]> granicus.if.org Git - ipset/commitdiff
Fix build with NDEBUG defined
authorJozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Tue, 18 Jan 2011 16:48:22 +0000 (17:48 +0100)
committerJozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Tue, 18 Jan 2011 16:48:22 +0000 (17:48 +0100)
The usage of the gcc option -Wunused-parameter interferes badly with
the assert() macros.  In case -DNDEBUG is specified build fails with:

  cc1: warnings being treated as errors
  print.c: In function 'ipset_print_family':
  print.c:92: error: unused parameter 'opt'
  print.c: In function 'ipset_print_port':
  print.c:413: error: unused parameter 'opt'
  print.c: In function 'ipset_print_proto':

Fix it by taking into accout NDEBUG in the function arguments.

Bug reported by Holger Eitzenberger.

include/libipset/utils.h
lib/parse.c
lib/print.c

index c22687f3c3bd9cd38b2d134ab73376d416bcecc8..2c88a839c6208aec0d5b087686eb6c49e7c6c711 100644 (file)
 #define MAX(a, b)              (a > b ? a : b)
 
 #define UNUSED                 __attribute__ ((unused))
+#ifdef NDEBUG
+#define ASSERT_UNUSED          UNUSED
+#else
+#define ASSERT_UNUSED
+#endif
 
 #ifndef ARRAY_SIZE
 #define ARRAY_SIZE(x)          (sizeof(x) / sizeof(*(x)))
index fbc1dca74bcf6c31aafac4d41fcdf858da286916..e998df598d27052e7672ee28dd43497aca1fc30e 100644 (file)
@@ -845,7 +845,7 @@ ipset_parse_net(struct ipset_session *session,
  */
 int
 ipset_parse_range(struct ipset_session *session,
-                 enum ipset_opt opt, const char *str)
+                 enum ipset_opt opt ASSERT_UNUSED, const char *str)
 {
        assert(session);
        assert(opt == IPSET_OPT_IP || opt == IPSET_OPT_IP2);
@@ -1322,7 +1322,7 @@ ipset_parse_flag(struct ipset_session *session,
  */
 int
 ipset_parse_typename(struct ipset_session *session,
-                    enum ipset_opt opt, const char *str)
+                    enum ipset_opt opt ASSERT_UNUSED, const char *str)
 {
        const struct ipset_type *type;
        const char *typename;
index b6819e54fa198e4e7b1957c8f81e603edb5a0f97..7ec786f6b8f3528fd99d2c213385bbc56206aaaf 100644 (file)
@@ -89,7 +89,8 @@ ipset_print_ether(char *buf, unsigned int len,
  */
 int
 ipset_print_family(char *buf, unsigned int len,
-                  const struct ipset_data *data, enum ipset_opt opt,
+                  const struct ipset_data *data,
+                  enum ipset_opt opt ASSERT_UNUSED,
                   uint8_t env UNUSED)
 {
        uint8_t family;
@@ -410,7 +411,8 @@ ipset_print_name(char *buf, unsigned int len,
  */
 int
 ipset_print_port(char *buf, unsigned int len,
-                const struct ipset_data *data, enum ipset_opt opt,
+                const struct ipset_data *data,
+                enum ipset_opt opt ASSERT_UNUSED,
                 uint8_t env UNUSED)
 {
        const uint16_t *port;
@@ -454,7 +456,8 @@ ipset_print_port(char *buf, unsigned int len,
  */
 int
 ipset_print_proto(char *buf, unsigned int len,
-                 const struct ipset_data *data, enum ipset_opt opt,
+                 const struct ipset_data *data,
+                 enum ipset_opt opt ASSERT_UNUSED,
                  uint8_t env UNUSED)
 {
        const struct protoent *protoent;
@@ -490,7 +493,8 @@ ipset_print_proto(char *buf, unsigned int len,
  */
 int
 ipset_print_icmp(char *buf, unsigned int len,
-                const struct ipset_data *data, enum ipset_opt opt,
+                const struct ipset_data *data,
+                enum ipset_opt opt ASSERT_UNUSED,
                 uint8_t env UNUSED)
 {
        const char *name;
@@ -523,7 +527,8 @@ ipset_print_icmp(char *buf, unsigned int len,
  */
 int
 ipset_print_icmpv6(char *buf, unsigned int len,
-                  const struct ipset_data *data, enum ipset_opt opt,
+                  const struct ipset_data *data,
+                  enum ipset_opt opt ASSERT_UNUSED,
                   uint8_t env UNUSED)
 {
        const char *name;
@@ -556,7 +561,8 @@ ipset_print_icmpv6(char *buf, unsigned int len,
  */
 int
 ipset_print_proto_port(char *buf, unsigned int len,
-                      const struct ipset_data *data, enum ipset_opt opt,
+                      const struct ipset_data *data,
+                      enum ipset_opt opt ASSERT_UNUSED,
                       uint8_t env UNUSED)
 {
        int size, offset = 0;