]> git.feebdaed.xyz Git - 0xmirror/f-stack.git/commitdiff
Added the -Wextra compilation option and fixed compilation errors.
authorfengbojiang <fengbojiang@tencent.com>
Wed, 29 Oct 2025 11:58:45 +0000 (19:58 +0800)
committerfengbojiang <fengbojiang@tencent.com>
Wed, 29 Oct 2025 11:58:45 +0000 (19:58 +0800)
lib/Makefile
lib/ff_config.c
lib/ff_config.h
lib/ff_dpdk_if.c
lib/ff_dpdk_kni.c
lib/ff_epoll.c
lib/ff_host_interface.c

index 917b4b7cefb4cf018370a6cb29e8b4e02fb32958..641e8ca2e5cd760be359829633776a276cdbaf7a 100644 (file)
@@ -62,7 +62,7 @@ endif
 
 PKGCONF ?= pkg-config
 
-DPDK_CFLAGS= -Wall -Wno-deprecated-declarations -Werror $(shell $(PKGCONF) --cflags libdpdk)
+DPDK_CFLAGS= -Wall -Wextra -Wno-deprecated-declarations -Werror $(shell $(PKGCONF) --cflags libdpdk)
 
 KERNPREINCLUDES:= ${INCLUDES}
 INCLUDES= -I${OVERRIDE_INCLUDES_ROOT} ${KERNPREINCLUDES}
index 0262a1f03befabf8155b1a00e4d121ddc20aad11..077c8103c68d320a21d28c48bb864477a9a39a62 100644 (file)
@@ -71,7 +71,7 @@ static int
 parse_lcore_mask(struct ff_config *cfg, const char *coremask)
 {
     int i, j, idx = 0, shift = 0, zero_num = 0;
-    unsigned count = 0;
+    int count = 0;
     char c;
     int val;
     uint16_t *proc_lcore;
@@ -121,7 +121,7 @@ parse_lcore_mask(struct ff_config *cfg, const char *coremask)
                     snprintf(buf, sizeof(buf) - 1, "%llx%s",
                         (unsigned long long)1<<shift, zero);
                     cfg->dpdk.proc_mask = strdup(buf);
-               }
+        }
                 count++;
             }
         }
@@ -857,7 +857,7 @@ bond_cfg_handler(struct ff_config *cfg, const char *section,
 }
 
 static int
-rss_tbl_cfg_handler(struct ff_config *cfg, struct ff_rss_check_cfg *cur)
+rss_tbl_cfg_handler(struct ff_rss_check_cfg *cur)
 {
     //vip cfg
     int ret, nb_rss_tbl, i, j, k;
@@ -900,7 +900,7 @@ rss_tbl_cfg_handler(struct ff_config *cfg, struct ff_rss_check_cfg *cur)
 }
 
 static int
