Skip to content

Commit

Permalink
compile with strict flags (#36)
Browse files Browse the repository at this point in the history
-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
  • Loading branch information
calccrypto authored Mar 26, 2024
1 parent 0b1aaab commit dfad4a0
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]
Expand Down
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
4 changes: 1 addition & 3 deletions src/client/info_display.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/common/parse.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions src/compat/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 <sched.h>
int main() { cpu_set_t cpuset; return 0; }" HAVE_CPU_SET_T)
Expand All @@ -37,6 +40,7 @@ int main() { pthread_barrier_t pb; return 0; }" HAVE_PTHREAD_BARRIER_T)
check_c_source_compiles("#include <stddef.h>
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)
Expand Down

0 comments on commit dfad4a0

Please sign in to comment.