X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=include%2Flttngerr.h;h=1feb6cc4ded1ba9ad9e7fb7a04db46cb43790449;hb=471d16937e160d99382c633db37d89605f483556;hp=c987fdd6141f92ad2da633e701d0deea0f3d4231;hpb=826d496db7f18f2ae1f7e0d2f4fc381144ed04a4;p=lttng-tools.git diff --git a/include/lttngerr.h b/include/lttngerr.h index c987fdd61..1feb6cc4d 100644 --- a/include/lttngerr.h +++ b/include/lttngerr.h @@ -20,7 +20,7 @@ #define _LTTNGERR_H #include -#include +#include extern int opt_quiet; extern int opt_verbose; @@ -36,24 +36,19 @@ enum __lttng_print_type { /* * __lttng_print * - * Internal function for printing message - * depending on command line option and verbosity. + * Macro for printing message depending on + * command line option and verbosity. */ -void __lttng_print(enum __lttng_print_type type, const char *fmt, ...) -{ - va_list ap; - va_start(ap, fmt); - - if (opt_quiet == 0) { - if (type == PRINT_MSG || (opt_verbose && type == PRINT_DBG)) { - vfprintf(stdout, fmt, ap); - } else if (type != PRINT_MSG && type != PRINT_DBG) { - vfprintf(stderr, fmt, ap); - } - } - - va_end(ap); -} +#define __lttng_print(type, fmt, args...) \ + do { \ + if (opt_quiet == 0) { \ + if (type == PRINT_MSG || (opt_verbose && type == PRINT_DBG)) { \ + fprintf(stdout, fmt, ## args); \ + } else if (type != PRINT_MSG && type != PRINT_DBG) { \ + fprintf(stderr, fmt, ## args); \ + } \ + } \ + } while (0); #define MSG(fmt, args...) __lttng_print(PRINT_MSG, fmt "\n", ## args) #define ERR(fmt, args...) __lttng_print(PRINT_ERR, "Error: " fmt "\n", ## args)