diff --git a/CMakeLists.txt b/CMakeLists.txt index 61b786b..efdec6f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,9 +10,7 @@ set(CMAKE_CXX_STANDARD 11) set(CMAKE_C_STANDARD 11) #set warning as error -add_compile_options(-Wall -Wextra -Werror - -Wno-error=implicit-fallthrough - -Wno-error=unused-parameter) +add_compile_options(-Wall -Wextra -Werror) if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE RelWithDebInfo) @@ -49,7 +47,8 @@ if (CMAKE_CXX_CPPCHECK) "--suppress=duplicateValueTernary" "--suppress=funcArgOrderDifferent" "--suppress=*:${PROJECT_SOURCE_DIR}/vendors/*" - "--suppress=*:${PROJECT_SOURCE_DIR}/deps/*" + "--suppress=*:${PROJECT_SOURCE_DIR}/deps/toml/*" + "--suppress=*:${PROJECT_SOURCE_DIR}/deps/rbtree/*" ) set(CMAKE_C_CPPCHECK ${CMAKE_CXX_CPPCHECK}) else() diff --git a/deps/dablooms/murmur.cpp b/deps/dablooms/murmur.cpp index a36c5fa..83baeb4 100644 --- a/deps/dablooms/murmur.cpp +++ b/deps/dablooms/murmur.cpp @@ -92,37 +92,50 @@ void MurmurHash3_x64_128(const void *key, const int len, const uint32_t seed, vo { case 15: k2 ^= ((uint64_t)tail[14]) << 48; + [[fallthrough]]; case 14: k2 ^= ((uint64_t)tail[13]) << 40; + [[fallthrough]]; case 13: k2 ^= ((uint64_t)tail[12]) << 32; + [[fallthrough]]; case 12: k2 ^= ((uint64_t)tail[11]) << 24; + [[fallthrough]]; case 11: k2 ^= ((uint64_t)tail[10]) << 16; + [[fallthrough]]; case 10: k2 ^= ((uint64_t)tail[9]) << 8; + [[fallthrough]]; case 9: k2 ^= ((uint64_t)tail[8]) << 0; k2 *= c2; k2 = ROTL64(k2, 33); k2 *= c1; h2 ^= k2; - + [[fallthrough]]; case 8: k1 ^= ((uint64_t)tail[7]) << 56; + [[fallthrough]]; case 7: k1 ^= ((uint64_t)tail[6]) << 48; + [[fallthrough]]; case 6: k1 ^= ((uint64_t)tail[5]) << 40; + [[fallthrough]]; case 5: k1 ^= ((uint64_t)tail[4]) << 32; + [[fallthrough]]; case 4: k1 ^= ((uint64_t)tail[3]) << 24; + [[fallthrough]]; case 3: k1 ^= ((uint64_t)tail[2]) << 16; + [[fallthrough]]; case 2: k1 ^= ((uint64_t)tail[1]) << 8; + [[fallthrough]]; case 1: k1 ^= ((uint64_t)tail[0]) << 0; k1 *= c1; diff --git a/deps/rbtree/rbtree.cpp b/deps/rbtree/rbtree.cpp index d648a94..2365dcd 100644 --- a/deps/rbtree/rbtree.cpp +++ b/deps/rbtree/rbtree.cpp @@ -442,11 +442,15 @@ void __rb_erase_color(struct rb_node *parent, struct rb_root *root, * We use dummy augmented callbacks here, and have the compiler optimize them * out of the rb_insert_color() and rb_erase() function definitions. */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" static inline void dummy_propagate(struct rb_node *node, struct rb_node *stop) {} static inline void dummy_copy(struct rb_node *old, struct rb_node *new_node) {} static inline void dummy_rotate(struct rb_node *old, struct rb_node *new_node) {} +#pragma GCC diagnostic pop + static const struct rb_augment_callbacks dummy_callbacks = { .propagate = dummy_propagate, .copy = dummy_copy, diff --git a/src/packet/gre1_utils.h b/src/packet/gre1_utils.h index 5b8b62a..58c1bfd 100644 --- a/src/packet/gre1_utils.h +++ b/src/packet/gre1_utils.h @@ -117,6 +117,7 @@ static inline uint32_t gre1_hdr_get_ack(const struct gre1_hdr *hdr) static inline uint16_t calc_gre1_hdr_len(const char *data, uint32_t len) { + if(data==NULL||lenproto == LAYER_PROTO_IPV4 && next1 && (next1->proto == LAYER_PROTO_IPV4 || next1->proto == LAYER_PROTO_IPV6)) @@ -23,7 +23,7 @@ static int is_ipv4_tunnel(const struct raw_layer *curr, const struct raw_layer * return 0; } -static int is_ipv6_tunnel(const struct raw_layer *curr, const struct raw_layer *next1, const struct raw_layer *next2) +static int is_ipv6_tunnel(const struct raw_layer *curr, const struct raw_layer *next1, const struct raw_layer *next __attribute__((unused))) { if (curr && curr->proto == LAYER_PROTO_IPV6 && next1 && (next1->proto == LAYER_PROTO_IPV4 || next1->proto == LAYER_PROTO_IPV6)) @@ -34,7 +34,7 @@ static int is_ipv6_tunnel(const struct raw_layer *curr, const struct raw_layer * return 0; } -static int is_gre_tunnel(const struct raw_layer *curr, const struct raw_layer *next1, const struct raw_layer *next2) +static int is_gre_tunnel(const struct raw_layer *curr, const struct raw_layer *next1, const struct raw_layer *next2 __attribute__((unused))) { if (curr && (curr->proto == LAYER_PROTO_IPV4 || curr->proto == LAYER_PROTO_IPV6) && next1 && next1->proto == LAYER_PROTO_GRE) diff --git a/src/packet_io/dumpfile_io.cpp b/src/packet_io/dumpfile_io.cpp index 4525bf5..29fc2d2 100644 --- a/src/packet_io/dumpfile_io.cpp +++ b/src/packet_io/dumpfile_io.cpp @@ -298,7 +298,7 @@ int dumpfile_io_wait_exit(struct dumpfile_io *handle) return ATOMIC_READ(&handle->io_thread_wait_exit); } -int dumpfile_io_init(struct dumpfile_io *handle, uint16_t thr_idx) +int dumpfile_io_init(struct dumpfile_io *handle __attribute__((unused)), uint16_t thr_idx __attribute__((unused))) { return 0; } @@ -437,7 +437,7 @@ int dumpfile_io_inject(struct dumpfile_io *handle, uint16_t thr_idx, struct pack return nr_pkts; } -void dumpfile_io_yield(struct dumpfile_io *handle, uint16_t thr_idx, uint64_t timeout_ms) +void dumpfile_io_yield(struct dumpfile_io *handle __attribute__((unused)), uint16_t thr_idx __attribute__((unused)), uint64_t timeout_ms __attribute__((unused))) { return; } diff --git a/src/packet_io/marsio_io.cpp b/src/packet_io/marsio_io.cpp index e10ec94..94b5a47 100644 --- a/src/packet_io/marsio_io.cpp +++ b/src/packet_io/marsio_io.cpp @@ -246,7 +246,7 @@ void marsio_io_free(struct marsio_io *handle) } } -int marsio_io_init(struct marsio_io *handle, uint16_t thr_idx) +int marsio_io_init(struct marsio_io *handle, uint16_t thr_idx __attribute__((unused))) { if (marsio_thread_init(handle->mr_ins) != 0) { diff --git a/src/plugin/plugin_manager.cpp b/src/plugin/plugin_manager.cpp index 111c64c..5cf0797 100644 --- a/src/plugin/plugin_manager.cpp +++ b/src/plugin/plugin_manager.cpp @@ -105,7 +105,7 @@ static void plugin_manager_per_thread_data_free(struct plugin_manger_per_thread_ return; } -static void tcp_stream_msg_free_fn(void *msg, void *msg_free_arg) +static void tcp_stream_msg_free_fn(void *msg, void *msg_free_arg __attribute__((unused))) { struct session *cur_sess = plugin_manager_scratch_session_get(); if(msg && cur_sess)session_free_tcp_segment(cur_sess, (struct tcp_segment *)msg); diff --git a/src/session/test/gtest_session.cpp b/src/session/test/gtest_session.cpp index 3a6c5b8..3afaf01 100644 --- a/src/session/test/gtest_session.cpp +++ b/src/session/test/gtest_session.cpp @@ -3,6 +3,8 @@ #include "session_def.h" #include "session_utils.h" +#pragma GCC diagnostic ignored "-Wunused-parameter" + #define SESSION_KEY_IPV4_TCP(name) \ struct tuple6 name; \ memset(&name, 0, sizeof(struct tuple6)); \ diff --git a/src/stellar/main.cpp b/src/stellar/main.cpp index c7e5b8f..69a7405 100644 --- a/src/stellar/main.cpp +++ b/src/stellar/main.cpp @@ -1,4 +1,4 @@ -#include "stellar_core.h" +#include "stellar/stellar.h" int main(int argc, char **argv) { diff --git a/src/stellar/stellar_core.cpp b/src/stellar/stellar_core.cpp index 3064b19..79de2b6 100644 --- a/src/stellar/stellar_core.cpp +++ b/src/stellar/stellar_core.cpp @@ -433,7 +433,7 @@ static void stellar_thread_join(struct stellar_runtime *runtime, struct stellar_ } } -int stellar_run(int argc, char **argv) +int stellar_run(int argc __attribute__((unused)), char **argv __attribute__((unused))) { static struct stellar st={}; struct stellar_runtime *runtime = &st.runtime; diff --git a/test/packet_inject/packet_inject.cpp b/test/packet_inject/packet_inject.cpp index 3161218..f9bc08c 100644 --- a/test/packet_inject/packet_inject.cpp +++ b/test/packet_inject/packet_inject.cpp @@ -10,6 +10,9 @@ #include "stellar/session.h" #include "stellar/stellar_mq.h" + +#pragma GCC diagnostic ignored "-Wunused-parameter" + #define LOG_ERR(fmt, ...) printf("ERROR [packet inject] " fmt, ##__VA_ARGS__) #define LOG_INFO(fmt, ...) printf("INFO [packet inject] " fmt, ##__VA_ARGS__)