nshlib: disable nsh error print if NSH_DISABLE_ERROR_PRINT enabled

text	   data	    bss	    dec	    hex	filename
 398953	  27088	   4128	 430169	  69059	nuttx    /* before */
 389241	  27072	   4128	 420441	  66a59	nuttx    /* after  */
  -9712     -16

Signed-off-by: chao an <anchao@xiaomi.com>
This commit is contained in:
chao an
2023-06-08 19:37:31 +08:00
committed by Xiang Xiao
parent 900b32c908
commit ec63217b48
8 changed files with 40 additions and 23 deletions

View File

@@ -47,9 +47,13 @@
#define alias_head(list) (FAR struct nsh_alias_s *)sq_peek(list)
#define alias_remfirst(list) (FAR struct nsh_alias_s *)sq_remfirst(list)
/****************************************************************************
* Private Types
****************************************************************************/
/* Alias message format */
#define g_savefail_format "alias %s='%s' failed\n"
/* Common for both alias / unalias */
#define g_noalias_format "%s: %s not found\n"
/****************************************************************************
* Private Data
@@ -58,11 +62,6 @@
/* Alias message format */
static const char g_aliasfmt[] = "alias %s='%s'\n";
static const char g_savefailfmt[] = "alias %s='%s' failed\n";
/* Common for both alias / unalias */
static const char g_noaliasfmt[] = "%s: %s not found\n";
/****************************************************************************
* Private Functions
@@ -348,7 +347,7 @@ int cmd_alias(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv)
ret = alias_save(vtbl, *arg, value);
if (ret < 0)
{
nsh_error(vtbl, g_savefailfmt, *arg, value);
nsh_error(vtbl, g_savefail_format, *arg, value);
}
}
else if ((alias = alias_find(vtbl, *arg)) != NULL)
@@ -361,7 +360,7 @@ int cmd_alias(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv)
{
/* Nothing found */
nsh_error(vtbl, g_noaliasfmt, "alias", *arg);
nsh_error(vtbl, g_noalias_format, "alias", *arg);
ret = -ENOENT;
}
}
@@ -429,7 +428,7 @@ int cmd_unalias(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv)
{
/* Nothing found */
nsh_error(vtbl, g_noaliasfmt, "unalias", *arg);
nsh_error(vtbl, g_noalias_format, "unalias", *arg);
ret = -ENOENT;
}
}