Skip to contentSkip to conversation

kernel: pid_namespace: Constify ctl_path structure

PATCH Superseded Gargi Sharma 2 participants 3 messages Mar 26, 2017 Namespaces:

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 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[] = { ... };

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

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

---
 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
#1 lore raw
Quoted 33 lines · Gargi Sharma

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[] = { ... };

Quoted 5 lines

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

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

You should say what these numbers represent (one is the result of size before the transformation and one after).

julia

Quoted 29 lines
---
 kernel/pid_namespace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/pid_namespace.c +1 -2
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)
--

2.7.4

--
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/1490544994-32649-1-git-send-email-gs051095%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

#2 lore raw
Quoted 37 lines · Julia Lawall
Quoted 33 lines · Gargi Sharma

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[] = { ... };

Quoted 9 lines
Quoted 5 lines

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

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

You should say what these numbers represent (one is the result of size before the transformation and one after).

Oh, I missed this. Sending a v2.

Thanks!
Gargi

Quoted 25 lines

julia

Quoted 23 lines
---
 kernel/pid_namespace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/pid_namespace.c +1 -2
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)
--

2.7.4

--