Thread (2 messages) 2 messages, 2 authors, 2022-02-24

RE: [PATCH v2] fs/proc: Optimize arrays defined by struct ctl_path

From: David Laight <hidden>
Date: 2022-02-24 11:05:44
Also in: linux-fscrypt, linux-fsdevel, lkml

From: Meng Tang <redacted>
Sent: 24 February 2022 10:53

Previously, arrays defined by struct ctl_path is terminated
with an empty one. For example, when we actually only register
one ctl_path, we've gone from 8 bytes to 16 bytes.
...
quoted hunk ↗ jump to hunk
diff --git a/arch/csky/abiv1/alignment.c b/arch/csky/abiv1/alignment.c
index 2df115d0e210..b9290a252d84 100644
--- a/arch/csky/abiv1/alignment.c
+++ b/arch/csky/abiv1/alignment.c
@@ -340,14 +340,14 @@ static struct ctl_table sysctl_table[2] = {
 	{}
 };

-static struct ctl_path sysctl_path[2] = {
-	{.procname = "csky"},
-	{}
+static struct ctl_path sysctl_path[1] = {
+	{.procname = "csky"}
 };
+#define SYSCTL_PATH_NUM ARRAY_SIZE(sysctl_path)

 static int __init csky_alignment_init(void)
 {
-	 (sysctl_path, sysctl_table);
+	register_sysctl_paths(sysctl_path, SYSCTL_PATH_NUM, sysctl_table);
 	return 0;
 }
That is horribly error prone.
What might work is to add the ctl_path_num parameter but leave in the
check for NULL.
Then add:

#define register_sysctl_paths(p, t) register_sysctl_paths(p, ARRAY_SIZE(t), t)

in the header file after the prototype.
Put the function name in () in the definition to stop the macro expansion.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help