From: Petr Mladek <pmladek@suse.com>
To: Feng Tang <feng.tang@linux.alibaba.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Steven Rostedt <rostedt@goodmis.org>,
Lance Yang <lance.yang@linux.dev>,
Jonathan Corbet <corbet@lwn.net>,
linux-kernel@vger.kernel.org, paulmck@kernel.org,
john.ogness@linutronix.de
Subject: Re: [PATCH 1/3] lib/sys_info: handle sys_info_mask==0 case
Date: Tue, 19 Aug 2025 10:34:14 +0200 [thread overview]
Message-ID: <aKQ3Bi5q7-in9MgC@pathway.suse.cz> (raw)
In-Reply-To: <20250815071428.98041-2-feng.tang@linux.alibaba.com>
On Fri 2025-08-15 15:14:26, Feng Tang wrote:
> It is a normal case that bitmask parameter is 0, so pre-initialize the
> names[] to null string to cover this case.
>
> Also remove the superfluous "+1" in names[sizeof(sys_info_avail) + 1],
> which is needed for 'strlen()', but not for 'sizeof()'.
>
> --- a/lib/sys_info.c
> +++ b/lib/sys_info.c
> @@ -55,7 +55,7 @@ int sysctl_sys_info_handler(const struct ctl_table *ro_table, int write,
> void *buffer, size_t *lenp,
> loff_t *ppos)
> {
> - char names[sizeof(sys_info_avail) + 1];
> + char names[sizeof(sys_info_avail)];
> struct ctl_table table;
> unsigned long *si_bits_global;
>
> @@ -81,6 +81,9 @@ int sysctl_sys_info_handler(const struct ctl_table *ro_table, int write,
> char *delim = "";
> int i, len = 0;
>
> + /* *si_bits_glabl could be 0 */
s/si_bits_glabl/si_bits_global/
But I would personally remove the comment completely. IMHO, the
purpose is quite obvious. But I do not resist on it.
> + names[0] = '\0';
> +
> for (i = 0; i < ARRAY_SIZE(si_names); i++) {
> if (*si_bits_global & si_names[i].bit) {
> len += scnprintf(names + len, sizeof(names) - len,
Otherwise, it looks good to me:
Reviewed-by: Petr Mladek <pmladek@suse.com>
Best Regards,
Petr
next prev parent reply other threads:[~2025-08-19 8:34 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-15 7:14 [PATCH 0/3] follow up patches for panic_print's generalization Feng Tang
2025-08-15 7:14 ` [PATCH 1/3] lib/sys_info: handle sys_info_mask==0 case Feng Tang
2025-08-19 8:34 ` Petr Mladek [this message]
2025-08-25 1:05 ` Feng Tang
2025-08-15 7:14 ` [PATCH 2/3] panic: refine the document for 'panic_print' Feng Tang
2025-08-19 8:35 ` Petr Mladek
2025-08-15 7:14 ` [PATCH 3/3] panic: add note that 'panic_print' parameter is deprecated Feng Tang
2025-08-19 9:48 ` Petr Mladek
2025-08-19 9:51 ` [PATCH] panic: Clean up message about deprecated 'panic_print' parameter Petr Mladek
2025-08-19 13:58 ` Lance Yang
2025-08-20 1:31 ` kernel test robot
2025-08-20 1:54 ` Lance Yang
2025-08-20 1:56 ` Lance Yang
2025-08-20 8:57 ` Lance Yang
2025-08-20 9:33 ` Petr Mladek
2025-08-20 9:40 ` [PATCH v2] " Petr Mladek
2025-08-20 11:03 ` Lance Yang
2025-08-25 1:01 ` Feng Tang
2025-08-20 10:39 ` [PATCH] " Lance Yang
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=aKQ3Bi5q7-in9MgC@pathway.suse.cz \
--to=pmladek@suse.com \
--cc=akpm@linux-foundation.org \
--cc=corbet@lwn.net \
--cc=feng.tang@linux.alibaba.com \
--cc=john.ogness@linutronix.de \
--cc=lance.yang@linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=paulmck@kernel.org \
--cc=rostedt@goodmis.org \
/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®