From dfad4a0f47897f6dd72ccd02e324878988bcc74a Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Tue, 26 Mar 2024 11:52:07 -0600 Subject: [PATCH] compile with strict flags (#36) -Wall -Wextra -Werror -pedantic Also passing in -Wno-unused-parameter because there are a lot of unused parameters, but (void) variable might not be desirable --- .github/workflows/ci.yml | 2 ++ CMakeLists.txt | 2 ++ src/client/info_display.c | 4 +--- src/common/parse.h | 2 +- src/compat/CMakeLists.txt | 4 ++++ 5 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 29898970..93f70a5f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,6 +7,8 @@ jobs: name: build runs-on: ubuntu-latest + env: + CFLAGS: -Wall -Wextra -Wno-unused-parameter -Werror -pedantic strategy: matrix: img: ["ubuntu:20.04", "ubuntu:22.04", "centos:8" ] diff --git a/CMakeLists.txt b/CMakeLists.txt index 0a9428bb..537a6d0e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,9 +33,11 @@ if (WITH_VERBS) if (IBVERBS) message(STATUS "libibverbs: ${IBVERBS}") check_include_files(infiniband/verbs.h HAVE_INFINIBAND_VERBS_H) + list(APPEND CMAKE_REQUIRED_FLAGS -Wno-pedantic) list(APPEND CMAKE_REQUIRED_LIBRARIES -libverbs) # CMP0075, requires CMake 3.12 check_symbol_exists(ibv_get_device_list "infiniband/verbs.h" IBV_GET_DEVICE_LIST) list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES -libverbs) + list(REMOVE_ITEM CMAKE_REQUIRED_FLAGS -Wno-pedantic) if (IBV_GET_DEVICE_LIST) set(CPACK_RPM_PACKAGE_REQUIRES "${CPACK_RPM_PACKAGE_REQUIRES}, libibverbs") list(APPEND CPACK_DEBIAN_PACKAGE_DEPENDS "libibverbs1") diff --git a/src/client/info_display.c b/src/client/info_display.c index 5bb95e82..211b8bed 100644 --- a/src/client/info_display.c +++ b/src/client/info_display.c @@ -141,8 +141,6 @@ xdd_target_info(FILE *out, target_data_t *tdp) { //ptds_t *masterp, *slavep; //lockstep_t *master_lsp, *slave_lsp; xint_data_pattern_t *dpp; - unsigned int j; - fprintf(out,"\tTarget number, %d\n",tdp->td_target_number); fprintf(out,"\t\tFully qualified target pathname, '%s'\n",tdp->td_target_full_pathname); fprintf(out,"\t\tTarget directory, %s\n",(strlen(tdp->td_target_directory)==0)?"\"./\"":tdp->td_target_directory); @@ -151,7 +149,7 @@ xdd_target_info(FILE *out, target_data_t *tdp) { #if HAVE_CPU_SET_T if (strlen(tdp->numa_node_list) > 0) { fprintf(out, "\t\tWorker threads pinned in NUMA domains, "); - for (j = 0; j < strlen(tdp->numa_node_list); j++) { + for (size_t j = 0; j < strlen(tdp->numa_node_list); j++) { if (j != strlen(tdp->numa_node_list) - 1) fprintf(out, "%c, ", tdp->numa_node_list[j]); else diff --git a/src/common/parse.h b/src/common/parse.h index 57290346..06f09d64 100644 --- a/src/common/parse.h +++ b/src/common/parse.h @@ -76,7 +76,7 @@ int xddfunc_nobarrier(xdd_plan_t *planp, int32_t argc, char *argv[], uint32_t fl int xddfunc_nomemlock(xdd_plan_t *planp, int32_t argc, char *argv[], uint32_t flags); int xddfunc_noordering(xdd_plan_t *planp, int32_t argc, char *argv[], uint32_t flags); int xddfunc_noproclock(xdd_plan_t *planp, int32_t argc, char *argv[], uint32_t flags); -#if HAVE_CPU_SET_T +#if HAVE_ENABLE_NUMA int xddfunc_numactl(xdd_plan_t *planp, int32_t argc, char *argv[], uint32_t flags); #endif int xddfunc_numreqs(xdd_plan_t *planp, int32_t argc, char *argv[], uint32_t flags); diff --git a/src/compat/CMakeLists.txt b/src/compat/CMakeLists.txt index 2dcfc665..d0c918c7 100644 --- a/src/compat/CMakeLists.txt +++ b/src/compat/CMakeLists.txt @@ -15,6 +15,7 @@ list(APPEND CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE) list(APPEND CMAKE_REQUIRED_LIBRARIES -pthread) # CMP0075, requires CMake 3.12 # functions +list(APPEND CMAKE_REQUIRED_FLAGS -Wno-pedantic) check_symbol_exists(clock_gettime "time.h" HAVE_CLOCK_GETTIME) check_symbol_exists(initstate "stdlib.h" HAVE_INITSTATE) check_symbol_exists(memset "string.h" HAVE_MEMSET) @@ -27,8 +28,10 @@ check_symbol_exists(random "stdlib.h" HAVE_RANDOM) check_symbol_exists(rand "stdlib.h" HAVE_RAND) check_symbol_exists(sched_getcpu "sched.h" HAVE_SCHED_GETCPU) check_symbol_exists(sched_setscheduler "sched.h" HAVE_SCHED_SETSCHEDULER) +list(REMOVE_ITEM CMAKE_REQUIRED_FLAGS -Wno-pedantic) # features +list(APPEND CMAKE_REQUIRED_FLAGS -Wno-unused-variable) check_symbol_exists(BLKGETSIZE64 "linux/fs.h" HAVE_DECL_BLKGETSIZE64) check_c_source_compiles("#include int main() { cpu_set_t cpuset; return 0; }" HAVE_CPU_SET_T) @@ -37,6 +40,7 @@ int main() { pthread_barrier_t pb; return 0; }" HAVE_PTHREAD_BARRIER_T) check_c_source_compiles("#include int main() { size_t sz; return 0; }" HAVE_SIZE_T) check_symbol_exists(TCP_CONGESTION "netinet/tcp.h" HAVE_DECL_TPC_CONGESTION) +list(REMOVE_ITEM CMAKE_REQUIRED_FLAGS -Wno-unused-variable) list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES -pthread) list(REMOVE_ITEM CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE)