Skip to contentSkip to conversation

kernel: pid_namespace: Constify ctl_path structure

PATCH New Gargi Sharma 1 participant 1 message Mar 26, 2017 Namespaces:

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 kernel: pid_namespace: Constify ctl_path structure

The struct kern_path of the type ctl_path is used as an input to the function register_sysctl_paths which registers a sysctl hierarchy. ctl_path is simply the path to the directory the sysctl table is in and is not modified anywhere.

Done using Coccinelle:
@r1 disable optional_qualifier@
identifier s,i;
position p;
@@

static struct ctl_path 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 ctl_path i[] = { ... };

Size before constification:

text data bss dec hex filename
5462 1698 192 7352 1cb8 kernel/pid_namespace.o

Size after constification:

text data bss dec hex filename
5526 1634 192 7352 1cb8 kernel/pid_namespace.o

---
Changes in v2:
- Add size after and before to the object file numbers.

---
 kernel/pid_namespace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/pid_namespace.c +1 -1
index 071ebd3..f8a5a0c 100644
@@ -323,7 +323,7 @@ static struct ctl_table pid_ns_ctl_table[] = {
 	},
 	{ }
 };
-static struct ctl_path kern_path[] = { { .procname = "kernel", }, { } };
+static const struct ctl_path kern_path[] = { { .procname = "kernel", }, { } };
 #endif	/* CONFIG_CHECKPOINT_RESTORE */
 
 int reboot_pid_ns(struct pid_namespace *pid_ns, int cmd)
Signature · 1 line
2.7.4