This patch enables two compiler options, -Wmissing-declarations and
-Wmissing-variable-declarations, to help minimize visibility of symbols
used inside a single module, and catch other possible problems like
unused functions and variables. It also adjusts `_OVS_CHECK_CC_OPTION`
macro to work correctly with -Wmissing-variable-declarations option.

This patch also declares `impl_set_masked_funcs` array in
lib/odp-execute-avx512.c as `static`, because it isn't used anywhere
else.

Signed-off-by: Dmitry Mityugov <[email protected]>
---
 acinclude.m4             | 2 +-
 configure.ac             | 2 ++
 lib/odp-execute-avx512.c | 2 +-
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/acinclude.m4 b/acinclude.m4
index 586163ef3..599179a31 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -614,7 +614,7 @@ AC_DEFUN([_OVS_CHECK_CC_OPTION], [dnl
      dnl instead of testing for -Wno-<foo>, test for the positive version.
      CFLAGS="$CFLAGS $WERROR m4_bpatsubst([$1], [-Wno-], [-W])"
      AC_COMPILE_IFELSE(
-       [AC_LANG_SOURCE([int x;])],
+       [AC_LANG_SOURCE([static int x;])],
        [if test -s conftest.err && grep "unrecognized option" conftest.err
         then
           ovs_cv_name[]=no
diff --git a/configure.ac b/configure.ac
index 6f28360a1..56eacbbc7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -168,6 +168,8 @@ OVS_ENABLE_OPTION([-Wstrict-prototypes])
 OVS_ENABLE_OPTION([-Wold-style-definition])
 OVS_ENABLE_OPTION([-Wmissing-prototypes])
 OVS_ENABLE_OPTION([-Wmissing-field-initializers])
+OVS_ENABLE_OPTION([-Wmissing-declarations])
+OVS_ENABLE_OPTION([-Wmissing-variable-declarations])
 OVS_ENABLE_OPTION([-Wthread-safety])
 OVS_ENABLE_OPTION([-fno-strict-aliasing])
 OVS_ENABLE_OPTION([-Wswitch-bool])
diff --git a/lib/odp-execute-avx512.c b/lib/odp-execute-avx512.c
index 13afe0c79..55af58737 100644
--- a/lib/odp-execute-avx512.c
+++ b/lib/odp-execute-avx512.c
@@ -108,7 +108,7 @@ BUILD_ASSERT_DECL(offsetof(struct ovs_key_ipv6, 
ipv6_tclass) +
                   offsetof(struct ovs_key_ipv6, ipv6_hlimit));
 
 /* Array of callback functions, one for each masked operation. */
-odp_execute_action_cb impl_set_masked_funcs[__OVS_KEY_ATTR_MAX];
+static odp_execute_action_cb impl_set_masked_funcs[__OVS_KEY_ATTR_MAX];
 
 static inline void ALWAYS_INLINE
 avx512_dp_packet_resize_l2(struct dp_packet *b, int resize_by_bytes)
-- 
2.53.0

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to