debug: Reduce CONFIG_CPP_HAVE_VARARGS usage

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2020-05-04 18:52:59 +08:00 committed by patacongo
parent 005ef92990
commit 8a1f5ee34c
14 changed files with 110 additions and 300 deletions

View File

@ -105,18 +105,6 @@
* that the output will be synchronous with the debug output. * 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
#else
#ifdef CONFIG_DEBUG_INFO #ifdef CONFIG_DEBUG_INFO
# define message _info # define message _info
#else #else
@ -127,7 +115,6 @@
#else #else
# define errmsg printf # define errmsg printf
#endif #endif
#endif
/**************************************************************************** /****************************************************************************
* Private Data * Private Data

View File

@ -56,45 +56,31 @@
* Could be a porting issue. * Could be a porting issue.
*/ */
#ifdef CONFIG_CPP_HAVE_VARARGS #if !defined(GRAPHICS_FT80X_DEBUG_ERROR)
# ifdef GRAPHICS_FT80X_DEBUG_ERROR # define ft80x_err _none
#elif defined(CONFIG_CPP_HAVE_VARARGS)
# define ft80x_err(format, ...) \ # define ft80x_err(format, ...) \
fprintf(stderr, EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__) fprintf(stderr, EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__)
#else #else
# define ft80x_err(format, ...) # define ft80x_err printf
#endif #endif
# ifdef GRAPHICS_FT80X_DEBUG_WARN #if !defined(GRAPHICS_FT80X_DEBUG_WARN)
# define ft80x_warn _none
#elif defined(CONFIG_CPP_HAVE_VARARGS)
# define ft80x_warn(format, ...) \ # define ft80x_warn(format, ...) \
fprintf(stderr, EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__) fprintf(stderr, EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__)
#else #else
# define ft80x_warn(format, ...) # define ft80x_warn printf
#endif #endif
# ifdef GRAPHICS_FT80X_DEBUG_INFO #if !defined(GRAPHICS_FT80X_DEBUG_INFO)
# define ft80x_info _none
#elif defined(CONFIG_CPP_HAVE_VARARGS)
# define ft80x_info(format, ...) \ # define ft80x_info(format, ...) \
printf(EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__) printf(EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__)
#else #else
# define ft80x_info(format, ...)
# endif
#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 # define ft80x_info printf
# else
# define ft80x_info (void)
# endif
#endif #endif
/**************************************************************************** /****************************************************************************

View File

@ -96,18 +96,6 @@
* that the output will be synchronous with the debug output. * 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
#else
#ifdef CONFIG_DEBUG_INFO #ifdef CONFIG_DEBUG_INFO
# define message _info # define message _info
#else #else
@ -118,7 +106,6 @@
#else #else
# define errmsg printf # define errmsg printf
#endif #endif
#endif
/**************************************************************************** /****************************************************************************
* Private Data * Private Data

View File

@ -96,15 +96,6 @@
* that the output will be synchronous with the debug output. * 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
#else
#ifdef CONFIG_DEBUG_FEATURES #ifdef CONFIG_DEBUG_FEATURES
# define message _info # define message _info
# define errmsg _err # define errmsg _err
@ -112,7 +103,6 @@
# define message printf # define message printf
# define errmsg printf # define errmsg printf
#endif #endif
#endif
/**************************************************************************** /****************************************************************************
* Private Types * Private Types

View File

@ -60,32 +60,22 @@
# define CONFIG_FSUTILS_INIFILE_DEBUGLEVEL 0 # define CONFIG_FSUTILS_INIFILE_DEBUGLEVEL 0
#endif #endif
#ifdef CONFIG_CPP_HAVE_VARARGS #if CONFIG_FSUTILS_INIFILE_DEBUGLEVEL < 1
# if CONFIG_FSUTILS_INIFILE_DEBUGLEVEL > 0 # define inidbg _none
#elif defined(CONFIG_CPP_HAVE_VARARGS)
# define inidbg(format, ...) \ # define inidbg(format, ...) \
printf(EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__) printf(EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__)
#else #else
# define inidbg(x...) # define inidbg printf
#endif #endif
# if CONFIG_FSUTILS_INIFILE_DEBUGLEVEL > 1 #if CONFIG_FSUTILS_INIFILE_DEBUGLEVEL < 2
# define iniinfo _none
#elif defined(CONFIG_CPP_HAVE_VARARGS)
# define iniinfo(format, ...) \ # define iniinfo(format, ...) \
printf(EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__) printf(EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__)
#else #else
# define iniinfo(x...)
# endif
#else
# if CONFIG_FSUTILS_INIFILE_DEBUGLEVEL > 0
# define inidbg printf
# else
# define inidbg (void)
# endif
# if CONFIG_FSUTILS_INIFILE_DEBUGLEVEL > 1
# define iniinfo printf # define iniinfo printf
# else
# define iniinfo (void)
# endif
#endif #endif
/**************************************************************************** /****************************************************************************

View File

@ -57,45 +57,31 @@
* Could be a porting issue. * Could be a porting issue.
*/ */
#ifdef CONFIG_CPP_HAVE_VARARGS #if !defined(CONFIG_GRAPHICS_FT80X_DEBUG_ERROR)
# ifdef CONFIG_GRAPHICS_FT80X_DEBUG_ERROR # define ft80x_err _none
#elif defined(CONFIG_CPP_HAVE_VARARGS)
# define ft80x_err(format, ...) \ # define ft80x_err(format, ...) \
fprintf(stderr, EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__) fprintf(stderr, EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__)
#else #else
# define ft80x_err(format, ...) # define ft80x_err printf
#endif #endif
# ifdef CONFIG_GRAPHICS_FT80X_DEBUG_WARN #if !defined(CONFIG_GRAPHICS_FT80X_DEBUG_WARN)
# define ft80x_warn _none
#elif defined(CONFIG_CPP_HAVE_VARARGS)
# define ft80x_warn(format, ...) \ # define ft80x_warn(format, ...) \
fprintf(stderr, EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__) fprintf(stderr, EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__)
#else #else
# define ft80x_warn(format, ...) # define ft80x_warn printf
#endif #endif
# ifdef CONFIG_GRAPHICS_FT80X_DEBUG_INFO #if !defined(CONFIG_GRAPHICS_FT80X_DEBUG_INFO)
# define ft80x_info _none
#elif defined(CONFIG_CPP_HAVE_VARARGS)
# define ft80x_info(format, ...) \ # define ft80x_info(format, ...) \
printf(EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__) printf(EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__)
#else #else
# define ft80x_info(format, ...)
# endif
#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 # define ft80x_info printf
# else
# define ft80x_info (void)
# endif
#endif #endif
#define FT80X_CMDFIFO_MASK (FT80X_CMDFIFO_SIZE - 1) #define FT80X_CMDFIFO_MASK (FT80X_CMDFIFO_SIZE - 1)

