* [PATCH 0/4] Constify option structures
@ 2017-03-27 18:45 Gargi Sharma
2017-03-27 18:45 ` [PATCH 1/4] extensions: libebt_limit: Constify option struct Gargi Sharma
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Gargi Sharma @ 2017-03-27 18:45 UTC (permalink / raw)
To: netfilter-devel; +Cc: pablo, outreachy-kernel, Gargi Sharma
The struct option is generally used only to initialise
fields inside certain structs 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[] = { ... };
Gargi Sharma (4):
extensions: libebt_limit: Constify option struct
extenstions: libebt_mark_m: Constify option struct
extensions: libebt_mark: Constify option struct
extensions: libebt_nflog: Constify option struct
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(-)
--
2.7.4
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/4] extensions: libebt_limit: Constify option struct
2017-03-27 18:45 [PATCH 0/4] Constify option structures Gargi Sharma
@ 2017-03-27 18:45 ` Gargi Sharma
2017-03-27 18:45 ` [PATCH 2/4] extenstions: libebt_mark_m: " Gargi Sharma
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Gargi Sharma @ 2017-03-27 18:45 UTC (permalink / raw)
To: netfilter-devel; +Cc: pablo, outreachy-kernel, Gargi Sharma
The struct brlimit_opts of the type option is only used to
initialise a field inside the xtables_match struct and is
not modified anywhere.
Signed-off-by: Gargi Sharma <gs051095@gmail.com>
---
extensions/libebt_limit.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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 },
--
2.7.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/4] extenstions: libebt_mark_m: Constify option struct
2017-03-27 18:45 [PATCH 0/4] Constify option structures Gargi Sharma
2017-03-27 18:45 ` [PATCH 1/4] extensions: libebt_limit: Constify option struct Gargi Sharma
@ 2017-03-27 18:45 ` Gargi Sharma
2017-03-27 18:45 ` [PATCH 3/4] extensions: libebt_mark: " Gargi Sharma
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Gargi Sharma @ 2017-03-27 18:45 UTC (permalink / raw)
To: netfilter-devel; +Cc: pablo, outreachy-kernel, Gargi Sharma
The struct brmark_m_opts of the type option is only
used to initialise extra_opts field inside the xtables_match
struct and is not modified anywhere.
Signed-off-by: Gargi Sharma <gs051095@gmail.com>
---
extensions/libebt_mark_m.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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,
};
--
2.7.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/4] extensions: libebt_mark: Constify option struct
2017-03-27 18:45 [PATCH 0/4] Constify option structures Gargi Sharma
2017-03-27 18:45 ` [PATCH 1/4] extensions: libebt_limit: Constify option struct Gargi Sharma
2017-03-27 18:45 ` [PATCH 2/4] extenstions: libebt_mark_m: " Gargi Sharma
@ 2017-03-27 18:45 ` Gargi Sharma
2017-03-27 18:45 ` [PATCH 4/4] extensions: libebt_nflog: " Gargi Sharma
2017-03-27 18:49 ` [Outreachy kernel] [PATCH 0/4] Constify option structures Pablo Neira Ayuso
4 siblings, 0 replies; 6+ messages in thread
From: Gargi Sharma @ 2017-03-27 18:45 UTC (permalink / raw)
To: netfilter-devel; +Cc: pablo, outreachy-kernel, Gargi Sharma
The struct brmark_opts of the type option is only
used to initialise the extra_opts field in xtables_target
struct and is no modified anywhere.
Signed-off-by: Gargi Sharma <gs051095@gmail.com>
---
extensions/libebt_mark.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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> */
--
2.7.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 4/4] extensions: libebt_nflog: Constify option struct
2017-03-27 18:45 [PATCH 0/4] Constify option structures Gargi Sharma
` (2 preceding siblings ...)
2017-03-27 18:45 ` [PATCH 3/4] extensions: libebt_mark: " Gargi Sharma
@ 2017-03-27 18:45 ` Gargi Sharma
2017-03-27 18:49 ` [Outreachy kernel] [PATCH 0/4] Constify option structures Pablo Neira Ayuso
4 siblings, 0 replies; 6+ messages in thread
From: Gargi Sharma @ 2017-03-27 18:45 UTC (permalink / raw)
To: netfilter-devel; +Cc: pablo, outreachy-kernel, Gargi Sharma
The struct brnflog_opts of the type options is
used to initialise extra_opts field inside the
xtables_target struct and is not modified anywhere.
Signed-off-by: Gargi Sharma <gs051095@gmail.com>
---
extensions/libebt_nflog.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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] 6+ messages in thread
* Re: [Outreachy kernel] [PATCH 0/4] Constify option structures
2017-03-27 18:45 [PATCH 0/4] Constify option structures Gargi Sharma
` (3 preceding siblings ...)
2017-03-27 18:45 ` [PATCH 4/4] extensions: libebt_nflog: " Gargi Sharma
@ 2017-03-27 18:49 ` Pablo Neira Ayuso
4 siblings, 0 replies; 6+ messages in thread
From: Pablo Neira Ayuso @ 2017-03-27 18:49 UTC (permalink / raw)
To: Gargi Sharma; +Cc: netfilter-devel, pablo, outreachy-kernel
On Tue, Mar 28, 2017 at 12:15:26AM +0530, Gargi Sharma wrote:
> The struct option is generally used only to initialise
> fields inside certain structs 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[] = { ... };
Please indicate what userspace tree in the subject, I guess this is
iptables.
And merge them all into one single patch, they are part of the same
logical change.
Thanks!
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-03-27 18:50 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-27 18:45 [PATCH 0/4] Constify option structures Gargi Sharma
2017-03-27 18:45 ` [PATCH 1/4] extensions: libebt_limit: Constify option struct Gargi Sharma
2017-03-27 18:45 ` [PATCH 2/4] extenstions: libebt_mark_m: " Gargi Sharma
2017-03-27 18:45 ` [PATCH 3/4] extensions: libebt_mark: " Gargi Sharma
2017-03-27 18:45 ` [PATCH 4/4] extensions: libebt_nflog: " Gargi Sharma
2017-03-27 18:49 ` [Outreachy kernel] [PATCH 0/4] Constify option structures 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).