iptables: Constify option struct
PATCH 1/1 iptables: Constify option struct
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[] = { ... };
--- extensions/libebt_limit.c | 2 +- extensions/libebt_mark.c | 2 +- extensions/libebt_mark_m.c | 2 +- extensions/libebt_nflog.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)
extensions/libebt_limit.c +1 -1
@@ -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 },
extensions/libebt_mark.c +1 -1
@@ -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> */
extensions/libebt_mark_m.c +1 -1
@@ -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 , };
extensions/libebt_nflog.c +1 -1
@@ -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 },
Signature · 1 line
2.7.4
Quoted 24 lines · Gargi Sharma
The struct of the type option is only used to initialise a field inside the
xtables_matchstruct 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
Quoted 6 lines
@depends on !bad disable optional_qualifier@
identifier r1.i;
@@
static
+const
struct option i[] = { ... };
Applied, thanks.
You can probably have a look at ebtables.git, probably there are more things to constify there.
Quoted 33 lines · Pablo Neira Ayuso
Quoted 24 lines · Gargi Sharma
The struct of the type option is only used to initialise a field inside the
xtables_matchstruct 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@pQuoted 6 lines
@depends on !bad disable optional_qualifier@
identifier r1.i;
@@
static
+const
struct option i[] = { ... };
Quoted 5 lines
Applied, thanks.
You can probably have a look at ebtables.git, probably there are more things to constify there.
Okay, I will. :)
Thanks!
Gargi
Quoted 6 lines
--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20170327191239.GA18080%40salvia.
For more options, visit https://groups.google.com/d/optout.
Quoted 34 lines · Gargi Sharma
Quoted 33 lines · Pablo Neira Ayuso
Quoted 30 lines · Gargi Sharma
The struct of the type option is only used to initialise a field inside the
xtables_matchstruct 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[] = { ... };
Quoted 4 lines
Quoted 4 lines
Applied, thanks.
You can probably have a look at ebtables.git, probably there are more things to constify there.
Hi Pablo,
There are around 18 files being affected by this semantic patch in ebtables. Should I still send them as a single patch(since it might be difficult to review a large single patch)?
Thanks!
Gargi
Quoted 11 lines
Quoted 1 line
Okay, I will. :)
Thanks!
GargiQuoted 6 lines
--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20170327191239.GA18080%40salvia.
For more options, visit https://groups.google.com/d/optout.
Quoted 37 lines · Gargi Sharma
Quoted 36 lines · Gargi Sharma
Quoted 35 lines · Pablo Neira Ayuso
Quoted 24 lines · Gargi Sharma
The struct of the type option is only used to initialise a field inside the
xtables_matchstruct 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@pQuoted 6 lines
@depends on !bad disable optional_qualifier@
identifier r1.i;
@@
static
+const
struct option i[] = { ... };Applied, thanks.
Quoted 8 lines
Quoted 2 lines
Quoted 2 lines
You can probably have a look at ebtables.git, probably there are more things to constify there.
Hi Pablo,
There are around 18 files being affected by this semantic patch in ebtables. Should I still send them as a single patch(since it might be difficult to review a large single patch)?
If they are just independent structures, you can cut up the patches if it seems best. If the changes are interdependent, then one patch would be better.
julia
Quoted 22 lines
Thanks!
GargiQuoted 11 lines
Quoted 1 line
Okay, I will. :)
Thanks!
GargiQuoted 6 lines
--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20170327191239.GA18080%40salvia.
For more options, visit https://groups.google.com/d/optout.--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/CAOCi2DFc2aURc5gAuF5q6NLvBwiVSbF6cpoF%3DipfVwntz%3D86Hg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.