From 996e8cbb0c0f94fbbd8662d4ee80b599f6cb0020 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sat, 14 May 2022 20:09:49 +0200 Subject: Avoid using ##__VA_ARGS__ gcc extension --- src/bootp.c | 2 +- src/debug.h | 31 +++++++++++++++++++------------ src/slirp.c | 2 +- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/src/bootp.c b/src/bootp.c index a0eb17a..147955f 100644 --- a/src/bootp.c +++ b/src/bootp.c @@ -38,7 +38,7 @@ static const uint8_t rfc1533_cookie[] = { RFC1533_COOKIE }; -#define DPRINTF(fmt, ...) DEBUG_CALL(fmt, ##__VA_ARGS__) +#define DPRINTF(...) DEBUG_RAW_CALL(__VA_ARGS__) static BOOTPClient *get_new_addr(Slirp *slirp, struct in_addr *paddr, const uint8_t *macaddr) diff --git a/src/debug.h b/src/debug.h index 0f9f3ef..f4da00c 100644 --- a/src/debug.h +++ b/src/debug.h @@ -14,45 +14,52 @@ extern int slirp_debug; -#define DEBUG_CALL(fmt, ...) \ +#define DEBUG_CALL(name) \ do { \ if (G_UNLIKELY(slirp_debug & DBG_CALL)) { \ - g_debug(fmt "...", ##__VA_ARGS__); \ + g_debug(name "..."); \ } \ } while (0) -#define DEBUG_VERBOSE_CALL(fmt, ...) \ +#define DEBUG_VERBOSE_CALL(name) \ do { \ if (G_UNLIKELY(slirp_debug & DBG_VERBOSE_CALL)) { \ - g_debug(fmt "...", ##__VA_ARGS__); \ + g_debug(name "..."); \ } \ } while (0) -#define DEBUG_ARG(fmt, ...) \ +#define DEBUG_RAW_CALL(...) \ do { \ if (G_UNLIKELY(slirp_debug & DBG_CALL)) { \ - g_debug(" " fmt, ##__VA_ARGS__); \ + g_debug(__VA_ARGS__); \ } \ } while (0) -#define DEBUG_MISC(fmt, ...) \ +#define DEBUG_ARG(...) \ + do { \ + if (G_UNLIKELY(slirp_debug & DBG_CALL)) { \ + g_debug(" " __VA_ARGS__); \ + } \ + } while (0) + +#define DEBUG_MISC(...) \ do { \ if (G_UNLIKELY(slirp_debug & DBG_MISC)) { \ - g_debug(fmt, ##__VA_ARGS__); \ + g_debug(__VA_ARGS__); \ } \ } while (0) -#define DEBUG_ERROR(fmt, ...) \ +#define DEBUG_ERROR(...) \ do { \ if (G_UNLIKELY(slirp_debug & DBG_ERROR)) { \ - g_debug(fmt, ##__VA_ARGS__); \ + g_debug(__VA_ARGS__); \ } \ } while (0) -#define DEBUG_TFTP(fmt, ...) \ +#define DEBUG_TFTP(...) \ do { \ if (G_UNLIKELY(slirp_debug & DBG_TFTP)) { \ - g_debug(fmt, ##__VA_ARGS__); \ + g_debug(__VA_ARGS__); \ } \ } while (0) diff --git a/src/slirp.c b/src/slirp.c index 25051f9..0e95e91 100644 --- a/src/slirp.c +++ b/src/slirp.c @@ -158,7 +158,7 @@ static void print_dns_v6_address(struct in6_addr address) DEBUG_ERROR("Failed to stringify IPv6 address for logging."); return; } - DEBUG_CALL("IPv6 DNS server found: %s", address_str); + DEBUG_RAW_CALL("IPv6 DNS server found: %s", address_str); } // Gets the first valid DNS resolver with an IPv6 address. -- cgit v1.1