libpfring: fix compilation warning
authorChristian Marangi <ansuelsmth@gmail.com>
Sun, 14 May 2023 13:56:08 +0000 (15:56 +0200)
committerChristian Marangi <ansuelsmth@gmail.com>
Sun, 14 May 2023 14:51:48 +0000 (16:51 +0200)
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 <ansuelsmth@gmail.com>
libs/libpfring/patches/100-fix-compilation-warning.patch [new file with mode: 0644]

diff --git a/libs/libpfring/patches/100-fix-compilation-warning.patch b/libs/libpfring/patches/100-fix-compilation-warning.patch
new file mode 100644 (file)
index 0000000..18c72e7
--- /dev/null
@@ -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));