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/nuttx-apps.git
commit 94d477b3dfcefd0cd2719cb78dbad07f3f633086 Author: Ville Juven <[email protected]> AuthorDate: Thu Aug 24 13:26:20 2023 +0300 nshlib/nsh_console.h: Add nsh_none, where any empty output can be forwarded Add nsh_none to consume all empty traces from nsh. For the variadic argument case need to add a (inline) function to eat away the __VA_ARGS__ list, there is no good / portable way to do this by pre-processor macros, but a function will eat the variadic list whatever its size is. --- nshlib/nsh_console.h | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/nshlib/nsh_console.h b/nshlib/nsh_console.h index a9a382045..adea4b455 100644 --- a/nshlib/nsh_console.h +++ b/nshlib/nsh_console.h @@ -51,20 +51,19 @@ #define nsh_exit(v,s) (v)->exit(v,s) #ifdef CONFIG_CPP_HAVE_VARARGS -# define nsh_error(v, ...) (v)->error(v, ##__VA_ARGS__) -# define nsh_output(v, ...) (v)->output(v, ##__VA_ARGS__) +# define nsh_error(v, ...) (v)->error(v, ##__VA_ARGS__) +# define nsh_output(v, ...) (v)->output(v, ##__VA_ARGS__) +# define nsh_none(v, ...) \ + do { if (0) nsh_output_none(v, ##__VA_ARGS__); } while (0) #else -# define nsh_error vtbl->error -# define nsh_output vtbl->output +# define nsh_error vtbl->error +# define nsh_output vtbl->output +# define nsh_none (void) #endif #ifdef CONFIG_NSH_DISABLE_ERROR_PRINT # undef nsh_error -# ifdef CONFIG_CPP_HAVE_VARARGS -# define nsh_error(v, ...) (void)(v) -# else -# define nsh_error (void)(vtbl) -# endif +# define nsh_error nsh_none #endif /* Size of info to be saved in call to nsh_redirect @@ -183,6 +182,19 @@ struct console_stdio_s * Public Data ****************************************************************************/ +/**************************************************************************** + * Inline functions + ****************************************************************************/ + +#ifdef CONFIG_CPP_HAVE_VARARGS +/* Can be used to suppress any nsh output */ + +static inline void nsh_output_none(FAR struct nsh_vtbl_s *vtbl, ...) +{ + UNUSED(vtbl); +} +#endif + /**************************************************************************** * Public Function Prototypes ****************************************************************************/
