You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2021/05/07 17:53:33 UTC

[incubator-nuttx-apps] branch master updated: nshlib: Fix the build break in nsh_telnetd.c when CONFIG_NSH_CONSOLE=n

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git


The following commit(s) were added to refs/heads/master by this push:
     new 8721bc6  nshlib: Fix the build break in nsh_telnetd.c when CONFIG_NSH_CONSOLE=n
8721bc6 is described below

commit 8721bc68478adedb4ebed8e7a0b4413895c07535
Author: chao.an <an...@xiaomi.com>
AuthorDate: Thu May 6 22:28:05 2021 +0800

    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 <an...@xiaomi.com>
---
 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 8489d0d..786c344 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 510e26f..49b31f7 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 0515993..a633fa0 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)