]> git.ipfire.org Git - thirdparty/libnftnl.git/commitdiff
expr: Add const qualifiers to *2str translation arrays
authorTobias Klauser <tklauser@distanz.ch>
Fri, 13 Jan 2017 10:50:09 +0000 (11:50 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Mon, 16 Jan 2017 10:32:46 +0000 (11:32 +0100)
Add const qualifiers to the "to string" translation arrays used by
various *2str() functions.

This fixes GCC warnings such as the following when compiling with
-Wwrite-strings:

  expr/byteorder.c:176:25: warning: initialization discards â€˜const’ qualifier from pointer target type [-Wdiscarded-qualifiers]

In order to catch these in the future, also add -Wwrite-strings to
default CFLAGS.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
configure.ac
src/expr/byteorder.c
src/expr/cmp.c
src/expr/dynset.c
src/expr/payload.c
src/expr/range.c

index 4777c5e26b3f57d0088581c7042de33458585d55..2b74e522b93001974e4aa4e67687fec0b3c07e5a 100644 (file)
@@ -40,7 +40,7 @@ AS_IF([test "x$with_json_parsing" = "xyes"], [
 ])
 regular_CFLAGS="-Wall -Waggregate-return -Wmissing-declarations \
        -Wmissing-prototypes -Wshadow -Wstrict-prototypes \
-       -Wformat=2 -pipe"
+       -Wformat=2 -Wwrite-strings -pipe"
 AC_SUBST([regular_CPPFLAGS])
 AC_SUBST([regular_CFLAGS])
 AC_CONFIG_FILES([Makefile src/Makefile include/Makefile include/libnftnl/Makefile include/linux/Makefile include/linux/netfilter/Makefile examples/Makefile tests/Makefile libnftnl.pc doxygen.cfg])
index 5f8e585d91ca66884768e88f069413215d9c86dd..38053073982c89cbef989cc3f8db07f364588e7f 100644 (file)
@@ -172,7 +172,7 @@ nftnl_expr_byteorder_parse(struct nftnl_expr *e, struct nlattr *attr)
        return ret;
 }
 
-static char *expr_byteorder_str[] = {
+static const char *expr_byteorder_str[] = {
        [NFT_BYTEORDER_HTON] = "hton",
        [NFT_BYTEORDER_NTOH] = "ntoh",
 };
index e7ed0db5bf9abaef2338989879c7771af882516d..353e907c25139baf7db0f754e2402c2ea2cb7fe1 100644 (file)
@@ -139,7 +139,7 @@ nftnl_expr_cmp_parse(struct nftnl_expr *e, struct nlattr *attr)
        return ret;
 }
 
-static char *expr_cmp_str[] = {
+static const char *expr_cmp_str[] = {
        [NFT_CMP_EQ]    = "eq",
        [NFT_CMP_NEQ]   = "neq",
        [NFT_CMP_LT]    = "lt",
index 20a500449eebaf72aa510ee9a64e50bee8fac04a..f7b99ea7e7f87175b21394c1e1eecbfc54482b2b 100644 (file)
@@ -258,7 +258,7 @@ nftnl_expr_dynset_export(char *buf, size_t size,
        return nftnl_buf_done(&b);
 }
 
-static char *op2str_array[] = {
+static const char *op2str_array[] = {
        [NFT_DYNSET_OP_ADD]             = "add",
        [NFT_DYNSET_OP_UPDATE]          = "update",
 };
index d65585711bd19cbaf7e0f536e02d46edc01b2a8a..91e1587ff239b3236705e9125e6588f4c4a359f9 100644 (file)
@@ -203,7 +203,7 @@ nftnl_expr_payload_parse(struct nftnl_expr *e, struct nlattr *attr)
        return 0;
 }
 
-static char *base2str_array[NFT_PAYLOAD_TRANSPORT_HEADER+1] = {
+static const char *base2str_array[NFT_PAYLOAD_TRANSPORT_HEADER+1] = {
        [NFT_PAYLOAD_LL_HEADER]         = "link",
        [NFT_PAYLOAD_NETWORK_HEADER]    = "network",
        [NFT_PAYLOAD_TRANSPORT_HEADER]  = "transport",
index 1489d5849451c1d1daf62f758dc4f1ff8ae8caaf..8c8ce1213420669042f1f4440ef5b12cf7667f1f 100644 (file)
@@ -159,7 +159,7 @@ nftnl_expr_range_parse(struct nftnl_expr *e, struct nlattr *attr)
        return ret;
 }
 
-static char *expr_range_str[] = {
+static const char *expr_range_str[] = {
        [NFT_RANGE_EQ]  = "eq",
        [NFT_RANGE_NEQ] = "neq",
 };