]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
iptables: Constify option struct
authorHarsha Sharma <harshasharmaiitr@gmail.com>
Wed, 27 Sep 2017 11:44:52 +0000 (17:14 +0530)
committerPablo Neira Ayuso <pablo@netfilter.org>
Wed, 4 Oct 2017 13:54:00 +0000 (15:54 +0200)
The struct of type option is only used to initialise a field inside
the xtables_globals struct and is not modified anywhere.
Done using following coccinelle semantic patch

@r1 disable optional_qualifier@
identifier s,i;
position p;
@@

static struct option i@p[] ={...};

@ok1@
identifier r1.i;
expression e;
position p;
@@
e = i@p

@bad@
position p != {r1.p,ok1.p};
identifier r1.i;
@@
e@i@p

@depends on !bad disable optional_qualifier@
identifier r1.i;
@@
static
+const
struct option i[] = { ... };

Signed-off-by: Harsha Sharma <harshasharmaiitr@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
iptables/ip6tables.c
iptables/iptables.c
iptables/xtables-eb.c
iptables/xtables.c

index 49bd006fb22f67577658fa850f5597d19566a08a..0f6fa31aefd506a77f81b719a922e4d6a2c8b176 100644 (file)
@@ -78,7 +78,7 @@ static const char optflags[]
 
 static const char unsupported_rev[] = " [unsupported revision]";
 
-static struct option original_opts[] = {
+static const struct option original_opts[] = {
        {.name = "append",        .has_arg = 1, .val = 'A'},
        {.name = "delete",        .has_arg = 1, .val = 'D'},
        {.name = "check" ,        .has_arg = 1, .val = 'C'},
index 69d19feca1c22a89d551b29247199d890466e82a..e930fe2677489ace695b77c5ebd330f01c5bef31 100644 (file)
@@ -75,7 +75,7 @@ static const char optflags[]
 
 static const char unsupported_rev[] = " [unsupported revision]";
 
-static struct option original_opts[] = {
+static const struct option original_opts[] = {
        {.name = "append",        .has_arg = 1, .val = 'A'},
        {.name = "delete",        .has_arg = 1, .val = 'D'},
        {.name = "check",         .has_arg = 1, .val = 'C'},
index c8b5d4f3f4f83034b49bed5a048c7a279204965a..60ec935cfdd3c674c39d5cf285186a25ff5f004e 100644 (file)
@@ -247,7 +247,7 @@ static int get_current_chain(const char *chain)
 
 /* Default command line options. Do not mess around with the already
  * assigned numbers unless you know what you are doing */
-static struct option ebt_original_options[] =
+static const struct option ebt_original_options[] =
 {
        { "append"         , required_argument, 0, 'A' },
        { "insert"         , required_argument, 0, 'I' },
index ac1132541dddafc1b2c6387d703a288b142ea39d..aebe7d77acf75cd554ebd2e8dba216e413fcb8bc 100644 (file)
@@ -59,7 +59,7 @@ static const char cmdflags[] = { 'I', 'D', 'D', 'R', 'A', 'L', 'F', 'Z',
 static const char optflags[]
 = { 'n', 's', 'd', 'p', 'j', 'v', 'x', 'i', 'o', '0', 'c', 'f'};
 
-static struct option original_opts[] = {
+static const struct option original_opts[] = {
        {.name = "append",        .has_arg = 1, .val = 'A'},
        {.name = "delete",        .has_arg = 1, .val = 'D'},
        {.name = "check",         .has_arg = 1, .val = 'C'},