-rss_check_cfg_handler(struct ff_config *cfg, const char *section,
+rss_check_cfg_handler(struct ff_config *cfg, __rte_unused const char *section,
     const char *name, const char *value)
 {
     if (cfg->dpdk.port_cfgs == NULL && cfg->dpdk.vlan_cfgs == NULL) {
@@ -924,7 +924,7 @@ rss_check_cfg_handler(struct ff_config *cfg, const char *section,
     } else if (strcmp(name, "rss_tbl") == 0) {
         cur->rss_tbl_str = strdup(value);
         if (cur->rss_tbl_str) {
-            return rss_tbl_cfg_handler(cfg, cur);
+            return rss_tbl_cfg_handler(cur);
         }
     }
 
index 5d5816463ea33c1917c0d82fa1d078fba7fcf28d..f7a5469011a50835517ba6b0d48c22d8095cd561 100644 (file)
@@ -241,7 +241,7 @@ struct ff_rss_tbl_cfg {
 
 struct ff_rss_check_cfg {
     int enable;
-    uint32_t nb_rss_tbl;
+    int nb_rss_tbl;
     char *rss_tbl_str;
     struct ff_rss_tbl_cfg rss_tbl_cfgs[FF_RSS_TBL_MAX_ENTRIES];
 };
index 7b334b2452b5a5696047f94c431d0aff3869fd01..8fef961597fab3c507a1d908ca0430218b0dc85d 100644 (file)
@@ -572,7 +572,7 @@ set_rss_table(uint16_t port_id, uint16_t reta_size, uint16_t nb_queues)
         return;
     }
 
-    int reta_conf_size = RTE_MAX(1, reta_size / RTE_ETH_RETA_GROUP_SIZE);
+    unsigned reta_conf_size = RTE_MAX(1, reta_size / RTE_ETH_RETA_GROUP_SIZE);
     struct rte_eth_rss_reta_entry64 reta_conf[reta_conf_size];
 
     /* config HW indirection table */
@@ -2249,9 +2249,9 @@ main_loop(void *arg)
 
                 ff_get_current_time(&sec, &nsec);
                 if (sec > last_sec) {
-                    if (kni_rate_limt.gerneal_packets > ff_global_cfg.kni.general_packets_ratelimit ||
-                        kni_rate_limt.console_packets > ff_global_cfg.kni.console_packets_ratelimit ||
-                        kni_rate_limt.kernel_packets > ff_global_cfg.kni.kernel_packets_ratelimit) {
+                    if (kni_rate_limt.gerneal_packets > (uint64_t)ff_global_cfg.kni.general_packets_ratelimit ||
+                        kni_rate_limt.console_packets > (uint64_t)ff_global_cfg.kni.console_packets_ratelimit ||
+                        kni_rate_limt.kernel_packets > (uint64_t)ff_global_cfg.kni.kernel_packets_ratelimit) {
                         printf("kni ratelimit, general:%lu/%d, console:%lu/%d, kernel:%lu/%d, last sec:%ld, sec:%ld\n",
                             kni_rate_limt.gerneal_packets, ff_global_cfg.kni.general_packets_ratelimit,
                             kni_rate_limt.console_packets, ff_global_cfg.kni.console_packets_ratelimit,
index 1ff92607831604e96a1e1c393b2f6fba7cd346f0..eb9ee3a63c03f3dd6a5e5a17ab2f0b5dd94e7c27 100644 (file)
@@ -143,7 +143,7 @@ kni_set_bitmap(const char *p, unsigned char *port_bitmap)
 #ifdef FF_KNI_KNI
 /* Currently we don't support change mtu. */
 static int
-kni_change_mtu(uint16_t port_id, unsigned new_mtu)
+kni_change_mtu(__rte_unused uint16_t port_id, __rte_unused unsigned new_mtu)
 {
     return 0;
 }
@@ -213,7 +213,7 @@ kni_config_mac_address(uint16_t port_id, uint8_t mac_addr[])
 #endif
 
 static int
-kni_process_tx(uint16_t port_id, uint16_t queue_id,
+kni_process_tx(uint16_t port_id, __rte_unused uint16_t queue_id,
     struct rte_mbuf **pkts_burst, unsigned count)
 {
     /* read packet from kni ring(phy port) and transmit to kni */
@@ -225,7 +225,7 @@ kni_process_tx(uint16_t port_id, uint16_t queue_id,
      * If there are too many processes, there is also the possibility that the control packet will be ratelimited.
      */
     if (ff_global_cfg.kni.kernel_packets_ratelimit) {
-        if (likely(kni_rate_limt.kernel_packets < ff_global_cfg.kni.kernel_packets_ratelimit)) {
+        if (likely(kni_rate_limt.kernel_packets < (uint64_t)ff_global_cfg.kni.kernel_packets_ratelimit)) {
             nb_to_tx = nb_tx;
         } else {
             nb_to_tx = 0;
@@ -526,8 +526,8 @@ ff_kni_init(uint16_t nb_ports, int type, const char *tcp_ports, const char *udp_
 }
 
 void
-ff_kni_alloc(uint16_t port_id, unsigned socket_id, int type, int port_idx,
-    struct rte_mempool *mbuf_pool, unsigned ring_queue_size)
+ff_kni_alloc(uint16_t port_id, unsigned socket_id, __rte_unused int type, int port_idx,
+    __rte_unused struct rte_mempool *mbuf_pool, unsigned ring_queue_size)
 {
     if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
         struct rte_ether_addr addr = {{0}};
@@ -644,14 +644,14 @@ ff_kni_enqueue(enum FilterReturn filter, uint16_t port_id, struct rte_mbuf *pkt)
     if (filter >= FILTER_ARP) {
         if (ff_global_cfg.kni.console_packets_ratelimit) {
             kni_rate_limt.console_packets++;
-            if (kni_rate_limt.console_packets > ff_global_cfg.kni.console_packets_ratelimit) {
+            if (kni_rate_limt.console_packets > (uint64_t)ff_global_cfg.kni.console_packets_ratelimit) {
                 goto error;
             }
         }
     } else {
         if (ff_global_cfg.kni.general_packets_ratelimit) {
             kni_rate_limt.gerneal_packets++;
-            if (kni_rate_limt.gerneal_packets > ff_global_cfg.kni.general_packets_ratelimit) {
+            if (kni_rate_limt.gerneal_packets > (uint64_t)ff_global_cfg.kni.general_packets_ratelimit) {
                 goto error;
             }
         }
index 42fdff1aa1c8a6d87c84d26210f9aaab48c080eb..13a3c9138771dea70f90e5fdf5351853db2c15cd 100644 (file)
@@ -103,7 +103,7 @@ ff_epoll_ctl(int epfd, int op, int fd, struct epoll_event *event)
     return ff_kevent(epfd, kev, changes, NULL, 0, NULL);
 }
 
-static void 
+static void
 ff_event_to_epoll(void **ev, struct kevent *kev)
 {
     unsigned int event_one = 0;
@@ -144,10 +144,11 @@ ff_event_to_epoll(void **ev, struct kevent *kev)
     (*ppev)++;
 }
 
-int 
+int
 ff_epoll_wait(int epfd, struct epoll_event *events, int maxevents, int timeout)
 {
     int i, ret;
+    (void)timeout;
     if (!events || maxevents < 1) {
         errno = EINVAL;
         return -1;
index b2de9437769d590a0815e225e58a2ef2e664c1e7..83537aa07e71e03f4d491930174275d4ff20fed4 100644 (file)
@@ -76,7 +76,7 @@ ff_mmap(void *addr, uint64_t len, int prot, int flags, int fd, uint64_t offset)
 
     void *ret = (mmap(addr, len, host_prot, host_flags, fd, offset));
 
-    if ((uint64_t)ret == -1) {
+    if (ret == MAP_FAILED) {
         printf("fst mmap failed:%s\n", strerror(errno));
         exit(1);
     }
@@ -271,10 +271,10 @@ void ff_os_errno(int error)
         case ff_EPIPE:       errno = EPIPE; break;
         case ff_EDOM:        errno = EDOM; break;
         case ff_ERANGE:      errno = ERANGE; break;
-    
+
         /* case ff_EAGAIN:       same as EWOULDBLOCK */
         case ff_EWOULDBLOCK:     errno = EWOULDBLOCK; break;
-    
+
         case ff_EINPROGRESS:     errno = EINPROGRESS; break;
         case ff_EALREADY:        errno = EALREADY; break;
         case ff_ENOTSOCK:        errno = ENOTSOCK; break;