* [PATCH] iptables: Constify option struct
@ 2017-03-27 19:10 Gargi Sharma
2017-03-27 19:12 ` Pablo Neira Ayuso
0 siblings, 1 reply; 7+ messages in thread
From: Gargi Sharma @ 2017-03-27 19:10 UTC (permalink / raw)
To: netfilter-devel; +Cc: pablo, outreachy-kernel, Gargi Sharma
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>
---
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(-)
diff --git a/extensions/libebt_limit.c b/extensions/libebt_limit.c
index 6b9bb16..988f678 100644
--- a/extensions/libebt_limit.c
+++ b/extensions/libebt_limit.c
@@ -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 },
diff --git a/extensions/libebt_mark.c b/extensions/libebt_mark.c
index a1a208c..7b80b22 100644
--- a/extensions/libebt_mark.c
+++ b/extensions/libebt_mark.c
@@ -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> */
diff --git a/extensions/libebt_mark_m.c b/extensions/libebt_mark_m.c
index ab9d234..eb08dba 100644
--- a/extensions/libebt_mark_m.c
+++ b/extensions/libebt_mark_m.c
@@ -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,
};
diff --git a/extensions/libebt_nflog.c b/extensions/libebt_nflog.c
index fef7196..5f1d13b 100644
--- a/extensions/libebt_nflog.c
+++ b/extensions/libebt_nflog.c
@@ -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},
--
2.7.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] iptables: Constify option struct
2017-03-27 19:10 [PATCH] iptables: Constify option struct Gargi Sharma
@ 2017-03-27 19:12 ` Pablo Neira Ayuso
2017-03-27 19:15 ` [Outreachy kernel] " Gargi Sharma
0 siblings, 1 reply; 7+ messages in thread
From: Pablo Neira Ayuso @ 2017-03-27 19:12 UTC (permalink / raw)
To: Gargi Sharma; +Cc: netfilter-devel, outreachy-kernel
On Tue, Mar 28, 2017 at 12:40:15AM +0530, Gargi Sharma wrote:
> 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[] = { ... };
Applied, thanks.
You can probably have a look at ebtables.git, probably there are more
things to constify there.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Outreachy kernel] Re: [PATCH] iptables: Constify option struct
2017-03-27 19:12 ` Pablo Neira Ayuso
@ 2017-03-27 19:15 ` Gargi Sharma
2017-03-27 19:57 ` Gargi Sharma
0 siblings, 1 reply; 7+ messages in thread
From: Gargi Sharma @ 2017-03-27 19:15 UTC (permalink / raw)
To: Pablo Neira Ayuso; +Cc: netfilter-devel, outreachy-kernel
On Tue, Mar 28, 2017 at 12:42 AM, Pablo Neira Ayuso <pablo@netfilter.org> wrote:
>
> On Tue, Mar 28, 2017 at 12:40:15AM +0530, Gargi Sharma wrote:
> > 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[] = { ... };
>
> Applied, thanks.
>
> You can probably have a look at ebtables.git, probably there are more
> things to constify there.
>
Okay, I will. :)
Thanks!
Gargi
> --
> 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 outreachy-kernel+unsubscribe@googlegroups.com.
> To post to this group, send email to outreachy-kernel@googlegroups.com.
> 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.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Outreachy kernel] Re: [PATCH] iptables: Constify option struct
2017-03-27 19:15 ` [Outreachy kernel] " Gargi Sharma
@ 2017-03-27 19:57 ` Gargi Sharma
2017-03-27 21:37 ` Julia Lawall
0 siblings, 1 reply; 7+ messages in thread
From: Gargi Sharma @ 2017-03-27 19:57 UTC (permalink / raw)
To: Pablo Neira Ayuso; +Cc: netfilter-devel, outreachy-kernel
On Tue, Mar 28, 2017 at 12:45 AM, Gargi Sharma <gs051095@gmail.com> wrote:
> On Tue, Mar 28, 2017 at 12:42 AM, Pablo Neira Ayuso <pablo@netfilter.org> wrote:
>>
>> On Tue, Mar 28, 2017 at 12:40:15AM +0530, Gargi Sharma wrote:
>> > 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[] = { ... };
>>
>> 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
>>
> Okay, I will. :)
>
> Thanks!
> Gargi
>> --
>> 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 outreachy-kernel+unsubscribe@googlegroups.com.
>> To post to this group, send email to outreachy-kernel@googlegroups.com.
>> 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.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Outreachy kernel] Re: [PATCH] iptables: Constify option struct
2017-03-27 19:57 ` Gargi Sharma
@ 2017-03-27 21:37 ` Julia Lawall
0 siblings, 0 replies; 7+ messages in thread
From: Julia Lawall @ 2017-03-27 21:37 UTC (permalink / raw)
To: Gargi Sharma; +Cc: Pablo Neira Ayuso, netfilter-devel, outreachy-kernel
On Tue, 28 Mar 2017, Gargi Sharma wrote:
> On Tue, Mar 28, 2017 at 12:45 AM, Gargi Sharma <gs051095@gmail.com> wrote:
> > On Tue, Mar 28, 2017 at 12:42 AM, Pablo Neira Ayuso <pablo@netfilter.org> wrote:
> >>
> >> On Tue, Mar 28, 2017 at 12:40:15AM +0530, Gargi Sharma wrote:
> >> > 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[] = { ... };
> >>
> >> 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)?
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
>
> Thanks!
> Gargi
> >>
> > Okay, I will. :)
> >
> > Thanks!
> > Gargi
> >> --
> >> 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 outreachy-kernel+unsubscribe@googlegroups.com.
> >> To post to this group, send email to outreachy-kernel@googlegroups.com.
> >> 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 outreachy-kernel+unsubscribe@googlegroups.com.
> To post to this group, send email to outreachy-kernel@googlegroups.com.
> 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.
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] iptables: Constify option struct
@ 2017-09-27 11:44 Harsha Sharma
2017-10-04 14:08 ` Pablo Neira Ayuso
0 siblings, 1 reply; 7+ messages in thread
From: Harsha Sharma @ 2017-09-27 11:44 UTC (permalink / raw)
To: pablo; +Cc: netfilter-devel, linux-kernel, outreachy-kernel, Harsha Sharma
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>
---
iptables/ip6tables.c | 2 +-
iptables/iptables.c | 2 +-
iptables/xtables-eb.c | 2 +-
iptables/xtables.c | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/iptables/ip6tables.c b/iptables/ip6tables.c
index 49bd006..0f6fa31 100644
--- a/iptables/ip6tables.c
+++ b/iptables/ip6tables.c
@@ -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'},
diff --git a/iptables/iptables.c b/iptables/iptables.c
index 69d19fe..e930fe2 100644
--- a/iptables/iptables.c
+++ b/iptables/iptables.c
@@ -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'},
diff --git a/iptables/xtables-eb.c b/iptables/xtables-eb.c
index c8b5d4f..60ec935 100644
--- a/iptables/xtables-eb.c
+++ b/iptables/xtables-eb.c
@@ -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' },
diff --git a/iptables/xtables.c b/iptables/xtables.c
index ac11325..aebe7d7 100644
--- a/iptables/xtables.c
+++ b/iptables/xtables.c
@@ -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'},
--
1.9.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2017-10-04 14:08 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-27 19:10 [PATCH] iptables: Constify option struct Gargi Sharma
2017-03-27 19:12 ` Pablo Neira Ayuso
2017-03-27 19:15 ` [Outreachy kernel] " Gargi Sharma
2017-03-27 19:57 ` Gargi Sharma
2017-03-27 21:37 ` Julia Lawall
-- strict thread matches above, loose matches on Subject: below --
2017-09-27 11:44 Harsha Sharma
2017-10-04 14:08 ` Pablo Neira Ayuso
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).