]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
netfilter: constify nf_loginfo structures
authorJulia Lawall <julia.lawall@lip6.fr>
Tue, 1 Aug 2017 10:48:03 +0000 (12:48 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Wed, 2 Aug 2017 12:25:59 +0000 (14:25 +0200)
The nf_loginfo structures are only passed as the seventh argument to
nf_log_trace, which is declared as const or stored in a local const
variable.  Thus the nf_loginfo structures themselves can be const.

Done with the help of Coccinelle.

// <smpl>
@r disable optional_qualifier@
identifier i;
position p;
@@
static struct nf_loginfo i@p = { ... };

@ok1@
identifier r.i;
expression list[6] es;
position p;
@@
 nf_log_trace(es,&i@p,...)

@ok2@
identifier r.i;
const struct nf_loginfo *e;
position p;
@@
 e = &i@p

@bad@
position p != {r.p,ok1.p,ok2.p};
identifier r.i;
struct nf_loginfo e;
@@
e@i@p

@depends on !bad disable optional_qualifier@
identifier r.i;
@@
static
+const
 struct nf_loginfo i = { ... };
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/ipv4/netfilter/ip_tables.c
net/ipv4/netfilter/nf_log_arp.c
net/ipv4/netfilter/nf_log_ipv4.c
net/ipv6/netfilter/ip6_tables.c
net/ipv6/netfilter/nf_log_ipv6.c
net/netfilter/nf_tables_core.c
net/netfilter/nfnetlink_log.c

index f47e8dad5e9559a531a225064265f79c1743f22a..2aea896f57084e81176252f339940c2d30955d3e 100644 (file)
@@ -151,7 +151,7 @@ static const char *const comments[] = {
        [NF_IP_TRACE_COMMENT_POLICY]    = "policy",
 };
 
-static struct nf_loginfo trace_loginfo = {
+static const struct nf_loginfo trace_loginfo = {
        .type = NF_LOG_TYPE_LOG,
        .u = {
                .log = {
index 2f3895ddc275d2e72b2f93d816a27f41b292384a..df5c2a2061a4b1e76c2d26f4b9b44164883a4dcb 100644 (file)
@@ -25,7 +25,7 @@
 #include <linux/netfilter/xt_LOG.h>
 #include <net/netfilter/nf_log.h>
 
-static struct nf_loginfo default_loginfo = {
+static const struct nf_loginfo default_loginfo = {
        .type   = NF_LOG_TYPE_LOG,
        .u = {
                .log = {
index c83a9963269bf689d7c4285c89ef1a4228bc739b..4388de0e5380c6423fbdfe7438727900fc297d7c 100644 (file)
@@ -24,7 +24,7 @@
 #include <linux/netfilter/xt_LOG.h>
 #include <net/netfilter/nf_log.h>
 
-static struct nf_loginfo default_loginfo = {
+static const struct nf_loginfo default_loginfo = {
        .type   = NF_LOG_TYPE_LOG,
        .u = {
                .log = {
index 1f90644056ac784f1a455751796d5fa0d9441915..9f6644958e5e32f5df464a79209ea092967b9779 100644 (file)
@@ -176,7 +176,7 @@ static const char *const comments[] = {
        [NF_IP6_TRACE_COMMENT_POLICY]   = "policy",
 };
 
-static struct nf_loginfo trace_loginfo = {
+static const struct nf_loginfo trace_loginfo = {
        .type = NF_LOG_TYPE_LOG,
        .u = {
                .log = {
index 97c724224da7b2b12e4dea38c3ff6dcf218f1a3a..b397a8fe88b9391e462146391901a360969547c0 100644 (file)
@@ -25,7 +25,7 @@
 #include <linux/netfilter/xt_LOG.h>
 #include <net/netfilter/nf_log.h>
 
-static struct nf_loginfo default_loginfo = {
+static const struct nf_loginfo default_loginfo = {
        .type   = NF_LOG_TYPE_LOG,
        .u = {
                .log = {
index c5bab08b0d7349b7c4fdea32e04526d493a40d9e..dfd0bf3810d2e81690a4a2d3ac5648cb8d881090 100644 (file)
@@ -29,7 +29,7 @@ static const char *const comments[__NFT_TRACETYPE_MAX] = {
        [NFT_TRACETYPE_RULE]    = "rule",
 };
 
-static struct nf_loginfo trace_loginfo = {
+static const struct nf_loginfo trace_loginfo = {
        .type = NF_LOG_TYPE_LOG,
        .u = {
                .log = {
index c684ba95dbb49447b0ddb2a7a1f27b54536a5a03..cad6498f10b03fca0e873eb8718734b471a65f9c 100644 (file)
@@ -606,7 +606,7 @@ __build_packet_message(struct nfnl_log_net *log,
        return -1;
 }
 
-static struct nf_loginfo default_loginfo = {
+static const struct nf_loginfo default_loginfo = {
        .type =         NF_LOG_TYPE_ULOG,
        .u = {
                .ulog = {