From 8ad39537dd8d0ed6f3f50e4fe6f923346179969f Mon Sep 17 00:00:00 2001 From: chao an Date: Mon, 2 Sep 2024 13:29:37 +0800 Subject: [PATCH] nshlib: move g_builtin_prompt from data to rodata 1. move g_builtin_prompt from data to rodata 2. add g_ prefix to some global variables Signed-off-by: chao an --- nshlib/nsh_command.c | 2 +- nshlib/nsh_script.c | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/nshlib/nsh_command.c b/nshlib/nsh_command.c index 0256fe2ac..d15b15a2c 100644 --- a/nshlib/nsh_command.c +++ b/nshlib/nsh_command.c @@ -886,7 +886,7 @@ static inline void help_builtins(FAR struct nsh_vtbl_s *vtbl) char line[HELP_LINELEN + HELP_TABSIZE + 1]; - static const char *g_builtin_prompt = "\nBuiltin Apps:\n"; + static FAR const char *const g_builtin_prompt = "\nBuiltin Apps:\n"; /* Count the number of built-in commands and get the optimal column width */ diff --git a/nshlib/nsh_script.c b/nshlib/nsh_script.c index e9a89af5b..9cf19fd25 100644 --- a/nshlib/nsh_script.c +++ b/nshlib/nsh_script.c @@ -35,6 +35,14 @@ #ifndef CONFIG_NSH_DISABLESCRIPT +/**************************************************************************** + * Private Data + ****************************************************************************/ + +#ifdef CONFIG_ETC_ROMFS +static bool g_nsh_script_initialized; +#endif + /**************************************************************************** * Private Functions ****************************************************************************/ @@ -227,15 +235,14 @@ int nsh_sysinitscript(FAR struct nsh_vtbl_s *vtbl) #ifdef CONFIG_ETC_ROMFS int nsh_initscript(FAR struct nsh_vtbl_s *vtbl) { - static bool initialized; bool already; int ret = OK; - /* Atomic test and set of the initialized flag */ + /* Atomic test and set of the g_nsh_script_initialized flag */ sched_lock(); - already = initialized; - initialized = true; + already = g_nsh_script_initialized; + g_nsh_script_initialized = true; sched_unlock(); /* If we have not already executed the init script, then do so now */