Re: [PATCH] sh: use sizeof() in memchunk_cmdline_override
From: Geert Uytterhoeven
Date: Fri Apr 24 2026 - 07:06:24 EST
Hi Thorsten,
On Thu, 23 Apr 2026 at 14:10, Thorsten Blum <thorsten.blum@xxxxxxxxx> wrote:
> Replace the hard-coded string length with 'sizeof("memchunk.") - 1' and
> remove the comment.
>
> Signed-off-by: Thorsten Blum <thorsten.blum@xxxxxxxxx>
Thanks for your patch!
> --- a/arch/sh/mm/consistent.c
> +++ b/arch/sh/mm/consistent.c
> @@ -23,7 +23,7 @@ static void __init memchunk_cmdline_override(char *name, unsigned long *sizep)
> int k = strlen(name);
>
> while ((p = strstr(p, "memchunk."))) {
> - p += 9; /* strlen("memchunk.") */
> + p += sizeof("memchunk.") - 1;
Can't you just use strlen() instead, i.e. won't the compiler optimize
that into a constant?
> if (!strncmp(name, p, k) && p[k] == '=') {
> p += k + 1;
> *sizep = memparse(p, NULL);
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds