🐞 fix(warning as error): fix unused parameter warning

This commit is contained in:
yangwei
2024-08-07 13:34:56 +08:00
committed by luwenpeng
parent f1b3928c70
commit 6bb5c44ee3
12 changed files with 36 additions and 14 deletions

View File

@@ -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()

View File

@@ -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;

View File

@@ -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,

View File

@@ -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||len<sizeof(struct gre1_hdr))return 0;
const struct gre1_hdr *hdr = (const struct gre1_hdr *)data;
uint16_t hdr_len = 8;
uint16_t flags = gre1_hdr_get_flags(hdr);

View File

@@ -12,7 +12,7 @@ struct tunnel_detector
int (*identify_func)(const struct raw_layer *curr, const struct raw_layer *next1, const struct raw_layer *next2);
};
static int is_ipv4_tunnel(const struct raw_layer *curr, const struct raw_layer *next1, const struct raw_layer *next2)
static int is_ipv4_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 &&
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)

View File

@@ -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;
}

View File

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

View File

@@ -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);

View File

@@ -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)); \

View File

@@ -1,4 +1,4 @@
#include "stellar_core.h"
#include "stellar/stellar.h"
int main(int argc, char **argv)
{

View File

@@ -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;

View File

@@ -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__)