Skip to contentSkip to conversation

init: mark envp_init as static

PATCH In review Sameeksha Sankpal 2 participants 2 messages Nov 28, 2025 – Nov 30, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 init: mark envp_init as static

Sparse reports a warning that 'envp_init' has no prior declaration:

warning: symbol 'envp_init' was not declared. Should it be static?

The variable is only used within init/main.c and does not need external linkage. Mark it as static to limit its scope and fix the sparse warning.

---
 init/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
init/main.c +1 -1
index 07a3116811c5..792ab00e62e6 100644
@@ -191,7 +191,7 @@ static int __init set_reset_devices(char *str)
 __setup("reset_devices", set_reset_devices);
 
 static const char *argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };
-const char *envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };
+static const char *envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };
 static const char *panic_later, *panic_param;
 
 static bool __init obsolete_checksetup(char *line)
Signature · 1 line
2.43.0
#1 lore raw
Quoted 8 lines · Sameeksha Sankpal

Sparse reports a warning that 'envp_init' has no prior declaration:

warning: symbol 'envp_init' was not declared. Should it be static?

The variable is only used within init/main.c and does not need external linkage. Mark it as static to limit its scope and fix the sparse warning.

It's used in do_mounts_initrd::handle_initrd()

Quoted 22 lines
---
 init/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
init/main.c +1 -1
index 07a3116811c5..792ab00e62e6 100644
@@ -191,7 +191,7 @@ static int __init set_reset_devices(char *str)
 __setup("reset_devices", set_reset_devices);
 
 static const char *argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };
-const char *envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };
+static const char *envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };
 static const char *panic_later, *panic_param;
 
 static bool __init obsolete_checksetup(char *line)
Signature · 1 line
2.43.0
Signature · 2 lines
Sincerely yours,
Mike.