[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <376fe4403af346ccbdc7294259b8d11a@AcuMS.aculab.com>
Date: Thu, 24 Feb 2022 11:05:35 +0000
From: David Laight <David.Laight@...LAB.COM>
To: 'Meng Tang' <tangmeng@...ontech.com>,
"mcgrof@...nel.org" <mcgrof@...nel.org>,
"keescook@...omium.org" <keescook@...omium.org>,
"yzaikin@...gle.com" <yzaikin@...gle.com>
CC: "guoren@...nel.org" <guoren@...nel.org>,
"nickhu@...estech.com" <nickhu@...estech.com>,
"green.hu@...il.com" <green.hu@...il.com>,
"deanbo422@...il.com" <deanbo422@...il.com>,
"ebiggers@...nel.org" <ebiggers@...nel.org>,
"tytso@....edu" <tytso@....edu>,
"wad@...omium.org" <wad@...omium.org>,
"john.johansen@...onical.com" <john.johansen@...onical.com>,
"jmorris@...ei.org" <jmorris@...ei.org>,
"serge@...lyn.com" <serge@...lyn.com>,
"linux-csky@...r.kernel.org" <linux-csky@...r.kernel.org>,
"linux-fscrypt@...r.kernel.org" <linux-fscrypt@...r.kernel.org>,
"linux-security-module@...r.kernel.org"
<linux-security-module@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"linux-fsdevel@...r.kernel.org" <linux-fsdevel@...r.kernel.org>
Subject: RE: [PATCH v2] fs/proc: Optimize arrays defined by struct ctl_path
From: Meng Tang <tangmeng@...ontech.com>
> 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.
>
...
> 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)
Powered by blists - more mailing lists