Re: [PATCH v2 3/6] panic: sys_info: Replace struct sys_info_name with plain array of strings

From: Andy Shevchenko

Date: Thu Oct 30 2025 - 03:36:46 EST


On Thu, Oct 30, 2025 at 10:01:49AM +0800, Feng Tang wrote:
> On Wed, Oct 29, 2025 at 12:07:38PM +0100, Andy Shevchenko wrote:
> > There is no need to keep a custom structure just for the need of
> > a plain array of strings. Replace struct sys_info_name with plain
> > array of strings.
> >
> > With that done, simplify the code, in particular, naturally use
> > for_each_set_bit() when iterating over si_bits_global bitmap.

...

> > names[0] = '\0';
> > - for (i = 0; i < ARRAY_SIZE(si_names); i++) {
> > - if (si_bits & si_names[i].bit) {
> > - len += scnprintf(names + len, sizeof(names) - len,
> > - "%s%s", delim, si_names[i].name);
> > - delim = ",";
> > - }
> > + for_each_set_bit(i, &si_bits, ARRAY_SIZE(si_names)) {
> > + len += scnprintf(names + len, sizeof(names) - len,
> > + "%s%s", delim, si_names[i]);
> > + delim = ",";
>
> For SYS_INFO_PANIC_CONSOLE_REPLAY bit, it is a NULL string, no need for
> an extra ','?

If you look closer to the original code, the behaviour is the same. Feel free
to update behaviour separately as I tried to keep the functionality to be not
changed with my series (with the exceptions of the fetching issue).

--
With Best Regards,
Andy Shevchenko