From 2f86385ff56c4e204133dfeef9e0ec1cada6ba56 Mon Sep 17 00:00:00 2001 From: Christian Marangi Date: Sun, 14 May 2023 15:56:08 +0200 Subject: [PATCH] libpfring: fix compilation warning Fix simple compilation warning with checking statically allocated variables and missing fallthrough. Fix compilation warning: /home/ansuel/openwrt-ansuel/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-ipq807x_generic/PF_RING-8.0.0/kernel/pf_ring.c: In function 'ring_release': /home/ansuel/openwrt-ansuel/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-ipq807x_generic/PF_RING-8.0.0/kernel/pf_ring.c:5489:6: error: the comparison will always evaluate as 'true' for the address of 'name' will never be NULL [-Werror=address] 5489 | && pfr->zc_device_entry->zc_dev.dev->name) { | ^~ In file included from ./include/linux/rtnetlink.h:7, from /home/ansuel/openwrt-ansuel/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-ipq807x_generic/PF_RING-8.0.0/kernel/pf_ring.c:84: ./include/linux/netdevice.h:1986:33: note: 'name' declared here 1986 | char name[IFNAMSIZ]; | ^~~~ /home/ansuel/openwrt-ansuel/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-ipq807x_generic/PF_RING-8.0.0/kernel/pf_ring.c: In function 'ring_bind': /home/ansuel/openwrt-ansuel/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-ipq807x_generic/PF_RING-8.0.0/kernel/pf_ring.c:5620:18: error: the comparison will always evaluate as 'false' for the address of 'sa_data' will never be NULL [-Werror=address] 5620 | if(sa->sa_data == NULL) | ^~ In file included from /home/ansuel/openwrt-ansuel/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-ipq807x_generic/PF_RING-8.0.0/kernel/pf_ring.c:82: ./include/linux/socket.h:34:25: note: 'sa_data' declared here 34 | char sa_data[14]; /* 14 bytes of protocol address */ | ^~~~~~~ /home/ansuel/openwrt-ansuel/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-ipq807x_generic/PF_RING-8.0.0/kernel/pf_ring.c: In function 'hash_pkt_cluster': /home/ansuel/openwrt-ansuel/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-ipq807x_generic/PF_RING-8.0.0/kernel/pf_ring.c:3937:7: error: this statement may fall through [-Werror=implicit-fallthrough=] 3937 | if(l3_proto == IPPROTO_TCP) | ^ /home/ansuel/openwrt-ansuel/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-ipq807x_generic/PF_RING-8.0.0/kernel/pf_ring.c:3944:3: note: here 3944 | case cluster_per_flow_2_tuple: | ^~~~ cc1: all warnings being treated as errors Signed-off-by: Christian Marangi --- .../patches/100-fix-compilation-warning.patch | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 libs/libpfring/patches/100-fix-compilation-warning.patch diff --git a/libs/libpfring/patches/100-fix-compilation-warning.patch b/libs/libpfring/patches/100-fix-compilation-warning.patch new file mode 100644 index 0000000000..18c72e734d --- /dev/null +++ b/libs/libpfring/patches/100-fix-compilation-warning.patch @@ -0,0 +1,30 @@ +--- a/kernel/pf_ring.c ++++ b/kernel/pf_ring.c +@@ -3940,7 +3940,7 @@ static int hash_pkt_cluster(ring_cluster_element *cluster_ptr, + break; + } + /* else, fall through, because it's like 2-tuple for non-TCP packets */ +- ++ fallthrough; + case cluster_per_flow_2_tuple: + case cluster_per_inner_flow_2_tuple: + flags |= mask_2_tuple; +@@ -5485,8 +5485,7 @@ static int ring_release(struct socket *sock) + remove_cluster_referee(pfr); + + if((pfr->zc_device_entry != NULL) +- && pfr->zc_device_entry->zc_dev.dev +- && pfr->zc_device_entry->zc_dev.dev->name) { ++ && pfr->zc_device_entry->zc_dev.dev) { + pfring_release_zc_dev(pfr); + } + +@@ -5617,8 +5616,6 @@ static int ring_bind(struct socket *sock, struct sockaddr *sa, int addr_len) + return(-EINVAL); + if(sa->sa_family != PF_RING) + return(-EINVAL); +- if(sa->sa_data == NULL) +- return(-EINVAL); + + memcpy(name, sa->sa_data, sizeof(sa->sa_data)); +