🔧 build(compile Werror): reduce warning

This commit is contained in:
yangwei
2024-08-07 11:34:52 +08:00
committed by luwenpeng
parent 0c6b441157
commit 526171618f
28 changed files with 41 additions and 24 deletions

View File

@@ -9,6 +9,11 @@ add_definitions(-D_GNU_SOURCE)
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)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE RelWithDebInfo)
endif()

View File

@@ -189,17 +189,9 @@ int bitmap_check(bitmap_t *bitmap, unsigned int index, long offset)
int bitmap_flush(bitmap_t *bitmap)
{
#if 0
if ((msync(bitmap->array, bitmap->bytes, MS_SYNC) < 0)) {
perror("Error, flushing bitmap to disk");
return -1;
} else {
if(bitmap==NULL)return -1;
return 0;
}
#else
return 0;
#endif
}
/*
* Perform the actual hashing for `key`

View File

@@ -17,7 +17,7 @@ struct id_generator
uint64_t thread_volatile[MAX_THREAD_NUM];
};
struct id_generator global_id_generator = {0};
struct id_generator global_id_generator = {};
// return 0: success
// return -1: failed

View File

@@ -911,7 +911,7 @@ struct packet *ipv4_reassembly_packet(struct ip_reassembly *assy, const struct p
return NULL;
}
struct ip_flow_key key = {0};
struct ip_flow_key key = {};
uint64_t src_addr = hdr->ip_src.s_addr;
uint64_t dst_addr = hdr->ip_dst.s_addr;
key.src_dst_addr[0] = src_addr << 32 | dst_addr;
@@ -1004,7 +1004,7 @@ struct packet *ipv6_reassembly_packet(struct ip_reassembly *assy, const struct p
return NULL;
}
struct ip_flow_key key = {0};
struct ip_flow_key key = {};
memcpy(&key.src_dst_addr[0], hdr->ip6_src.s6_addr, 16);
memcpy(&key.src_dst_addr[2], hdr->ip6_dst.s6_addr, 16);
key.src_dst_len = IPV6_KEYLEN;

View File

@@ -33,7 +33,7 @@ struct log_context
};
struct log_context g_log_context = {
.config = {.output = LOG_OUTPUT_STDERR, .level = LOG_DEBUG},
.config = {},
.log_fd = -1,
.log_file_reopen_day = 0,
};

View File

@@ -152,7 +152,7 @@ static void calculate_length_and_checksum(const struct packet *origin_pkt, int l
struct gre1_hdr *gre1 = NULL;
struct raw_layer *curr_layer = NULL;
struct raw_layer *last_layer = NULL;
struct fingerprint finger = {0};
struct fingerprint finger = {};
calc_packet_fingerprint(&finger);
for (int i = layer_count - 1; i >= 0; i--)
{

View File

@@ -37,7 +37,7 @@ int packet_dump_pcap(const struct packet *pkt, const char *file)
const char *data = packet_get_raw_data(pkt);
uint16_t len = packet_get_raw_len(pkt);
struct pcap_pkt_hdr pkt_hdr = {0};
struct pcap_pkt_hdr pkt_hdr = {};
struct pcap_file_hdr file_hdr = {
.magic = 0xA1B2C3D4,
.version_major = 0x0002,
@@ -60,7 +60,7 @@ int packet_dump_pcap(const struct packet *pkt, const char *file)
return -1;
}
struct timeval ts = {0};
struct timeval ts = {};
gettimeofday(&ts, NULL);
pkt_hdr.tv_sec = ts.tv_sec;

View File

@@ -28,10 +28,9 @@ struct marsio_io
static void metadata_from_mbuff_to_packet(marsio_buff_t *mbuff, struct packet *pkt)
{
struct route_ctx route_ctx = {0};
struct sids sids = {0};
struct route_ctx route_ctx = {};
struct sids sids = {};
uint64_t session_id = {0};
uint64_t domain = {0};
uint16_t link_id = {0};
int is_ctrl = {0};
enum packet_direction direction = PACKET_DIRECTION_OUTGOING;
@@ -107,7 +106,7 @@ static void metadata_from_packet_to_mbuff(struct packet *pkt, marsio_buff_t *mbu
const struct route_ctx *route_ctx = packet_get_route_ctx(pkt);
const struct sids *sids = packet_get_sids(pkt);
uint64_t session_id = packet_get_session_id(pkt);
uint64_t domain = packet_get_domain(pkt);
//uint64_t domain = packet_get_domain(pkt);
uint16_t link_id = packet_get_link_id(pkt);
int is_ctrl = packet_is_ctrl(pkt);
enum packet_direction direction = packet_get_direction(pkt);

View File

@@ -19,7 +19,7 @@ struct session_exdata_manager
uint8_t count;
};
static struct session_exdata_manager g_ex_manager = {0};
static struct session_exdata_manager g_ex_manager = {};
/******************************************************************************
* session set/get

View File

@@ -28,6 +28,7 @@ struct session_manager_options opts = {
// udp timeout
.udp_data_timeout = 8,
.udp_discard_timeout = 0,
// duplicate packet filter
.duplicated_packet_filter_enable = 1,

View File

@@ -28,6 +28,7 @@ struct session_manager_options opts = {
// udp timeout
.udp_data_timeout = 8,
.udp_discard_timeout = 0,
// duplicate packet filter
.duplicated_packet_filter_enable = 1,

View File

@@ -29,6 +29,7 @@ struct session_manager_options opts = {
// udp timeout
.udp_data_timeout = 8,
.udp_discard_timeout = 0,
// duplicate packet filter

View File

@@ -29,6 +29,7 @@ struct session_manager_options opts = {
// udp timeout
.udp_data_timeout = 8,
.udp_discard_timeout = 0,
// duplicate packet filter

View File

@@ -29,6 +29,7 @@ struct session_manager_options opts = {
// udp timeout
.udp_data_timeout = 8,
.udp_discard_timeout = 0,
// duplicate packet filter
.duplicated_packet_filter_enable = 1,

View File

@@ -31,6 +31,7 @@ struct session_manager_options opts = {
// udp timeout
.udp_data_timeout = 8,
.udp_discard_timeout = 0,
// duplicate packet filter
.duplicated_packet_filter_enable = 1,

View File

@@ -31,6 +31,7 @@ struct session_manager_options opts = {
// udp timeout
.udp_data_timeout = 8,
.udp_discard_timeout = 0,
// duplicate packet filter
.duplicated_packet_filter_enable = 1,

View File

@@ -30,6 +30,7 @@ struct session_manager_options opts = {
// udp timeout
.udp_data_timeout = 8,
.udp_discard_timeout = 0,
// duplicate packet filter
.duplicated_packet_filter_enable = 1,

View File

@@ -30,6 +30,7 @@ struct session_manager_options opts = {
// udp timeout
.udp_data_timeout = 8,
.udp_discard_timeout = 0,
// duplicate packet filter
.duplicated_packet_filter_enable = 1,

View File

@@ -31,6 +31,7 @@ struct session_manager_options opts = {
// udp timeout
.udp_data_timeout = 8,
.udp_discard_timeout = 0,
// duplicate packet filter
.duplicated_packet_filter_enable = 1,

View File

@@ -30,6 +30,7 @@ struct session_manager_options opts = {
// udp timeout
.udp_data_timeout = 8,
.udp_discard_timeout = 0,
// duplicate packet filter
.duplicated_packet_filter_enable = 1,

View File

@@ -30,6 +30,7 @@ struct session_manager_options opts = {
// udp timeout
.udp_data_timeout = 8,
.udp_discard_timeout = 0,
// duplicate packet filter
.duplicated_packet_filter_enable = 1,

View File

@@ -28,6 +28,7 @@ struct session_manager_options opts = {
// udp timeout
.udp_data_timeout = 8,
.udp_discard_timeout = 0,
// duplicate packet filter
.duplicated_packet_filter_enable = 1,

View File

@@ -28,6 +28,7 @@ struct session_manager_options opts = {
// udp timeout
.udp_data_timeout = 8,
.udp_discard_timeout = 0,
// duplicate packet filter
.duplicated_packet_filter_enable = 1,

View File

@@ -28,6 +28,7 @@ struct session_manager_options opts = {
// udp timeout
.udp_data_timeout = 8,
.udp_discard_timeout = 0,
// duplicate packet filter
.duplicated_packet_filter_enable = 1,

View File

@@ -28,6 +28,7 @@ struct session_manager_options opts = {
// udp timeout
.udp_data_timeout = 8,
.udp_discard_timeout = 0,
// duplicate packet filter
.duplicated_packet_filter_enable = 1,

View File

@@ -413,7 +413,7 @@ int stellar_config_load(struct stellar_config *config, const char *file)
char errbuf[200];
FILE *fp = NULL;
toml_table_t *table = NULL;
memset(config, 0, sizeof(*config));
//memset(config, 0, sizeof(struct stellar_config));
fp = fopen(file, "r");
if (fp == NULL)

View File

@@ -435,7 +435,7 @@ static void stellar_thread_join(struct stellar_runtime *runtime, struct stellar_
int stellar_run(int argc, char **argv)
{
static struct stellar st = {0};
static struct stellar st={};
struct stellar_runtime *runtime = &st.runtime;
struct stellar_config *config = &st.config;

View File

@@ -279,8 +279,13 @@ static void usage(char *cmd)
int main(int argc, char **argv)
{
int opt = 0;
<<<<<<< HEAD
struct runtime rte = {0};
while ((opt = getopt(argc, argv, "f:tvh")) != -1)
=======
struct runtime rte = {};
while ((opt = getopt(argc, argv, "f:tvch")) != -1)
>>>>>>> 654eee3 (🔧 build(compile Werror): reduce warning)
{
switch (opt)
{