Skip to content

Commit

Permalink
Fix some warnings instead of disabling them.
Browse files Browse the repository at this point in the history
Signed-off-by: Akshat Sikarwar <asikarwar1@bloomberg.net>
  • Loading branch information
akshatsikarwar committed May 9, 2024
1 parent 310230d commit 451ab09
Show file tree
Hide file tree
Showing 76 changed files with 730 additions and 1,122 deletions.
65 changes: 23 additions & 42 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,18 @@ else()
endif()

if(${CMAKE_SYSTEM_NAME} STREQUAL Darwin)
if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL x86_64)
if(EXISTS /opt/homebrew)
list(APPEND CMAKE_PREFIX_PATH
${CMAKE_PREFIX_PATH}
"/usr/local"
"/usr/local/opt/openssl"
"/usr/local/opt/readline")
${CMAKE_PREFIX_PATH}
"/opt/homebrew"
"/opt/homebrew/opt/openssl"
"/opt/homebrew/opt/readline")
else()
list(APPEND CMAKE_PREFIX_PATH
${CMAKE_PREFIX_PATH}
"/opt/homebrew"
"/opt/homebrew/opt/openssl"
"/opt/homebrew/opt/readline")
${CMAKE_PREFIX_PATH}
"/usr/local"
"/usr/local/opt/openssl"
"/usr/local/opt/readline")
endif()
endif()

Expand Down Expand Up @@ -189,16 +189,19 @@ else()
add_definitions(-DUSE_SYS_ALLOC)
endif()

if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL x86_64)
# This is mostly misused as little-endian
message("CMAKE_SYSTEM_PROCESSOR ${CMAKE_SYSTEM_PROCESSOR}")
message("CMAKE_SYSTEM_NAME ${CMAKE_SYSTEM_NAME}")
message("CMAKE_C_COMPILER_ID ${CMAKE_C_COMPILER_ID}")

# _LINUX_SOURCE is mostly misused as little-endian
if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL x86_64 OR ${CMAKE_SYSTEM_PROCESSOR} STREQUAL aarch64 OR ${CMAKE_SYSTEM_PROCESSOR} STREQUAL arm64)
add_definitions(-D_LINUX_SOURCE)
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL armv7l OR ${CMAKE_SYSTEM_PROCESSOR} STREQUAL aarch64)
add_definitions(-D_LINUX_SOURCE)
include(crc32c/arm.cmake)
endif()

if(${CMAKE_SYSTEM_NAME} STREQUAL Linux)
add_definitions(-D_GNU_SOURCE)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lrt")
elseif(${CMAKE_SYSTEM_NAME} STREQUAL AIX)
add_definitions(-D_IBM_SOURCE)
elseif(${CMAKE_SYSTEM_NAME} STREQUAL SunOS)
Expand All @@ -209,37 +212,23 @@ elseif(${CMAKE_SYSTEM_NAME} STREQUAL SunOS)
)
elseif(${CMAKE_SYSTEM_NAME} STREQUAL Darwin)
add_definitions(
-D_LINUX_SOURCE
-D_DARWIN_C_SOURCE
-D_XOPEN_SOURCE=600
)
set(CMAKE_CXX_STANDARD 17)
endif()

if (${CMAKE_C_COMPILER_ID} STREQUAL GNU OR ${CMAKE_C_COMPILER_ID} STREQUAL Clang OR ${CMAKE_C_COMPILER_ID} STREQUAL AppleClang)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
if (${CMAKE_SYSTEM_PROCESSOR} STREQUAL armv7l)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -latomic")
elseif(${CMAKE_C_COMPILER_ID} STREQUAL AppleClang)
set(CMAKE_CXX_STANDARD 17)
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-function")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-variable")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-switch")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-deprecated-non-prototype")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-but-set-variable")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-single-bit-bitfield-constant-conversion")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-tautological-constant-out-of-range-compare")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-format")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-array-parameter")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-incompatible-pointer-types")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wignored-qualifiers")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-switch")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-function")
if (${CMAKE_C_COMPILER_ID} STREQUAL GNU)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-stringop-truncation")
endif()
set(COMMON_FLAGS "${COMMON_FLAGS} -pthread")
set(COMMON_FLAGS "${COMMON_FLAGS} -fno-strict-aliasing")
if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL Darwin)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lrt")
endif()
elseif(${CMAKE_C_COMPILER_ID} STREQUAL XL)
set(COMMON_FLAGS "${COMMON_FLAGS} -qdfp")
set(COMMON_FLAGS "${COMMON_FLAGS} -qtls")
Expand All @@ -257,14 +246,6 @@ elseif(${CMAKE_C_COMPILER_ID} STREQUAL SunPro)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lresolv")
endif()

