Skip to content

Commit 7a7b552

Browse files
committed
Enable -Werror in developer build
1 parent 8ea6d11 commit 7a7b552

File tree

8 files changed

+35
-13
lines changed

8 files changed

+35
-13
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: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,9 @@ umf_result_t umfIpcCacheGlobalInit(void) {
8989
return ret;
9090
}
9191

92-
static size_t getGlobalLruListSize(lru_list_t lru_list) {
92+
// Removed `static, because of an unused function warning
93+
// TODO: restore static
94+
size_t getGlobalLruListSize(lru_list_t lru_list) {
9395
size_t size = 0;
9496
ipc_handle_cache_entry_t *tmp;
9597
DL_COUNT(lru_list, tmp, size);
@@ -216,7 +218,15 @@ umfIpcHandleMappedCacheGet(ipc_mapped_handle_cache_handle_t cache,
216218
entry->value.mapped_size = 0;
217219
entry->value.mapped_base_ptr = NULL;
218220

221+
#ifdef _MSC_VER
222+
#pragma warning(disable : 4702)
223+
#endif
224+
// HASH_ADD produces `warning C4702: unreachable code` on MSVC
219225
HASH_ADD(hh, cache->hash_table, key, sizeof(entry->key), entry);
226+
#ifdef _MSC_VER
227+
#pragma warning(default : 4702)
228+
#endif
229+
220230
DL_PREPEND(cache->global->lru_list, entry);
221231
cache->global->cur_size += 1;
222232
}

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_devdax_memory.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ static umf_result_t devdax_open_ipc_handle(void *provider,
474474
LOG_DEBUG("devdax mapped (path: %s, size: %zu, protection: %i, fd: %i, "
475475
"offset: %zu) to address %p",
476476
devdax_ipc_data->path, length_aligned,
477-
devdax_ipc_data->protection, fd, offset_aligned, addr);
477+
devdax_ipc_data->protection, fd, offset_aligned, (void *)addr);
478478

479479
*ptr = addr;
480480

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

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/ipc_os_prov_proxy.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,9 @@ int main(int argc, char *argv[]) {
106106
}
107107

108108
fprintf(stderr, "Allocated memory - %zu\n", size);
109-
size_t val = 144;
110-
size_t expected_val = val / 2;
111-
*(size_t *)ptr = val;
109+
unsigned long long val = 144;
110+
unsigned long long expected_val = val / 2;
111+
*(unsigned long long *)ptr = val;
112112

113113
// get IPC handle of the allocation
114114
umf_ipc_handle_t ipc_handle = NULL;

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

0 commit comments

Comments
 (0)