From 8721bc68478adedb4ebed8e7a0b4413895c07535 Mon Sep 17 00:00:00 2001 From: "chao.an" Date: Thu, 6 May 2021 22:28:05 +0800 Subject: [PATCH] nshlib: Fix the build break in nsh_telnetd.c when CONFIG_NSH_CONSOLE=n set the config: CONFIG_NSH_ROMFSETC=y CONFIG_NSH_CONSOLE=n nsh_telnetd.c: In function 'nsh_telnetstart': nsh_telnetd.c:267:22: error: 'vtbl' undeclared (first use in this function) 267 | nsh_initscript(vtbl); | ^~~~ Signed-off-by: chao.an --- nshlib/nsh_console.c | 2 +- nshlib/nsh_console.h | 2 +- nshlib/nsh_telnetd.c | 7 ++++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/nshlib/nsh_console.c b/nshlib/nsh_console.c index 8489d0d51..786c344e2 100644 --- a/nshlib/nsh_console.c +++ b/nshlib/nsh_console.c @@ -463,8 +463,8 @@ FAR struct console_stdio_s *nsh_newconsole(void) #ifndef CONFIG_NSH_DISABLEBG pstate->cn_vtbl.clone = nsh_consoleclone; - pstate->cn_vtbl.release = nsh_consolerelease; #endif + pstate->cn_vtbl.release = nsh_consolerelease; pstate->cn_vtbl.write = nsh_consolewrite; pstate->cn_vtbl.output = nsh_consoleoutput; pstate->cn_vtbl.error = nsh_erroroutput; diff --git a/nshlib/nsh_console.h b/nshlib/nsh_console.h index 510e26f0b..49b31f71d 100644 --- a/nshlib/nsh_console.h +++ b/nshlib/nsh_console.h @@ -123,8 +123,8 @@ struct nsh_vtbl_s #ifndef CONFIG_NSH_DISABLEBG FAR struct nsh_vtbl_s *(*clone)(FAR struct nsh_vtbl_s *vtbl); void (*addref)(FAR struct nsh_vtbl_s *vtbl); - void (*release)(FAR struct nsh_vtbl_s *vtbl); #endif + void (*release)(FAR struct nsh_vtbl_s *vtbl); ssize_t (*write)(FAR struct nsh_vtbl_s *vtbl, FAR const void *buffer, size_t nbytes); int (*error)(FAR struct nsh_vtbl_s *vtbl, FAR const char *fmt, ...); diff --git a/nshlib/nsh_telnetd.c b/nshlib/nsh_telnetd.c index 05159931e..a633fa0b3 100644 --- a/nshlib/nsh_telnetd.c +++ b/nshlib/nsh_telnetd.c @@ -241,6 +241,9 @@ int nsh_telnetstart(sa_family_t family) if (state == TELNETD_NOTRUNNING) { +#if defined(CONFIG_NSH_ROMFSETC) && !defined(CONFIG_NSH_CONSOLE) + FAR struct console_stdio_s *pstate; +#endif struct telnetd_config_s config; /* There is a tiny race condition here if two tasks were to try to @@ -264,7 +267,9 @@ int nsh_telnetstart(sa_family_t family) */ #if defined(CONFIG_NSH_ROMFSETC) && !defined(CONFIG_NSH_CONSOLE) - nsh_initscript(vtbl); + pstate = nsh_newconsole(); + nsh_initscript(&pstate->cn_vtbl); + nsh_release(&pstate->cn_vtbl); #endif #if defined(CONFIG_NSH_NETINIT) && !defined(CONFIG_NSH_CONSOLE)