Revert "apps/nshlib/nsh_parse.c: Fix warning: 'g_nullstring defined but not used'. Use directly since the usage is triggered by a complex Kconfig combination."

Per SUZUKI Y <NBG03015@nifty.ne.jp>, changing:

-      return (FAR char *)g_nullstring;
+      return "";

causes a bad return value because "" lies on the stack.

This reverts commit 9defae8af6.
This commit is contained in:
Gregory Nutt 2019-12-19 07:52:00 -06:00
parent 9b77f80740
commit 6bfd6166dd

View File

@ -222,6 +222,7 @@ static const char g_exitstatus[] = "?";
static const char g_success[] = "0";
static const char g_failure[] = "1";
#endif
static const char g_nullstring[] = "";
/****************************************************************************
* Public Data
@ -886,7 +887,7 @@ static FAR char *nsh_cmdparm(FAR struct nsh_vtbl_s *vtbl, FAR char *cmdline,
if (!allocation)
{
return "";
return (FAR char *)g_nullstring;
}
/* Create a unique file name using the task ID */
@ -896,7 +897,7 @@ static FAR char *nsh_cmdparm(FAR struct nsh_vtbl_s *vtbl, FAR char *cmdline,
if (ret < 0 || !tmpfile)
{
nsh_error(vtbl, g_fmtcmdoutofmemory, "``");
return "";
return (FAR char *)g_nullstring;
}
/* Execute the command that will re-direct the output of the command to
@ -911,7 +912,7 @@ static FAR char *nsh_cmdparm(FAR struct nsh_vtbl_s *vtbl, FAR char *cmdline,
nsh_error(vtbl, g_fmtcmdfailed, "``", "exec", NSH_ERRNO);
free(tmpfile);
return "";
return (FAR char *)g_nullstring;
}
/* Concatenate the file contents with the current allocation */
@ -1052,7 +1053,7 @@ static FAR char *nsh_envexpand(FAR struct nsh_vtbl_s *vtbl, FAR char *varname)
}
#endif
return "";
return (FAR char *)g_nullstring;
}
}
#endif
@ -1231,7 +1232,7 @@ static FAR char *nsh_argexpand(FAR struct nsh_vtbl_s *vtbl, FAR char *cmdline,
if (!rptr)
{
nsh_error(vtbl, g_fmtnomatching, "`", "`");
return "";
return (FAR char *)g_nullstring;
}
/* Replace the final back-quote with a NUL terminator */
@ -1239,7 +1240,7 @@ static FAR char *nsh_argexpand(FAR struct nsh_vtbl_s *vtbl, FAR char *cmdline,
*rptr = '\0';
/* Then execute the command to get the sub-string value. On
* error, nsh_cmdparm may return null string but never NULL.
* error, nsh_cmdparm may return g_nullstring but never NULL.
*/
result = nsh_cmdparm(vtbl, ptr, &tmpalloc);
@ -1298,7 +1299,7 @@ static FAR char *nsh_argexpand(FAR struct nsh_vtbl_s *vtbl, FAR char *cmdline,
if (!rptr)
{
nsh_error(vtbl, g_fmtnomatching, "${", "}");
return "";
return (FAR char *)g_nullstring;
}
/* Replace the right bracket with a NUL terminator and set the
@ -1366,7 +1367,7 @@ static FAR char *nsh_argexpand(FAR struct nsh_vtbl_s *vtbl, FAR char *cmdline,
static FAR char *nsh_argexpand(FAR struct nsh_vtbl_s *vtbl, FAR char *cmdline,
FAR char **allocation, FAR int *isenvvar)
{
FAR char *argument = "";
FAR char *argument = (FAR char *)g_nullstring;
#ifdef CONFIG_NSH_QUOTE
char ch = *cmdline;
@ -1395,7 +1396,7 @@ static FAR char *nsh_argexpand(FAR struct nsh_vtbl_s *vtbl, FAR char *cmdline,
if (!rptr || rptr[1] != '\0')
{
nsh_error(vtbl, g_fmtnomatching, "`", "`");
return "";
return (FAR char *)g_nullstring;
}
/* Replace the final back-quote with a NUL terminator */