]> git.ipfire.org Git - thirdparty/ipset.git/commitdiff
Handle -Werror=implicit-fallthrough= in debug mode compiling
authorJozsef Kadlecsik <kadlec@netfilter.org>
Tue, 9 Feb 2021 18:41:23 +0000 (19:41 +0100)
committerJozsef Kadlecsik <kadlec@netfilter.org>
Tue, 9 Feb 2021 18:41:23 +0000 (19:41 +0100)
Signed-off-by: Jozsef Kadlecsik <kadlec@netfilter.org>
Makefile.am
include/libipset/ip_set_compiler.h [new file with mode: 0644]
lib/ipset.c

index eab32ee92d353190f12f7f677ab3c59049da1f53..cc821e64f500f2a68cb85474c34422365b20772e 100644 (file)
@@ -93,6 +93,9 @@ update_includes:
                kernel/include/uapi/linux/netfilter/ipset/$$x \
                > include/libipset/linux_$$x; \
        done
+       for x in ip_set_compiler.h; do \
+           cp kernel/include/linux/netfilter/ipset/$$x include/libipset/$x; \
+       done
 
 update_utils:
        wget -4 -O /tmp/ipset-bash-completion.tar.gz http://sourceforge.net/projects/ipset-bashcompl/files/latest/download
diff --git a/include/libipset/ip_set_compiler.h b/include/libipset/ip_set_compiler.h
new file mode 100644 (file)
index 0000000..1b392f8
--- /dev/null
@@ -0,0 +1,15 @@
+#ifndef __IP_SET_COMPILER_H
+#define __IP_SET_COMPILER_H
+
+/* Compiler attributes */
+#ifndef __has_attribute
+# define __has_attribute(x) __GCC4_has_attribute_##x
+# define __GCC4_has_attribute___fallthrough__          0
+#endif
+
+#if __has_attribute(__fallthrough__)
+# define fallthrough                   __attribute__((__fallthrough__))
+#else
+# define fallthrough                   do {} while (0)  /* fallthrough */
+#endif
+#endif /* __IP_SET_COMPILER_H */
index 8ae2b6f3b2cc26a61036a9d3ea7ebfc8c55c2df3..672991965770798fc132ff1aeec19afe8ede92da 100644 (file)
@@ -27,6 +27,7 @@
 #include <libipset/print.h>                    /* ipset_print_family */
 #include <libipset/utils.h>                    /* STREQ */
 #include <libipset/ipset.h>                    /* prototypes */
+#include <libipset/ip_set_compiler.h>          /* compiler attributes */
 
 static char program_name[] = PACKAGE;
 static char program_version[] = PACKAGE_VERSION;
@@ -1213,6 +1214,7 @@ ipset_parse_argv(struct ipset *ipset, int oargc, char *oargv[])
                                return ret;
                }
                /* Fall through to parse optional setname */
+               fallthrough;
        case IPSET_CMD_DESTROY:
        case IPSET_CMD_FLUSH:
                /* Args: [setname] */