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 <anchao@lixiang.com>
This commit is contained in:
chao an 2024-09-02 13:29:37 +08:00 committed by Xiang Xiao
parent 0b26b04081
commit 8ad39537dd
2 changed files with 12 additions and 5 deletions

View File

@ -886,7 +886,7 @@ static inline void help_builtins(FAR struct nsh_vtbl_s *vtbl)
char line[HELP_LINELEN + HELP_TABSIZE + 1]; 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 */ /* Count the number of built-in commands and get the optimal column width */

View File

@ -35,6 +35,14 @@
#ifndef CONFIG_NSH_DISABLESCRIPT #ifndef CONFIG_NSH_DISABLESCRIPT
/****************************************************************************
* Private Data
****************************************************************************/
#ifdef CONFIG_ETC_ROMFS
static bool g_nsh_script_initialized;
#endif
/**************************************************************************** /****************************************************************************
* Private Functions * Private Functions
****************************************************************************/ ****************************************************************************/
@ -227,15 +235,14 @@ int nsh_sysinitscript(FAR struct nsh_vtbl_s *vtbl)
#ifdef CONFIG_ETC_ROMFS #ifdef CONFIG_ETC_ROMFS
int nsh_initscript(FAR struct nsh_vtbl_s *vtbl) int nsh_initscript(FAR struct nsh_vtbl_s *vtbl)
{ {
static bool initialized;
bool already; bool already;
int ret = OK; int ret = OK;
/* Atomic test and set of the initialized flag */ /* Atomic test and set of the g_nsh_script_initialized flag */
sched_lock(); sched_lock();
already = initialized; already = g_nsh_script_initialized;
initialized = true; g_nsh_script_initialized = true;
sched_unlock(); sched_unlock();
/* If we have not already executed the init script, then do so now */ /* If we have not already executed the init script, then do so now */