Re: [PATCH] init: Use ARRAY_SIZE() in unknown_bootoption()
From: Andrew Morton
Date: Tue Nov 17 2026 - 19:40:41 EST
On Wed, 18 Nov 2026 01:00:36 +0100 Thorsten Blum <blum@xxxxxxxxxx> wrote:
> Remove the NULL terminator from the bootloader array, make its entries
> const, and use ARRAY_SIZE() as the loop bound. Also reuse the for loop
> index i instead of redeclaring it multiple times.
>
> ...
>
> --- a/init/main.c
> +++ b/init/main.c
> @@ -576,7 +576,8 @@ static int __init unknown_bootoption(char *param, char *val,
> * 1. LILO/Grub pass "BOOT_IMAGE=...";
> * 2. kexec/kdump (kexec-tools) pass "kexec".
> */
> - const char *bootloader[] = { "BOOT_IMAGE=", "kexec", NULL };
> + const char * const bootloader[] = { "BOOT_IMAGE=", "kexec" };
While you're in there, making this
static const char * const bootloader[] __initconst = ...
could/should/might put this into .init.rodata so its memory gets
recycled later in boot.