From: David Laight <David.Laight@ACULAB.COM>
To: 'Meng Tang' <tangmeng@uniontech.com>,
"mcgrof@kernel.org" <mcgrof@kernel.org>,
"keescook@chromium.org" <keescook@chromium.org>,
"yzaikin@google.com" <yzaikin@google.com>
Cc: "guoren@kernel.org" <guoren@kernel.org>,
"nickhu@andestech.com" <nickhu@andestech.com>,
"green.hu@gmail.com" <green.hu@gmail.com>,
"deanbo422@gmail.com" <deanbo422@gmail.com>,
"ebiggers@kernel.org" <ebiggers@kernel.org>,
"tytso@mit.edu" <tytso@mit.edu>,
"wad@chromium.org" <wad@chromium.org>,
"john.johansen@canonical.com" <john.johansen@canonical.com>,
"jmorris@namei.org" <jmorris@namei.org>,
"serge@hallyn.com" <serge@hallyn.com>,
"linux-csky@vger.kernel.org" <linux-csky@vger.kernel.org>,
"linux-fscrypt@vger.kernel.org" <linux-fscrypt@vger.kernel.org>,
"linux-security-module@vger.kernel.org"
<linux-security-module@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>
Subject: RE: [PATCH v2] fs/proc: Optimize arrays defined by struct ctl_path
Date: Thu, 24 Feb 2022 11:05:35 +0000 [thread overview]
Message-ID: <376fe4403af346ccbdc7294259b8d11a@AcuMS.aculab.com> (raw)
In-Reply-To: <20220224105234.19379-1-tangmeng@uniontech.com>
From: Meng Tang <tangmeng@uniontech.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)
prev parent reply other threads:[~2022-02-24 11:05 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-24 10:52 Meng Tang
2022-02-24 11:05 ` David Laight [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=376fe4403af346ccbdc7294259b8d11a@AcuMS.aculab.com \
--to=david.laight@aculab.com \
--cc=deanbo422@gmail.com \
--cc=ebiggers@kernel.org \
--cc=green.hu@gmail.com \
--cc=guoren@kernel.org \
--cc=jmorris@namei.org \
--cc=john.johansen@canonical.com \
--cc=keescook@chromium.org \
--cc=linux-csky@vger.kernel.org \
--cc=linux-fscrypt@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=mcgrof@kernel.org \
--cc=nickhu@andestech.com \
--cc=serge@hallyn.com \
--cc=tangmeng@uniontech.com \
--cc=tytso@mit.edu \
--cc=wad@chromium.org \
--cc=yzaikin@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®