Skip to content

Commit cb37f2a

Browse files
Add /we4189 switch to CMAKE_CXX_FLAGS for MSVC.
- treat unused local variables warnings as error in Debug Change-Id: I2da08b72e0f0083d3cdf932fbf92ef4981a88615
1 parent 6e0d04e commit cb37f2a

16 files changed

+51
-66
lines changed

CMakeLists.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ if(NOT DEFINED AUB_STREAM_DIR AND NOT DISABLE_AUB_STREAM)
129129
endif()
130130
else()
131131
unset(AUB_STREAM_DIR)
132-
endif(NOT DEFINED AUB_STREAM_DIR)
132+
endif()
133133

134134
if(LIBDRM_DIR)
135135
get_filename_component(I915_INCLUDES_DIR "${LIBDRM_DIR}/include" ABSOLUTE)
@@ -469,7 +469,10 @@ endif()
469469
if(MSVC)
470470
# Force to treat warnings as errors
471471
if(NOT CMAKE_CXX_FLAGS MATCHES "/WX")
472-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX")
472+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX")
473+
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
474+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /we4189")
475+
endif()
473476
endif()
474477

475478
# Support for WUD

offline_compiler/utilities/windows/seh_exception.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2018 Intel Corporation
2+
* Copyright (C) 2018-2019 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -73,6 +73,10 @@ void SehException::getCallStack(unsigned int code, struct _EXCEPTION_POINTERS *e
7373
stack.clear();
7474

7575
BOOL result = SymInitialize(hProcess, NULL, TRUE);
76+
if (result == FALSE) {
77+
return;
78+
}
79+
7680
STACKFRAME64 stackFrame;
7781
memset(&stackFrame, 0, sizeof(STACKFRAME64));
7882
const int nameSize = 255;

runtime/os_interface/windows/device_factory_win.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2017-2018 Intel Corporation
2+
* Copyright (C) 2017-2019 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*

runtime/os_interface/windows/kmdaf_listener.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
/*
2-
* Copyright (C) 2018 Intel Corporation
2+
* Copyright (C) 2018-2019 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
66
*/
77

88
#include "runtime/os_interface/windows/kmdaf_listener.h"
9+
#pragma warning(push) // save the current state
10+
#pragma warning(disable : 4189) // disable warning 4189 (unused local variable)
911
#include "kmdaf.h"
12+
#pragma warning(pop) // restore state.
1013

1114
namespace OCLRT {
1215

runtime/os_interface/windows/thk_wrapper.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2017-2018 Intel Corporation
2+
* Copyright (C) 2017-2019 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -80,8 +80,7 @@ class ThkWrapper {
8080
SYSTEM_ENTER()
8181
NTSTATUS Status;
8282
Status = mFunc(param);
83-
unsigned int ID = getId<Param>();
84-
SYSTEM_LEAVE(ID);
83+
SYSTEM_LEAVE(getId<Param>());
8584
return Status;
8685
} else {
8786
return mFunc(param);

runtime/os_interface/windows/wddm/wddm.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -943,7 +943,7 @@ bool Wddm::init(PreemptionMode preemptionMode) {
943943

944944
EvictionStatus Wddm::evictAllTemporaryResources() {
945945
decltype(temporaryResources) resourcesToEvict;
946-
auto &lock = acquireLock(temporaryResourcesLock);
946+
auto lock = acquireLock(temporaryResourcesLock);
947947
temporaryResources.swap(resourcesToEvict);
948948
if (resourcesToEvict.empty()) {
949949
return EvictionStatus::NOT_APPLIED;
@@ -959,7 +959,7 @@ EvictionStatus Wddm::evictAllTemporaryResources() {
959959
}
960960

961961
EvictionStatus Wddm::evictTemporaryResource(WddmAllocation &allocation) {
962-
auto &lock = acquireLock(temporaryResourcesLock);
962+
auto lock = acquireLock(temporaryResourcesLock);
963963
auto position = std::find(temporaryResources.begin(), temporaryResources.end(), allocation.handle);
964964
if (position == temporaryResources.end()) {
965965
return EvictionStatus::NOT_APPLIED;

runtime/sharings/d3d/d3d_sharing.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2017-2018 Intel Corporation
2+
* Copyright (C) 2017-2019 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -41,8 +41,6 @@ D3DSharing<D3D>::~D3DSharing() {
4141

4242
template <typename D3D>
4343
void D3DSharing<D3D>::synchronizeObject(UpdateData &updateData) {
44-
void *sharedHandle = nullptr;
45-
4644
sharingFunctions->getDeviceContext(d3dQuery);
4745
if (!sharedResource) {
4846
sharingFunctions->copySubresourceRegion(resourceStaging, 0, resource, subresource);

unit_tests/device/device_win_timers_tests.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2017-2018 Intel Corporation
2+
* Copyright (C) 2017-2019 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -22,7 +22,9 @@ TEST_F(MockOSTimeWinTest, DynamicResolution) {
2222
auto wddmMock = std::unique_ptr<WddmMock>(new WddmMock());
2323
auto mDev = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
2424

25-
bool error = wddmMock->init(mDev->getPreemptionMode());
25+
bool success = wddmMock->init(mDev->getPreemptionMode());
26+
EXPECT_TRUE(success);
27+
2628
std::unique_ptr<MockOSTimeWin> timeWin(new MockOSTimeWin(wddmMock.get()));
2729

2830
double res = 0.0;

unit_tests/gen9/windows/os_interface_tests_gen9.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2017-2018 Intel Corporation
2+
* Copyright (C) 2017-2019 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -13,7 +13,6 @@ typedef OsInterfaceTest OsInterfaceTestSkl;
1313

1414
GEN9TEST_F(OsInterfaceTestSkl, askKmdIfPreemptionRegisterWhitelisted) {
1515
HardwareInfo *hwInfo = nullptr;
16-
const HardwareInfo *refHwinfo = *platformDevices;
1716
size_t numDevices = 0;
1817

1918
ExecutionEnvironment executionEnvironment;

unit_tests/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,13 +172,13 @@ int main(int argc, char **argv) {
172172
int retVal = 0;
173173
bool useDefaultListener = false;
174174
bool enable_alarm = true;
175-
bool enable_segv = true;
176-
bool enable_abrt = true;
177175
bool setupFeatureTable = testMode == TestMode::AubTests ? true : false;
178176

179177
applyWorkarounds();
180178

181179
#if defined(__linux__)
180+
bool enable_segv = true;
181+
bool enable_abrt = true;
182182
if (getenv("IGDRCL_TEST_SELF_EXEC") == nullptr) {
183183
std::string wd = getRunPath(argv[0]);
184184
setenv("LD_LIBRARY_PATH", wd.c_str(), 1);

unit_tests/mocks/mock_wddm.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ bool WddmMock::destroyAllocation(WddmAllocation *alloc, OsContextWin *osContext)
8181
D3DKMT_HANDLE *allocationHandles = nullptr;
8282
uint32_t allocationCount = 0;
8383
D3DKMT_HANDLE resourceHandle = 0;
84-
void *cpuPtr = nullptr;
8584
void *reserveAddress = alloc->getReservedAddress();
8685
if (alloc->peekSharedHandle()) {
8786
resourceHandle = alloc->resourceHandle;

unit_tests/os_interface/windows/device_command_stream_tests.cpp

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ TEST_F(WddmCommandStreamTest, givenGraphicsAllocationWithDifferentGpuAddressThen
204204

205205
LinearStream cs(commandBuffer);
206206
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
207-
auto flushStamp = csr->flush(batchBuffer, csr->getResidencyAllocations());
207+
csr->flush(batchBuffer, csr->getResidencyAllocations());
208208
EXPECT_EQ(mockGpuAddres, wddm->submitResult.commandBufferSubmitted);
209209
memoryManager->freeGraphicsMemory(commandBuffer);
210210
}
@@ -376,7 +376,7 @@ TEST_F(WddmCommandStreamTest, givenWddmWithKmDafDisabledWhenFlushIsCalledWithAll
376376
ResidencyContainer allocationsForResidency = {linearStreamAllocation};
377377

378378
EXPECT_FALSE(wddm->isKmDafEnabled());
379-
auto flushStamp = csr->flush(batchBuffer, allocationsForResidency);
379+
csr->flush(batchBuffer, allocationsForResidency);
380380

381381
EXPECT_EQ(0u, wddm->kmDafLockResult.called);
382382
EXPECT_EQ(0u, wddm->kmDafLockResult.lockedAllocations.size());
@@ -392,7 +392,7 @@ TEST_F(WddmCommandStreamTest, givenWddmWithKmDafEnabledWhenFlushIsCalledWithoutA
392392
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
393393

394394
wddm->setKmDafEnabled(true);
395-
auto flushStamp = csr->flush(batchBuffer, csr->getResidencyAllocations());
395+
csr->flush(batchBuffer, csr->getResidencyAllocations());
396396

397397
EXPECT_EQ(0u, wddm->kmDafLockResult.called);
398398
EXPECT_EQ(0u, wddm->kmDafLockResult.lockedAllocations.size());
@@ -415,7 +415,7 @@ TEST_F(WddmCommandStreamTest, givenWddmWithKmDafEnabledWhenFlushIsCalledWithResi
415415
EXPECT_EQ(linearStreamAllocation, csr->getResidencyAllocations()[0]);
416416

417417
wddm->setKmDafEnabled(true);
418-
auto flushStamp = csr->flush(batchBuffer, csr->getResidencyAllocations());
418+
csr->flush(batchBuffer, csr->getResidencyAllocations());
419419

420420
EXPECT_EQ(1u, wddm->kmDafLockResult.called);
421421
EXPECT_EQ(1u, wddm->kmDafLockResult.lockedAllocations.size());
@@ -437,7 +437,7 @@ TEST_F(WddmCommandStreamTest, givenWddmWithKmDafEnabledWhenFlushIsCalledWithAllo
437437
ResidencyContainer allocationsForResidency = {linearStreamAllocation};
438438

439439
wddm->setKmDafEnabled(true);
440-
auto flushStamp = csr->flush(batchBuffer, allocationsForResidency);
440+
csr->flush(batchBuffer, allocationsForResidency);
441441

442442
EXPECT_EQ(1u, wddm->kmDafLockResult.called);
443443
EXPECT_EQ(1u, wddm->kmDafLockResult.lockedAllocations.size());
@@ -459,7 +459,7 @@ TEST_F(WddmCommandStreamTest, givenWddmWithKmDafEnabledWhenFlushIsCalledWithAllo
459459
ResidencyContainer allocationsForResidency = {fillPatternAllocation};
460460

461461
wddm->setKmDafEnabled(true);
462-
auto flushStamp = csr->flush(batchBuffer, allocationsForResidency);
462+
csr->flush(batchBuffer, allocationsForResidency);
463463

464464
EXPECT_EQ(1u, wddm->kmDafLockResult.called);
465465
EXPECT_EQ(1u, wddm->kmDafLockResult.lockedAllocations.size());
@@ -480,7 +480,7 @@ TEST_F(WddmCommandStreamTest, givenWddmWithKmDafEnabledWhenFlushIsCalledWithAllo
480480
ResidencyContainer allocationsForResidency = {nonLinearStreamAllocation};
481481

482482
wddm->setKmDafEnabled(true);
483-
auto flushStamp = csr->flush(batchBuffer, allocationsForResidency);
483+
csr->flush(batchBuffer, allocationsForResidency);
484484

485485
EXPECT_EQ(0u, wddm->kmDafLockResult.called);
486486
EXPECT_EQ(0u, wddm->kmDafLockResult.lockedAllocations.size());
@@ -490,8 +490,6 @@ TEST_F(WddmCommandStreamTest, givenWddmWithKmDafEnabledWhenFlushIsCalledWithAllo
490490
}
491491

492492
TEST_F(WddmCommandStreamTest, makeResident) {
493-
WddmMemoryManager *wddmMM = reinterpret_cast<WddmMemoryManager *>(memoryManager);
494-
495493
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
496494
ASSERT_NE(nullptr, commandBuffer);
497495
LinearStream cs(commandBuffer);
@@ -506,8 +504,6 @@ TEST_F(WddmCommandStreamTest, makeResident) {
506504
}
507505

508506
TEST_F(WddmCommandStreamTest, makeNonResidentPutsAllocationInEvictionAllocations) {
509-
WddmMemoryManager *wddmMM = reinterpret_cast<WddmMemoryManager *>(memoryManager);
510-
511507
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
512508
ASSERT_NE(nullptr, commandBuffer);
513509
LinearStream cs(commandBuffer);
@@ -522,8 +518,6 @@ TEST_F(WddmCommandStreamTest, makeNonResidentPutsAllocationInEvictionAllocations
522518
}
523519

524520
TEST_F(WddmCommandStreamTest, processEvictionPlacesAllAllocationsOnTrimCandidateList) {
525-
WddmMemoryManager *wddmMM = reinterpret_cast<WddmMemoryManager *>(memoryManager);
526-
527521
GraphicsAllocation *allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
528522
GraphicsAllocation *allocation2 = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
529523
ASSERT_NE(nullptr, allocation);
@@ -543,8 +537,6 @@ TEST_F(WddmCommandStreamTest, processEvictionPlacesAllAllocationsOnTrimCandidate
543537
}
544538

545539
TEST_F(WddmCommandStreamTest, processEvictionClearsEvictionAllocations) {
546-
WddmMemoryManager *wddmMM = reinterpret_cast<WddmMemoryManager *>(memoryManager);
547-
548540
GraphicsAllocation *allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
549541
ASSERT_NE(nullptr, allocation);
550542

@@ -562,7 +554,6 @@ TEST_F(WddmCommandStreamTest, processEvictionClearsEvictionAllocations) {
562554
TEST_F(WddmCommandStreamTest, makeResidentNonResidentMemObj) {
563555
GraphicsAllocation *gfxAllocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
564556
Buffer *buffer = new AlignedBuffer(gfxAllocation);
565-
WddmMemoryManager *wddmMM = reinterpret_cast<WddmMemoryManager *>(memoryManager);
566557

567558
csr->makeResident(*buffer->getGraphicsAllocation());
568559
EXPECT_EQ(0u, wddm->makeResidentResult.called);
@@ -888,7 +879,7 @@ HWTEST_F(WddmCsrCompressionTests, givenEnabledCompressionWhenFlushingThenInitTra
888879

889880
auto memoryManager = executionEnvironment->memoryManager.get();
890881

891-
auto &csrCS = mockWddmCsr->getCS();
882+
mockWddmCsr->getCS();
892883

893884
auto graphicsAllocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
894885
IndirectHeap cs(graphicsAllocation);

unit_tests/os_interface/windows/gl/gl_os_sharing_tests.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ TEST_F(GlArbSyncEventOsTest, WhenCreateSynchronizationObjectSucceedsThenAllHAndl
137137
gdi->createSynchronizationObject.mFunc = CreateSyncObjectMock::createSynchObject;
138138
gdi->createSynchronizationObject2.mFunc = CreateSyncObjectMock::createSynchObject2;
139139
auto ret = setupArbSyncObject(sharing, osInterface, syncInfo);
140+
EXPECT_TRUE(ret);
140141
EXPECT_EQ(1U, syncInfo.serverSynchronizationObject);
141142
EXPECT_EQ(2U, syncInfo.clientSynchronizationObject);
142143
EXPECT_EQ(3U, syncInfo.submissionSynchronizationObject);

unit_tests/os_interface/windows/wddm20_tests.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ TEST_F(Wddm20WithMockGdiDllTests, givenWddmAllocationWhenMappingGpuVaThenUseGmmS
224224

225225
allocation.gmm = gmm.get();
226226
auto status = wddm->createAllocation(&allocation);
227+
EXPECT_EQ(STATUS_SUCCESS, status);
227228

228229
auto mockResourceInfo = static_cast<MockGmmResourceInfo *>(gmm->gmmResourceInfo.get());
229230
mockResourceInfo->overrideReturnedSize(allocation.getAlignedSize() + (2 * MemoryConstants::pageSize));
@@ -646,8 +647,6 @@ TEST_F(Wddm20Tests, givenDestroyAllocationWhenItIsCalledThenAllocationIsPassedTo
646647

647648
*osContextWin->getResidencyController().getMonitoredFence().cpuAddress = 10;
648649

649-
D3DKMT_HANDLE handle = (D3DKMT_HANDLE)0x1234;
650-
651650
gdi->getWaitFromCpuArg().FenceValueArray = nullptr;
652651
gdi->getWaitFromCpuArg().Flags.Value = 0;
653652
gdi->getWaitFromCpuArg().hDevice = (D3DKMT_HANDLE)0;

0 commit comments

Comments
 (0)