On Tue, 24 Mar 2026 16:13:25 -0600
Wesley Atwell <[email protected]> wrote:
> +++ b/kernel/trace/trace.c
> @@ -228,6 +228,34 @@ static int boot_instance_index;
> static char boot_snapshot_info[COMMAND_LINE_SIZE] __initdata;
> static int boot_snapshot_index;
>
> +/*
> + * Repeated boot parameters, including Bootconfig array expansions, need
> + * to stay in the delimiter form that the existing parser consumes.
> + */
> +void __init trace_append_boot_param(char *buf, const char *str, char sep,
> + size_t size)
> +{
> + size_t len, str_len;
Why use the "size_t" type? Just use int. Then you don't need to play games
about unsigned types in the if statements below. The boot cmdline will
never come close to being 2GB in size.
> +
> + if (!buf[0]) {
Should we check for size here? Perhaps just remove this part (see below)
> + strscpy(buf, str, size);
> + return;
> + }
> +
> + str_len = strlen(str);
> + if (!str_len)
> + return;
> +
> + len = strlen(buf);
> + if (len >= size - 1)
> + return;
> + if (str_len >= size - len - 1)
> + return;
Instead of the above, have:
/* Plus 2 for ",\0" */
if (str_len + len + 2 > size)
return;
> +
> + buf[len] = sep;
If we remove the first check, here we can have:
if (len)
buf[len++] = sep;
By adding one to length, it makes the strscpy() a bit more readable.
strscpy(buf + len, str, size - len);
> + strscpy(buf + len + 1, str, size - len - 1);
> +}
> +
-- Steve