Skip to content

Commit 0dd3648

Browse files
authored
Merge pull request #889 from staniewzki/enable-werror
Enable -Werror flag in developer build
2 parents c6b68e6 + 68e19f5 commit 0dd3648

10 files changed

+32
-12
lines changed

cmake/helpers.cmake

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,9 @@ function(add_umf_target_compile_options name)
244244
target_compile_definitions(${name} PRIVATE -D_FORTIFY_SOURCE=2)
245245
endif()
246246
if(UMF_DEVELOPER_MODE)
247-
target_compile_options(${name} PRIVATE -fno-omit-frame-pointer
248-
-fstack-protector-strong)
247+
target_compile_options(
248+
${name} PRIVATE -fno-omit-frame-pointer
249+
-fstack-protector-strong -Werror)
249250
endif()
250251
if(UMF_USE_COVERAGE)
251252
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
@@ -279,6 +280,9 @@ function(add_umf_target_compile_options name)
279280
# disable 4200 warning: nonstandard extension used:
280281
# zero-sized array in struct/union
281282
/wd4200)
283+
if(UMF_DEVELOPER_MODE)
284+
target_compile_options(${name} PRIVATE /WX)
285+
endif()
282286
if(${CMAKE_C_COMPILER_ID} MATCHES "MSVC")
283287
target_compile_options(
284288
${name}

src/ipc_cache.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717
#include "utils_log.h"
1818
#include "utlist.h"
1919

20+
// HASH_ADD macro produces `warning C4702: unreachable code` on MSVC
21+
#ifdef _MSC_VER
22+
#pragma warning(disable : 4702)
23+
#endif
24+
2025
struct ipc_handle_cache_entry_t;
2126

2227
typedef struct ipc_handle_cache_entry_t *hash_map_t;

src/memtargets/memtarget_numa.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ static umf_result_t numa_initialize(void *params, void **memTarget) {
4040
return UMF_RESULT_ERROR_OUT_OF_HOST_MEMORY;
4141
}
4242

43-
numaTarget->physical_id = config->physical_id;
43+
numaTarget->physical_id = (unsigned)config->physical_id;
4444
*memTarget = numaTarget;
4545
return UMF_RESULT_SUCCESS;
4646
}
@@ -100,7 +100,7 @@ static umf_result_t numa_memory_provider_create_from_memspace(
100100

101101
params.partitions =
102102
(umf_numa_split_partition_t *)policy->ops.split.part;
103-
params.partitions_len = policy->ops.split.part_len;
103+
params.partitions_len = (unsigned)policy->ops.split.part_len;
104104
break;
105105
default:
106106
return UMF_RESULT_ERROR_INVALID_ARGUMENT;
@@ -131,7 +131,7 @@ static umf_result_t numa_memory_provider_create_from_memspace(
131131
for (size_t i = 0; i < numNodesProvider; i++) {
132132
params.numa_list[i] = numaTargets[i]->physical_id;
133133
}
134-
params.numa_list_len = numNodesProvider;
134+
params.numa_list_len = (unsigned)numNodesProvider;
135135
}
136136

137137
umf_memory_provider_handle_t numaProvider = NULL;

src/provider/provider_cuda.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ static void cu_memory_provider_finalize(void *provider) {
217217
umf_ba_global_free(provider);
218218
}
219219

220-
/*
220+
/*
221221
* This function is used by the CUDA provider to make sure that
222222
* the required context is set. If the current context is
223223
* not the required one, it will be saved in restore_ctx.

src/provider/provider_level_zero.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,12 @@ static umf_result_t ze_memory_provider_initialize(void *params,
148148
}
149149

150150
if ((ze_params->memory_type == UMF_MEMORY_TYPE_HOST) ==
151-
(bool)ze_params->level_zero_device_handle) {
151+
(ze_params->level_zero_device_handle != NULL)) {
152152
return UMF_RESULT_ERROR_INVALID_ARGUMENT;
153153
}
154154

155155
if ((bool)ze_params->resident_device_count !=
156-
(bool)ze_params->resident_device_handles) {
156+
(ze_params->resident_device_handles != NULL)) {
157157
return UMF_RESULT_ERROR_INVALID_ARGUMENT;
158158
}
159159

src/provider/provider_os_memory.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1207,8 +1207,9 @@ static umf_result_t os_get_ipc_handle(void *provider, const void *ptr,
12071207
os_ipc_data->visibility = os_provider->visibility;
12081208
os_ipc_data->shm_name_len = strlen(os_provider->shm_name);
12091209
if (os_ipc_data->shm_name_len > 0) {
1210+
// NOTE: +1 for '\0' at the end of the string
12101211
strncpy(os_ipc_data->shm_name, os_provider->shm_name,
1211-
os_ipc_data->shm_name_len);
1212+
os_ipc_data->shm_name_len + 1);
12121213
} else {
12131214
os_ipc_data->fd = os_provider->fd;
12141215
}

test/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,11 @@ function(build_umf_test)
7575
# tests retrieve arguments using 'GetParam()', which applies a 'const'
7676
# qualifier often discarded in the test scenarios.
7777
target_compile_options(${TEST_TARGET_NAME} PRIVATE -Wno-cast-qual)
78-
endif()
7978

79+
if(UMF_DEVELOPER_MODE)
80+
target_compile_options(${TEST_TARGET_NAME} PRIVATE -Werror)
81+
endif()
82+
endif()
8083
target_link_directories(${TEST_TARGET_NAME} PRIVATE ${LIB_DIRS})
8184

8285
target_include_directories(

test/memspaces/memspace_fixtures.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ struct memspaceProviderTest : ::memspaceGetTest {
8787
}
8888

8989
auto [isQuerySupported, memspaceGet] = ::memspaceGetTest::GetParam();
90+
(void)memspaceGet;
91+
9092
isQuerySupported(nodeIds.front());
9193

9294
// The test has been marked as skipped in isQuerySupported,

test/poolFixtures.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ struct umfPoolTest : umf_test::test,
7070

7171
auto [pool_ops, pool_params, provider_ops, provider_params,
7272
coarse_params] = this->GetParam();
73+
(void)pool_ops;
74+
(void)pool_params;
75+
(void)provider_params;
76+
(void)coarse_params;
77+
7378
if (provider_ops == umfDevDaxMemoryProviderOps()) {
7479
char *path = getenv("UMF_TESTS_DEVDAX_PATH");
7580
if (path == nullptr || path[0] == 0) {

test/providers/provider_level_zero.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,9 +254,9 @@ TEST_P(umfLevelZeroProviderTest, allocInvalidSize) {
254254
ASSERT_EQ(umf_result, UMF_RESULT_SUCCESS);
255255
ASSERT_NE(provider, nullptr);
256256

257-
// try to alloc (int)-1
258257
void *ptr = nullptr;
259-
umf_result = umfMemoryProviderAlloc(provider, -1, 0, &ptr);
258+
umf_result = umfMemoryProviderAlloc(
259+
provider, std::numeric_limits<size_t>::max(), 0, &ptr);
260260
ASSERT_EQ(umf_result, UMF_RESULT_ERROR_MEMORY_PROVIDER_SPECIFIC);
261261
const char *message;
262262
int32_t error;

0 commit comments

Comments
 (0)