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

@@ -63,8 +63,10 @@ static int nsh_consoleioctl(FAR struct nsh_vtbl_s *vtbl,
int cmd, unsigned long arg);
static int nsh_consoleoutput(FAR struct nsh_vtbl_s *vtbl,
FAR const char *fmt, ...) printf_like(2, 3);
#ifndef CONFIG_NSH_DISABLE_ERROR_PRINT
static int nsh_erroroutput(FAR struct nsh_vtbl_s *vtbl,
FAR const char *fmt, ...) printf_like(2, 3);
#endif
static FAR char *nsh_consolelinebuffer(FAR struct nsh_vtbl_s *vtbl);
static void nsh_consoleredirect(FAR struct nsh_vtbl_s *vtbl, int fd,
FAR uint8_t *save);
@@ -176,6 +178,7 @@ static int nsh_consoleoutput(FAR struct nsh_vtbl_s *vtbl,
*
****************************************************************************/
#ifndef CONFIG_NSH_DISABLE_ERROR_PRINT
static int nsh_erroroutput(FAR struct nsh_vtbl_s *vtbl,
FAR const char *fmt, ...)
{
@@ -189,6 +192,7 @@ static int nsh_erroroutput(FAR struct nsh_vtbl_s *vtbl,
return ret;
}
#endif
/****************************************************************************
* Name: nsh_consolelinebuffer
@@ -368,7 +372,9 @@ FAR struct console_stdio_s *nsh_newconsole(bool isctty)
pstate->cn_vtbl.write = nsh_consolewrite;
pstate->cn_vtbl.ioctl = nsh_consoleioctl;
pstate->cn_vtbl.output = nsh_consoleoutput;
#ifndef CONFIG_NSH_DISABLE_ERROR_PRINT
pstate->cn_vtbl.error = nsh_erroroutput;
#endif
pstate->cn_vtbl.linebuffer = nsh_consolelinebuffer;
pstate->cn_vtbl.exit = nsh_consoleexit;
pstate->cn_vtbl.isctty = isctty;