aboutsummaryrefslogtreecommitdiff
path: root/slirp/debug.h
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2018-11-14 16:36:31 +0400
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2019-01-14 00:43:30 +0100
commit2afbb788ff43c5cb5a91fb3da9cae6bd9a70731f (patch)
tree82ef676d69fd01861496a6efaaab8b86706c3337 /slirp/debug.h
parent90dfa2784164d1210ba95de462ce0f3b1030a698 (diff)
slirp: improve a bit the debug macros
Let them accept multiple arguments. Simplify the inner argument handling of DEBUG_ARGS/DEBUG_MISC_DEBUG_ERROR. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Diffstat (limited to 'slirp/debug.h')
-rw-r--r--slirp/debug.h47
1 files changed, 37 insertions, 10 deletions
diff --git a/slirp/debug.h b/slirp/debug.h
index 6cfa61edb3..ca3a4b04da 100644
--- a/slirp/debug.h
+++ b/slirp/debug.h
@@ -17,18 +17,45 @@
extern int slirp_debug;
-#define DEBUG_CALL(x) if (slirp_debug & DBG_CALL) { fprintf(dfd, "%s...\n", x); fflush(dfd); }
-#define DEBUG_ARG(x, y) if (slirp_debug & DBG_CALL) { fputc(' ', dfd); fprintf(dfd, x, y); fputc('\n', dfd); fflush(dfd); }
-#define DEBUG_ARGS(x) if (slirp_debug & DBG_CALL) { fprintf x ; fflush(dfd); }
-#define DEBUG_MISC(x) if (slirp_debug & DBG_MISC) { fprintf x ; fflush(dfd); }
-#define DEBUG_ERROR(x) if (slirp_debug & DBG_ERROR) {fprintf x ; fflush(dfd); }
+#define DEBUG_CALL(fmt, ...) do { \
+ if (slirp_debug & DBG_CALL) { \
+ fprintf(dfd, fmt, ##__VA_ARGS__); \
+ fprintf(dfd, "...\n"); \
+ fflush(dfd); \
+ } \
+} while (0)
+
+#define DEBUG_ARG(fmt, ...) do { \
+ if (slirp_debug & DBG_CALL) { \
+ fputc(' ', dfd); \
+ fprintf(dfd, fmt, ##__VA_ARGS__); \
+ fputc('\n', dfd); \
+ fflush(dfd); \
+ } \
+} while (0)
+
+#define DEBUG_ARGS(fmt, ...) DEBUG_ARG(fmt, ##__VA_ARGS__)
+
+#define DEBUG_MISC(fmt, ...) do { \
+ if (slirp_debug & DBG_MISC) { \
+ fprintf(dfd, fmt, ##__VA_ARGS__); \
+ fflush(dfd); \
+ } \
+} while (0)
+
+#define DEBUG_ERROR(fmt, ...) do { \
+ if (slirp_debug & DBG_ERROR) { \
+ fprintf(dfd, fmt, ##__VA_ARGS__); \
+ fflush(dfd); \
+ } \
+} while (0)
#else
-#define DEBUG_CALL(x)
-#define DEBUG_ARG(x, y)
-#define DEBUG_ARGS(x)
-#define DEBUG_MISC(x)
-#define DEBUG_ERROR(x)
+#define DEBUG_CALL(fmt, ...)
+#define DEBUG_ARG(fmt, ...)
+#define DEBUG_ARGS(fmt, ...)
+#define DEBUG_MISC(fmt, ...)
+#define DEBUG_ERROR(fmt, ...)
#endif