You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by gn...@apache.org on 2020/05/06 13:31:22 UTC
[incubator-nuttx-apps] 01/02: debug: Reduce CONFIG_CPP_HAVE_VARARGS
usage
This is an automated email from the ASF dual-hosted git repository.
gnutt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git
commit 8a1f5ee34c782dc585a339007878fb4a7407e3d2
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Mon May 4 18:52:59 2020 +0800
debug: Reduce CONFIG_CPP_HAVE_VARARGS usage
Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
examples/elf/elf_main.c | 29 +++++----------
examples/ft80x/ft80x.h | 62 +++++++++++++-------------------
examples/nxflat/nxflat_main.c | 29 +++++----------
examples/posix_spawn/spawn_main.c | 20 +++--------
fsutils/inifile/inifile.c | 40 ++++++++-------------
graphics/ft80x/ft80x.h | 62 +++++++++++++-------------------
graphics/nxwm/src/cmediaplayer.cxx | 14 --------
graphics/nxwm/src/ctouchscreen.cxx | 19 ----------
netutils/thttpd/fdwatch.c | 18 +++-------
system/cle/cle.c | 38 ++++++--------------
system/i2c/i2ctool.h | 4 ---
system/spi/spitool.h | 4 ---
system/vi/vi.c | 72 ++++++++------------------------------
system/zmodem/zm.h | 13 +++----
14 files changed, 117 insertions(+), 307 deletions(-)
diff --git a/examples/elf/elf_main.c b/examples/elf/elf_main.c
index 8c15935..5ddf81b 100644
--- a/examples/elf/elf_main.c
+++ b/examples/elf/elf_main.c
@@ -105,28 +105,15 @@
* that the output will be synchronous with the debug output.
*/
-#ifdef CONFIG_CPP_HAVE_VARARGS
-# ifdef CONFIG_DEBUG_INFO
-# define message(format, ...) syslog(LOG_INFO, format, ##__VA_ARGS__)
-# else
-# define message(format, ...) printf(format, ##__VA_ARGS__)
-# endif
-# ifdef CONFIG_DEBUG_ERROR
-# define errmsg(format, ...) syslog(LOG_ERR, format, ##__VA_ARGS__)
-# else
-# define errmsg(format, ...) fprintf(stderr, format, ##__VA_ARGS__)
-# endif
+#ifdef CONFIG_DEBUG_INFO
+# define message _info
#else
-# ifdef CONFIG_DEBUG_INFO
-# define message _info
-# else
-# define message printf
-# endif
-# ifdef CONFIG_DEBUG_ERROR
-# define errmsg _err
-# else
-# define errmsg printf
-# endif
+# define message printf
+#endif
+#ifdef CONFIG_DEBUG_ERROR
+# define errmsg _err
+#else
+# define errmsg printf
#endif
/****************************************************************************
diff --git a/examples/ft80x/ft80x.h b/examples/ft80x/ft80x.h
index ca9438d..110b80e 100644
--- a/examples/ft80x/ft80x.h
+++ b/examples/ft80x/ft80x.h
@@ -56,45 +56,31 @@
* Could be a porting issue.
*/
-#ifdef CONFIG_CPP_HAVE_VARARGS
-# ifdef GRAPHICS_FT80X_DEBUG_ERROR
-# define ft80x_err(format, ...) \
- fprintf(stderr, EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__)
-# else
-# define ft80x_err(format, ...)
-# endif
-
-# ifdef GRAPHICS_FT80X_DEBUG_WARN
-# define ft80x_warn(format, ...) \
- fprintf(stderr, EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__)
-# else
-# define ft80x_warn(format, ...)
-# endif
-
-# ifdef GRAPHICS_FT80X_DEBUG_INFO
-# define ft80x_info(format, ...) \
- printf(EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__)
-# else
-# define ft80x_info(format, ...)
-# endif
+#if !defined(GRAPHICS_FT80X_DEBUG_ERROR)
+# define ft80x_err _none
+#elif defined(CONFIG_CPP_HAVE_VARARGS)
+# define ft80x_err(format, ...) \
+ fprintf(stderr, EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__)
#else
-# ifdef GRAPHICS_FT80X_DEBUG_ERROR
-# define ft80x_err printf
-# else
-# define ft80x_err (void)
-# endif
-
-# ifdef GRAPHICS_FT80X_DEBUG_WARN
-# define ft80x_warn printf
-# else
-# define ft80x_warn (void)
-# endif
-
-# ifdef GRAPHICS_FT80X_DEBUG_INFO
-# define ft80x_info printf
-# else
-# define ft80x_info (void)
-# endif
+# define ft80x_err printf
+#endif
+
+#if !defined(GRAPHICS_FT80X_DEBUG_WARN)
+# define ft80x_warn _none
+#elif defined(CONFIG_CPP_HAVE_VARARGS)
+# define ft80x_warn(format, ...) \
+ fprintf(stderr, EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__)
+#else
+# define ft80x_warn printf
+#endif
+
+#if !defined(GRAPHICS_FT80X_DEBUG_INFO)
+# define ft80x_info _none
+#elif defined(CONFIG_CPP_HAVE_VARARGS)
+# define ft80x_info(format, ...) \
+ printf(EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__)
+#else
+# define ft80x_info printf
#endif
/****************************************************************************
diff --git a/examples/nxflat/nxflat_main.c b/examples/nxflat/nxflat_main.c
index 5001f3a..2d1620a 100644
--- a/examples/nxflat/nxflat_main.c
+++ b/examples/nxflat/nxflat_main.c
@@ -96,28 +96,15 @@
* that the output will be synchronous with the debug output.
*/
-#ifdef CONFIG_CPP_HAVE_VARARGS
-# ifdef CONFIG_DEBUG_INFO
-# define message(format, ...) syslog(LOG_INFO, format, ##__VA_ARGS__)
-# else
-# define message(format, ...) printf(format, ##__VA_ARGS__)
-# endif
-# ifdef CONFIG_DEBUG_ERROR
-# define errmsg(format, ...) syslog(LOG_ERR, format, ##__VA_ARGS__)
-# else
-# define errmsg(format, ...) fprintf(stderr, format, ##__VA_ARGS__)
-# endif
+#ifdef CONFIG_DEBUG_INFO
+# define message _info
#else
-# ifdef CONFIG_DEBUG_INFO
-# define message _info
-# else
-# define message printf
-# endif
-# ifdef CONFIG_DEBUG_ERROR
-# define errmsg _err
-# else
-# define errmsg printf
-# endif
+# define message printf
+#endif
+#ifdef CONFIG_DEBUG_ERROR
+# define errmsg _err
+#else
+# define errmsg printf
#endif
/****************************************************************************
diff --git a/examples/posix_spawn/spawn_main.c b/examples/posix_spawn/spawn_main.c
index 6316f58..add4d2d 100644
--- a/examples/posix_spawn/spawn_main.c
+++ b/examples/posix_spawn/spawn_main.c
@@ -96,22 +96,12 @@
* that the output will be synchronous with the debug output.
*/
-#ifdef CONFIG_CPP_HAVE_VARARGS
-# ifdef CONFIG_DEBUG_FEATURES
-# define message(format, ...) _info(format, ##__VA_ARGS__)
-# define errmsg(format, ...) _err(format, ##__VA_ARGS__)
-# else
-# define message(format, ...) printf(format, ##__VA_ARGS__)
-# define errmsg(format, ...) fprintf(stderr, format, ##__VA_ARGS__)
-# endif
+#ifdef CONFIG_DEBUG_FEATURES
+# define message _info
+# define errmsg _err
#else
-# ifdef CONFIG_DEBUG_FEATURES
-# define message _info
-# define errmsg _err
-# else
-# define message printf
-# define errmsg printf
-# endif
+# define message printf
+# define errmsg printf
#endif
/****************************************************************************
diff --git a/fsutils/inifile/inifile.c b/fsutils/inifile/inifile.c
index 6707abf..75098f6 100644
--- a/fsutils/inifile/inifile.c
+++ b/fsutils/inifile/inifile.c
@@ -60,32 +60,22 @@
# define CONFIG_FSUTILS_INIFILE_DEBUGLEVEL 0
#endif
-#ifdef CONFIG_CPP_HAVE_VARARGS
-# if CONFIG_FSUTILS_INIFILE_DEBUGLEVEL > 0
-# define inidbg(format, ...) \
- printf(EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__)
-# else
-# define inidbg(x...)
-# endif
-
-# if CONFIG_FSUTILS_INIFILE_DEBUGLEVEL > 1
-# define iniinfo(format, ...) \
- printf(EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__)
-# else
-# define iniinfo(x...)
-# endif
+#if CONFIG_FSUTILS_INIFILE_DEBUGLEVEL < 1
+# define inidbg _none
+#elif defined(CONFIG_CPP_HAVE_VARARGS)
+# define inidbg(format, ...) \
+ printf(EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__)
#else
-# if CONFIG_FSUTILS_INIFILE_DEBUGLEVEL > 0
-# define inidbg printf
-# else
-# define inidbg (void)
-# endif
-
-# if CONFIG_FSUTILS_INIFILE_DEBUGLEVEL > 1
-# define iniinfo printf
-# else
-# define iniinfo (void)
-# endif
+# define inidbg printf
+#endif
+
+#if CONFIG_FSUTILS_INIFILE_DEBUGLEVEL < 2
+# define iniinfo _none
+#elif defined(CONFIG_CPP_HAVE_VARARGS)
+# define iniinfo(format, ...) \
+ printf(EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__)
+#else
+# define iniinfo printf
#endif
/****************************************************************************
diff --git a/graphics/ft80x/ft80x.h b/graphics/ft80x/ft80x.h
index fa2224c..cbfcb88 100644
--- a/graphics/ft80x/ft80x.h
+++ b/graphics/ft80x/ft80x.h
@@ -57,45 +57,31 @@
* Could be a porting issue.
*/
-#ifdef CONFIG_CPP_HAVE_VARARGS
-# ifdef CONFIG_GRAPHICS_FT80X_DEBUG_ERROR
-# define ft80x_err(format, ...) \
- fprintf(stderr, EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__)
-# else
-# define ft80x_err(format, ...)
-# endif
-
-# ifdef CONFIG_GRAPHICS_FT80X_DEBUG_WARN
-# define ft80x_warn(format, ...) \
- fprintf(stderr, EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__)
-# else
-# define ft80x_warn(format, ...)
-# endif
-
-# ifdef CONFIG_GRAPHICS_FT80X_DEBUG_INFO
-# define ft80x_info(format, ...) \
- printf(EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__)
-# else
-# define ft80x_info(format, ...)
-# endif
+#if !defined(CONFIG_GRAPHICS_FT80X_DEBUG_ERROR)
+# define ft80x_err _none
+#elif defined(CONFIG_CPP_HAVE_VARARGS)
+# define ft80x_err(format, ...) \
+ fprintf(stderr, EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__)
#else
-# ifdef CONFIG_GRAPHICS_FT80X_DEBUG_ERROR
-# define ft80x_err printf
-# else
-# define ft80x_err (void)
-# endif
-
-# ifdef CONFIG_GRAPHICS_FT80X_DEBUG_WARN
-# define ft80x_warn printf
-# else
-# define ft80x_warn (void)
-# endif
-
-# ifdef CONFIG_GRAPHICS_FT80X_DEBUG_INFO
-# define ft80x_info printf
-# else
-# define ft80x_info (void)
-# endif
+# define ft80x_err printf
+#endif
+
+#if !defined(CONFIG_GRAPHICS_FT80X_DEBUG_WARN)
+# define ft80x_warn _none
+#elif defined(CONFIG_CPP_HAVE_VARARGS)
+# define ft80x_warn(format, ...) \
+ fprintf(stderr, EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__)
+#else
+# define ft80x_warn printf
+#endif
+
+#if !defined(CONFIG_GRAPHICS_FT80X_DEBUG_INFO)
+# define ft80x_info _none
+#elif defined(CONFIG_CPP_HAVE_VARARGS)
+# define ft80x_info(format, ...) \
+ printf(EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__)
+#else
+# define ft80x_info printf
#endif
#define FT80X_CMDFIFO_MASK (FT80X_CMDFIFO_SIZE - 1)
diff --git a/graphics/nxwm/src/cmediaplayer.cxx b/graphics/nxwm/src/cmediaplayer.cxx
index 1e5d367..4c32f99 100644
--- a/graphics/nxwm/src/cmediaplayer.cxx
+++ b/graphics/nxwm/src/cmediaplayer.cxx
@@ -63,20 +63,6 @@
* Pre-Processor Definitions
********************************************************************************************/
-/* We want debug output from this file if either audio or graphics debug is enabled. */
-
-#if !defined(CONFIG_DEBUG_AUDIO) && !defined(CONFIG_DEBUG_GRAPHICS)
-# undef gerr
-# undef _info
-# ifdef CONFIG_CPP_HAVE_VARARGS
-# define gerr(x...)
-# define _info(x...)
-# else
-# define gerr (void)
-# define _info (void)
-# endif
-#endif
-
#define AUDIO_NSUBSAMPLES 4
/********************************************************************************************
diff --git a/graphics/nxwm/src/ctouchscreen.cxx b/graphics/nxwm/src/ctouchscreen.cxx
index 19253b2..b7e279c 100644
--- a/graphics/nxwm/src/ctouchscreen.cxx
+++ b/graphics/nxwm/src/ctouchscreen.cxx
@@ -61,25 +61,6 @@
#include "graphics/nxwm/ctouchscreen.hxx"
/********************************************************************************************
- * Pre-Processor Definitions
- ********************************************************************************************/
-/* We want debug output from this file if either input/touchscreen or graphics debug is
- * enabled.
- */
-
-#if !defined(CONFIG_DEBUG_INPUT) && !defined(CONFIG_DEBUG_GRAPHICS)
-# undef gerr
-# undef _info
-# ifdef CONFIG_CPP_HAVE_VARARGS
-# define gerr(x...)
-# define _info(x...)
-# else
-# define gerr (void)
-# define _info (void)
-# endif
-#endif
-
-/********************************************************************************************
* CTouchscreen Method Implementations
********************************************************************************************/
diff --git a/netutils/thttpd/fdwatch.c b/netutils/thttpd/fdwatch.c
index 0706aaf..ed1880d 100644
--- a/netutils/thttpd/fdwatch.c
+++ b/netutils/thttpd/fdwatch.c
@@ -61,21 +61,11 @@
*/
#ifdef CONFIG_THTTPD_FDWATCH_DEBUG
-# ifdef CONFIG_CPP_HAVE_VARARGS
-# define fwerr(format, ...) nerr(format, ##__VA_ARGS__)
-# define fwinfo(format, ...) ninfo(format, ##__VA_ARGS__)
-# else
-# define fwerr nerr
-# define fwinfo ninfo
-# endif
+# define fwerr nerr
+# define fwinfo ninfo
#else
-# ifdef CONFIG_CPP_HAVE_VARARGS
-# define fwerr(x...)
-# define fwinfo(x...)
-# else
-# define fwerr (void)
-# define fwinfo (void)
-# endif
+# define fwerr _none
+# define fwinfo _none
#endif
#ifndef MIN
diff --git a/system/cle/cle.c b/system/cle/cle.c
index bb39371..f2e0cfd 100644
--- a/system/cle/cle.c
+++ b/system/cle/cle.c
@@ -106,32 +106,16 @@
# define CONFIG_SYSTEM_CLE_DEBUGLEVEL 0
#endif
-#ifdef CONFIG_CPP_HAVE_VARARGS
-# if CONFIG_SYSTEM_CLE_DEBUGLEVEL > 0
-# define cledbg(format, ...) \
- syslog(LOG_DEBUG, EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__)
-# else
-# define cledbg(x...)
-# endif
-
-# if CONFIG_SYSTEM_CLE_DEBUGLEVEL > 1
-# define cleinfo(format, ...) \
- syslog(LOG_DEBUG, EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__)
-# else
-# define cleinfo(x...)
-# endif
+#if CONFIG_SYSTEM_CLE_DEBUGLEVEL > 0
+# define cledbg cle_debug
#else
-# if CONFIG_SYSTEM_CLE_DEBUGLEVEL > 0
-# define cledbg cle_debug
-# else
-# define cledbg (void)
-# endif
-
-# if CONFIG_SYSTEM_CLE_DEBUGLEVEL > 1
-# define cleinfo cle_debug
-# else
-# define cleinfo (void)
-# endif
+# define cledbg _none
+#endif
+
+#if CONFIG_SYSTEM_CLE_DEBUGLEVEL > 1
+# define cleinfo cle_debug
+#else
+# define cleinfo _none
#endif
#ifdef CONFIG_SYSTEM_COLOR_CLE
@@ -182,7 +166,7 @@ struct cle_s
* Private Function Prototypes
****************************************************************************/
-#if !defined(CONFIG_CPP_HAVE_VARARGS) && CONFIG_SYSTEM_CLE_DEBUGLEVEL > 0
+#if CONFIG_SYSTEM_CLE_DEBUGLEVEL > 0
static int cle_debug(FAR const char *fmt, ...);
#endif
@@ -262,7 +246,7 @@ static const char g_setcolor[] = VT100_FMT_FORE_COLOR;
*
****************************************************************************/
-#if !defined(CONFIG_CPP_HAVE_VARARGS) && CONFIG_SYSTEM_CLE_DEBUGLEVEL > 0
+#if CONFIG_SYSTEM_CLE_DEBUGLEVEL > 0
static int cle_debug(FAR const char *fmt, ...)
{
va_list ap;
diff --git a/system/i2c/i2ctool.h b/system/i2c/i2ctool.h
index 3cf7cce..b901135 100644
--- a/system/i2c/i2ctool.h
+++ b/system/i2c/i2ctool.h
@@ -127,11 +127,7 @@
/* Output is via printf but can be changed using this macro */
-#ifdef CONFIG_CPP_HAVE_VARARGS
-# define i2c_output(v, ...) printf(v, ##__VA_ARGS__)
-#else
# define i2c_output printf
-#endif
/****************************************************************************
* Public Types
diff --git a/system/spi/spitool.h b/system/spi/spitool.h
index 211f4ff..e545cb6 100644
--- a/system/spi/spitool.h
+++ b/system/spi/spitool.h
@@ -131,11 +131,7 @@
/* Output is via printf but can be changed using this macro */
-#ifdef CONFIG_CPP_HAVE_VARARGS
-# define spi_output(v, ...) printf(v, ##__VA_ARGS__)
-#else
# define spi_output printf
-#endif
/****************************************************************************
* Public Types
diff --git a/system/vi/vi.c b/system/vi/vi.c
index d6e2927..272a7f3 100644
--- a/system/vi/vi.c
+++ b/system/vi/vi.c
@@ -170,37 +170,21 @@
# define CONFIG_SYSTEM_VI_DEBUGLEVEL 0
#endif
-#ifdef CONFIG_CPP_HAVE_VARARGS
-# if CONFIG_SYSTEM_VI_DEBUGLEVEL > 0
-# define vidbg(format, ...) \
- syslog(LOG_DEBUG, EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__)
-# define vvidbg(format, ap) \
- vsyslog(LOG_DEBUG, format, ap)
-# else
-# define vidbg(x...)
-# define vvidbg(x...)
-# endif
-
-# if CONFIG_SYSTEM_VI_DEBUGLEVEL > 1
-# define viinfo(format, ...) \
- syslog(LOG_DEBUG, EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__)
-# else
-# define viinfo(x...)
-# endif
+#if CONFIG_SYSTEM_VI_DEBUGLEVEL > 0
+# define vidbg(format, ...) \
+ syslog(LOG_DEBUG, EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__)
+# define vvidbg(format, ap) \
+ vsyslog(LOG_DEBUG, format, ap)
#else
-# if CONFIG_SYSTEM_VI_DEBUGLEVEL > 0
-# define vidbg vi_debug
-# define vvidbg vi_vdebug
-# else
-# define vidbg (void)
-# define vvidbg (void)
-# endif
-
-# if CONFIG_SYSTEM_VI_DEBUGLEVEL > 1
-# define viinfo vi_debug
-# else
-# define viinfo (void)
-# endif
+# define vidbg(x...)
+# define vvidbg(x...)
+#endif
+
+#if CONFIG_SYSTEM_VI_DEBUGLEVEL > 1
+# define viinfo(format, ...) \
+ syslog(LOG_DEBUG, EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__)
+#else
+# define viinfo(x...)
#endif
/* Uncomment to enable bottom line debug printing. Useful during yank /
@@ -577,34 +561,6 @@ static const char g_fmtinsert[] = "--INSERT--";
****************************************************************************/
/****************************************************************************
- * Name: vi_vdebug and vi_debug
- *
- * Description:
- * Print a debug message to the syslog
- *
- ****************************************************************************/
-
-#if !defined(CONFIG_CPP_HAVE_VARARGS) && CONFIG_SYSTEM_VI_DEBUGLEVEL > 0
-static inline int vi_vdebug(FAR const char *fmt, va_list ap)
-{
- return vsyslog(LOG_DEBUG, fmt, ap);
-}
-
-static int vi_debug(FAR const char *fmt, ...)
-{
- va_list ap;
- int ret;
-
- /* Let vsyslog do the real work */
-
- va_start(ap, fmt);
- ret = vsyslog(LOG_DEBUG, fmt, ap);
- va_end(ap);
- return ret;
-}
-#endif
-
-/****************************************************************************
* Low-level display and data entry functions
****************************************************************************/
diff --git a/system/zmodem/zm.h b/system/zmodem/zm.h
index d99a281..822f9e9 100644
--- a/system/zmodem/zm.h
+++ b/system/zmodem/zm.h
@@ -230,17 +230,12 @@
*/
#ifdef CONFIG_DEBUG_ZMODEM
-# define zmprintf(format, ...) syslog(LOG_INFO, format, ##__VA_ARGS__)
-# define zmdbg(format, ...) syslog(LOG_INFO, EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__)
+# define zmprintf(format, ...) _info
+# define zmdbg(format, ...) _info
#else
# undef CONFIG_SYSTEM_ZMODEM_DUMPBUFFER
-# ifdef CONFIG_CPP_HAVE_VARARGS
-# define zmprintf(x...)
-# define zmdbg(x...)
-# else
-# define zmprintf (void)
-# define zmdbg (void)
-# endif
+# define zmprintf _none
+# define zmdbg _none
#endif
/****************************************************************************