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
examples
fsutils/inifile
graphics
netutils/thttpd
system

@ -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
/****************************************************************************

@ -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
# define ft80x_err printf
#endif
# ifdef GRAPHICS_FT80X_DEBUG_WARN
# define ft80x_warn printf
# else
# define ft80x_warn (void)
# 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
# ifdef GRAPHICS_FT80X_DEBUG_INFO
# define ft80x_info printf
# else
# define ft80x_info (void)
# 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
/****************************************************************************

@ -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
/****************************************************************************

@ -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
/****************************************************************************

@ -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
# define inidbg printf
#endif
# if CONFIG_FSUTILS_INIFILE_DEBUGLEVEL > 1
# define iniinfo printf
# else
# define iniinfo (void)
# 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
/****************************************************************************

@ -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
# define ft80x_err printf
#endif
# ifdef CONFIG_GRAPHICS_FT80X_DEBUG_WARN
# define ft80x_warn printf
# else
# define ft80x_warn (void)
# 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
# ifdef CONFIG_GRAPHICS_FT80X_DEBUG_INFO
# define ft80x_info printf
# else
# define ft80x_info (void)
# 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)

@ -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
/********************************************************************************************

@ -60,25 +60,6 @@
#include "graphics/nxglyphs.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
********************************************************************************************/

@ -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

@ -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
# define cledbg _none
#endif
# if CONFIG_SYSTEM_CLE_DEBUGLEVEL > 1
# define cleinfo cle_debug
# else
# define cleinfo (void)
# 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;

@ -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

@ -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

@ -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
# define vidbg(x...)
# define vvidbg(x...)
#endif
# if CONFIG_SYSTEM_VI_DEBUGLEVEL > 1
# define viinfo vi_debug
# else
# define viinfo (void)
# 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 /
@ -576,34 +560,6 @@ static const char g_fmtinsert[] = "--INSERT--";
* 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
****************************************************************************/

@ -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
/****************************************************************************