netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tobias Klauser <tklauser@distanz.ch>
To: netfilter-devel@vger.kernel.org
Subject: [PATCH libnftnl] expr: Add const qualifiers to *2str translation arrays
Date: Fri, 13 Jan 2017 11:50:09 +0100	[thread overview]
Message-ID: <20170113105009.14502-1-tklauser@distanz.ch> (raw)

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>
---
 configure.ac         | 2 +-
 src/expr/byteorder.c | 2 +-
 src/expr/cmp.c       | 2 +-
 src/expr/dynset.c    | 2 +-
 src/expr/payload.c   | 2 +-
 src/expr/range.c     | 2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/configure.ac b/configure.ac
index 4777c5e26b3f..2b74e522b930 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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])
diff --git a/src/expr/byteorder.c b/src/expr/byteorder.c
index 5f8e585d91ca..38053073982c 100644
--- a/src/expr/byteorder.c
+++ b/src/expr/byteorder.c
@@ -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",
 };
diff --git a/src/expr/cmp.c b/src/expr/cmp.c
index e7ed0db5bf9a..353e907c2513 100644
--- a/src/expr/cmp.c
+++ b/src/expr/cmp.c
@@ -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",
diff --git a/src/expr/dynset.c b/src/expr/dynset.c
index 20a500449eeb..f7b99ea7e7f8 100644
--- a/src/expr/dynset.c
+++ b/src/expr/dynset.c
@@ -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",
 };
diff --git a/src/expr/payload.c b/src/expr/payload.c
index d65585711bd1..91e1587ff239 100644
--- a/src/expr/payload.c
+++ b/src/expr/payload.c
@@ -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",
diff --git a/src/expr/range.c b/src/expr/range.c
index 1489d5849451..8c8ce1213420 100644
--- a/src/expr/range.c
+++ b/src/expr/range.c
@@ -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",
 };
-- 
2.11.0



             reply	other threads:[~2017-01-13 10:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-13 10:50 Tobias Klauser [this message]
2017-01-16 10:33 ` [PATCH libnftnl] expr: Add const qualifiers to *2str translation arrays Pablo Neira Ayuso

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170113105009.14502-1-tklauser@distanz.ch \
    --to=tklauser@distanz.ch \
    --cc=netfilter-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).