Skip to contentSkip to conversation

iptables: extension: Constify option struct

PATCH Superseded Arushi Singhal 1 participant 2 messages Mar 21, 2018

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iptables: extension: Constify option struct

The struct of type option is only used to initialise a field and is not modified anywhere.

---
 extensions/libarpt_mangle.c | 2 +-
 iptables/iptables-xml.c     | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
extensions/libarpt_mangle.c +1 -1
index ec9b543..0d1f140 100644
@@ -32,7 +32,7 @@ static void arpmangle_print_help(void)
 #define MANGLE_DEVT   '4'
 #define MANGLE_TARGET '5'
 
-static struct option arpmangle_opts[] = {
+static const struct option arpmangle_opts[] = {
 	{ .name = "mangle-ip-s",	.has_arg = true, .val = MANGLE_IPS },
 	{ .name = "mangle-ip-d",	.has_arg = true, .val = MANGLE_IPT },
 	{ .name = "mangle-mac-s",	.has_arg = true, .val = MANGLE_DEVS },
iptables/iptables-xml.c +1 -1
index 49674ec..69c19a6 100644
@@ -38,7 +38,7 @@ static int verbose;
 /* Whether to combine actions of sequential rules with identical conditions */
 static int combine;
 /* Keeping track of external matches and targets.  */
-static struct option options[] = {
+static const struct option options[] = {
 	{"verbose", 0, NULL, 'v'},
 	{"combine", 0, NULL, 'c'},
 	{"help", 0, NULL, 'h'},
Signature · 1 line
2.7.4
#1 lore raw
Quoted 40 lines · Arushi Singhal

The struct of type option is only used to initialise a field and is not modified anywhere.

---
 extensions/libarpt_mangle.c | 2 +-
 iptables/iptables-xml.c     | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
extensions/libarpt_mangle.c +1 -1
index ec9b543..0d1f140 100644
@@ -32,7 +32,7 @@ static void arpmangle_print_help(void)
 #define MANGLE_DEVT   '4'
 #define MANGLE_TARGET '5'
 
-static struct option arpmangle_opts[] = {
+static const struct option arpmangle_opts[] = {
        { .name = "mangle-ip-s",        .has_arg = true, .val = MANGLE_IPS
 },
        { .name = "mangle-ip-d",        .has_arg = true, .val = MANGLE_IPT

},

        { .name = "mangle-mac-s",       .has_arg = true, .val =

MANGLE_DEVS },

iptables/iptables-xml.c +0 -0
index 49674ec..69c19a6 100644
@@ -38,7 +38,7 @@ static int verbose;
 /* Whether to combine actions of sequential rules with identical

conditions */
static int combine;
/* Keeping track of external matches and targets. */

iptables/iptables-xml.c +1 -2
-static struct option options[] = {
+static const struct option options[] = {
        {"verbose", 0, NULL, 'v'},
        {"combine", 0, NULL, 'c'},
        {"help", 0, NULL, 'h'},
--
Quoted 3 lines

2.7.4

Please ignore this patch.