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

File tree

16 files changed

+51
-66
lines changed

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);

0 commit comments

Comments
 (0)