kernel: pid_namespace: Constify ctl_path structure
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
@@ -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
Quoted 33 lines · Gargi Sharma
The struct
kern_pathof the typectl_pathis used as an input to the functionregister_sysctl_pathswhich registers a sysctl hierarchy.ctl_pathis 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_pathi@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
structctl_pathi[] = { ... };
Quoted 5 lines
text data bss dec hex filename
5462 1698 192 7352 1cb8kernel/pid_namespace.otext data bss dec hex filename
5526 1634 192 7352 1cb8kernel/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
Signed-off-by Gargi Sharma <[email protected]>--- kernel/pid_namespace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)kernel/pid_namespace.c +1
-2@@ -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.
Quoted 37 lines · Julia Lawall
Quoted 33 lines · Gargi Sharma
The struct
kern_pathof the typectl_pathis used as an input to the functionregister_sysctl_pathswhich registers a sysctl hierarchy.ctl_pathis 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_pathi@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
structctl_pathi[] = { ... };
Quoted 9 lines
Quoted 5 lines
text data bss dec hex filename
5462 1698 192 7352 1cb8kernel/pid_namespace.otext data bss dec hex filename
5526 1634 192 7352 1cb8kernel/pid_namespace.oYou 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
Signed-off-by Gargi Sharma <[email protected]>--- kernel/pid_namespace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)kernel/pid_namespace.c +1
-2@@ -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
--