View File

@ -63,20 +63,6 @@
* Pre-Processor Definitions * 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 #define AUDIO_NSUBSAMPLES 4
/******************************************************************************************** /********************************************************************************************

View File

@ -60,25 +60,6 @@
#include "graphics/nxglyphs.hxx" #include "graphics/nxglyphs.hxx"
#include "graphics/nxwm/ctouchscreen.hxx" #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 * CTouchscreen Method Implementations
********************************************************************************************/ ********************************************************************************************/

View File

@ -61,21 +61,11 @@
*/ */
#ifdef CONFIG_THTTPD_FDWATCH_DEBUG #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 fwerr nerr
# define fwinfo ninfo # define fwinfo ninfo
# endif
#else #else
# ifdef CONFIG_CPP_HAVE_VARARGS # define fwerr _none
# define fwerr(x...) # define fwinfo _none
# define fwinfo(x...)
# else
# define fwerr (void)
# define fwinfo (void)
# endif
#endif #endif
#ifndef MIN #ifndef MIN

View File

@ -106,32 +106,16 @@
# define CONFIG_SYSTEM_CLE_DEBUGLEVEL 0 # define CONFIG_SYSTEM_CLE_DEBUGLEVEL 0
#endif #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
#else
#if CONFIG_SYSTEM_CLE_DEBUGLEVEL > 0 #if CONFIG_SYSTEM_CLE_DEBUGLEVEL > 0
# define cledbg cle_debug # define cledbg cle_debug
#else #else
# define cledbg (void) # define cledbg _none
#endif #endif
#if CONFIG_SYSTEM_CLE_DEBUGLEVEL > 1 #if CONFIG_SYSTEM_CLE_DEBUGLEVEL > 1
# define cleinfo cle_debug # define cleinfo cle_debug
#else #else
# define cleinfo (void) # define cleinfo _none
# endif
#endif #endif
#ifdef CONFIG_SYSTEM_COLOR_CLE #ifdef CONFIG_SYSTEM_COLOR_CLE
@ -182,7 +166,7 @@ struct cle_s
* Private Function Prototypes * 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, ...); static int cle_debug(FAR const char *fmt, ...);
#endif #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, ...) static int cle_debug(FAR const char *fmt, ...)
{ {
va_list ap; va_list ap;

View File

@ -127,11 +127,7 @@
/* Output is via printf but can be changed using this macro */ /* 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 # define i2c_output printf
#endif
/**************************************************************************** /****************************************************************************
* Public Types * Public Types

View File

@ -131,11 +131,7 @@
/* Output is via printf but can be changed using this macro */ /* 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 # define spi_output printf
#endif
/**************************************************************************** /****************************************************************************
* Public Types * Public Types

View File

@ -170,7 +170,6 @@
# define CONFIG_SYSTEM_VI_DEBUGLEVEL 0 # define CONFIG_SYSTEM_VI_DEBUGLEVEL 0
#endif #endif
#ifdef CONFIG_CPP_HAVE_VARARGS
#if CONFIG_SYSTEM_VI_DEBUGLEVEL > 0 #if CONFIG_SYSTEM_VI_DEBUGLEVEL > 0
# define vidbg(format, ...) \ # define vidbg(format, ...) \
syslog(LOG_DEBUG, EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__) syslog(LOG_DEBUG, EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__)
@ -187,21 +186,6 @@
#else #else
# define viinfo(x...) # define viinfo(x...)
#endif #endif
#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
#endif
/* Uncomment to enable bottom line debug printing. Useful during yank / /* Uncomment to enable bottom line debug printing. Useful during yank /
* paste debugging, etc. * paste debugging, etc.
@ -576,34 +560,6 @@ static const char g_fmtinsert[] = "--INSERT--";
* Private Functions * Private Functions
****************************************************************************/ ****************************************************************************/
/****************************************************************************
* 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 * Low-level display and data entry functions
****************************************************************************/ ****************************************************************************/

View File

@ -230,17 +230,12 @@
*/ */
#ifdef CONFIG_DEBUG_ZMODEM #ifdef CONFIG_DEBUG_ZMODEM
# define zmprintf(format, ...) syslog(LOG_INFO, format, ##__VA_ARGS__) # define zmprintf(format, ...) _info
# define zmdbg(format, ...) syslog(LOG_INFO, EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__) # define zmdbg(format, ...) _info
#else #else
# undef CONFIG_SYSTEM_ZMODEM_DUMPBUFFER # undef CONFIG_SYSTEM_ZMODEM_DUMPBUFFER
# ifdef CONFIG_CPP_HAVE_VARARGS # define zmprintf _none
# define zmprintf(x...) # define zmdbg _none
# define zmdbg(x...)
# else
# define zmprintf (void)
# define zmdbg (void)
# endif
#endif #endif
/**************************************************************************** /****************************************************************************