]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
iptables: Constify option struct
authorGargi Sharma <gs051095@gmail.com>
Mon, 27 Mar 2017 19:10:15 +0000 (00:40 +0530)
committerPablo Neira Ayuso <pablo@netfilter.org>
Mon, 27 Mar 2017 19:13:08 +0000 (21:13 +0200)
The struct  of the type option is only used to initialise a field
inside the xtables_match struct and is not modified anywhere.
Done using Coccinelle:

@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: Gargi Sharma <gs051095@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
extensions/libebt_limit.c
extensions/libebt_mark.c
extensions/libebt_mark_m.c
extensions/libebt_nflog.c

index 6b9bb16f4eda0ab26c38692705b95ade7f9d3a67..988f678a5169b88d10962df9d75c78c58cdaf49e 100644 (file)
@@ -29,7 +29,7 @@
 #define ARG_LIMIT              '1'
 #define ARG_LIMIT_BURST                '2'
 
-static struct option brlimit_opts[] =
+static const struct option brlimit_opts[] =
 {
        { .name = "limit",      .has_arg = true,        .val = ARG_LIMIT },
        { .name = "limit-burst",.has_arg = true,        .val = ARG_LIMIT_BURST },
index a1a208c3c06971cb52064498290d965d7ddab1ee..7b80b22e63c0beda39f600757f2e7871461f7498 100644 (file)
@@ -25,7 +25,7 @@ static int mark_supplied;
 #define MARK_ORMARK  '3'
 #define MARK_ANDMARK '4'
 #define MARK_XORMARK '5'
-static struct option brmark_opts[] = {
+static const struct option brmark_opts[] = {
        { .name = "mark-target",.has_arg = true,        .val = MARK_TARGET },
        /* an oldtime messup, we should have always used the scheme
         * <extension-name>-<option> */
index ab9d2344f12a4f173a47ccaab3105c3a61f7c1ed..eb08dbabbb46a9dd7935b463eaa4139c8975fc64 100644 (file)
@@ -18,7 +18,7 @@
 
 #define MARK '1'
 
-static struct option brmark_m_opts[] = {
+static const struct option brmark_m_opts[] = {
        { .name = "mark",       .has_arg = true, .val = MARK },
        XT_GETOPT_TABLEEND,
 };
index fef7196053d23532fb6df30d26647497f6f613ef..5f1d13b1251a8eb005fa6ed69e40ab91edf8cf7d 100644 (file)
@@ -30,7 +30,7 @@ enum {
        NFLOG_NFLOG     = 0x16,
 };
 
-static struct option brnflog_opts[] = {
+static const struct option brnflog_opts[] = {
        { .name = "nflog-group",     .has_arg = true,  .val = NFLOG_GROUP},
        { .name = "nflog-prefix",    .has_arg = true,  .val = NFLOG_PREFIX},
        { .name = "nflog-range",     .has_arg = true,  .val = NFLOG_RANGE},