if (${CMAKE_C_COMPILER_ID} STREQUAL GNU)
if ((DEFINED CMAKE_C_COMPILER_VERSION) AND
((CMAKE_C_COMPILER_VERSION VERSION_GREATER 8.0) OR (CMAKE_C_COMPILER_VERSION VERSION_EQUAL 8.0)))
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-stringop-truncation")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-array-bounds")
endif()
endif()

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMMON_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_FLAGS}")

Expand Down
5 changes: 1 addition & 4 deletions archive/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
set(module cdb2archive)
set(MODULE CDB2ARCHIVE)
configure_file(${PROJECT_SOURCE_DIR}/mem/mem.h.in mem_util.h @ONLY)
set(src
ar_checksum.c
ar_wrap.c
)
set(src ar_wrap.c)
add_library(cdb2archive ${src})
include_directories(
${PROJECT_SOURCE_DIR}/bbinc
Expand Down
107 changes: 0 additions & 107 deletions archive/ar_checksum.c

This file was deleted.

28 changes: 0 additions & 28 deletions archive/ar_checksum.h

This file was deleted.

44 changes: 40 additions & 4 deletions archive/ar_wrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,47 @@
#include <stdint.h>
#include <string.h>
#include <poll.h>
#include "cdb2_constants.h"

#include <cdb2_constants.h>
#include <crc32c.h>

#include "ar_wrap.h"
#include "ar_checksum.h"

static uint32_t comdb2_ham_func4(const uint8_t *k, uint32_t len)
{
uint32_t h, loop;

if (len == 0)
return (0);

#define HASH4a h = (h << 5) - h + *k++;
#define HASH4b h = (h << 5) + h + *k++;
#define HASH4 HASH4b
h = 0;

loop = (len + 8 - 1) >> 3;
switch (len & (8 - 1)) {
case 0:
do {
HASH4;
case 7:
HASH4;
case 6:
HASH4;
case 5:
HASH4;
case 4:
HASH4;
case 3:
HASH4;
case 2:
HASH4;
case 1:
HASH4;
} while (--loop);
}
return (h);
}

#define MIN(A, B) (A < B) ? A : B
#define MAX_BUF_SIZE 4 * 1024 * 1024
Expand Down Expand Up @@ -329,7 +367,6 @@ int read_write_file(dbfile_info *f, void *writer_ctx, writer_cb writer)

uint8_t *pagebuf = f->pagebuf;
size_t bufsize = f->bufsize;
size_t total_bytes_read = 0;

while (bytes_left > 0) {
unsigned long long nbytes = bytes_left > bufsize ? bufsize : bytes_left;
Expand Down Expand Up @@ -408,7 +445,6 @@ int read_write_file(dbfile_info *f, void *writer_ctx, writer_cb writer)
goto done;
}

total_bytes_read += bytes_read;
bytes_left -= bytes_read;
}

Expand Down
9 changes: 2 additions & 7 deletions bdb/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,8 @@ add_custom_command(
COMMAND dist/genrec.sh ${CMAKE_CURRENT_SOURCE_DIR}/llog.src llog_auto.c llog_auto.h rec_llog
COMMAND dist/geninc.sh llog llog_ext.h llog_auto.c
)

if (${CMAKE_C_COMPILER_ID} STREQUAL GNU)
set_source_files_properties(llog_auto.c count.c PROPERTIES COMPILE_FLAGS "-Wno-unused-variable -Wno-unused-but-set-variable -Wno-unused-label")
elseif(${CMAKE_C_COMPILER_ID} STREQUAL Clang)
set_source_files_properties(llog_auto.c count.c PROPERTIES COMPILE_FLAGS "-Wno-unused-variable -Wno-unused-const-variable -Wno-unused-label -Wno-unused-but-set-variable")
elseif(${CMAKE_C_COMPILER_ID} STREQUAL AppleClang)
set_source_files_properties(llog_auto.c count.c PROPERTIES COMPILE_FLAGS "-Wno-unused-variable -Wno-unused-const-variable -Wno-unused-label")
if (${CMAKE_C_COMPILER_ID} STREQUAL AppleClang)
set_source_files_properties(llog_auto.c PROPERTIES COMPILE_FLAGS "-Wno-deprecated-non-prototype")
endif()

include_directories(
Expand Down
1 change: 0 additions & 1 deletion bdb/bdb_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -1795,7 +1795,6 @@ int sampler_last(sampler_t *);
int sampler_prev(sampler_t *);
int sampler_next(sampler_t *);
void *sampler_key(sampler_t *);
sampler_t *sampler_init();
int sampler_close(sampler_t *);

int bdb_summarize_table(bdb_state_type *bdb_state, int ixnum, int comp_pct,
Expand Down
Loading

0 comments on commit 451ab09

Please sign in to comment.