From e7ed5b455e9407b486801bb1429bd583051eebd9 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Wed, 9 Oct 2019 12:12:38 -0400 Subject: [PATCH] Fix: fix wint_t warning on MSYS2/mingw We get the following warning when compiling on Windows: common.c: In function 'handle_conversion_specifier_std': common.c:1419:30: warning: 'wint_t' {aka 'short unsigned int'} is promoted to 'int' when passed through '...' 1419 | BUF_STD_APPEND_SINGLE_ARG(wint_t); | ^ common.c:1419:4: note: in expansion of macro 'BUF_STD_APPEND_SINGLE_ARG' 1419 | BUF_STD_APPEND_SINGLE_ARG(wint_t); | ^~~~~~~~~~~~~~~~~~~~~~~~~ common.c:1419:30: note: (so you should pass 'int' not 'wint_t' {aka 'short unsigned int'} to 'va_arg') 1419 | BUF_STD_APPEND_SINGLE_ARG(wint_t); | ^ When expanded, this problematic macro usage contains: wint_t _arg = va_arg(*args, wint_t); I think the suggestion of passing `int`, not `wint_t` makes sense. This is because any integral argument smaller than an int would have already been promoted to int when passed to the variable arguments function that eventually called handle_conversion_specifier_std. So it makes sense to fetch this variable as an int. We don't see this warning on x86-64 Linux because there, sizeof(wint_t) is 4, the same as an int. Change-Id: Ia1519b15a56a58022254be98597c1f3e020db9b9 Signed-off-by: Simon Marchi Reviewed-on: https://review.lttng.org/c/babeltrace/+/2160 Reviewed-by: Francis Deslauriers --- src/common/common.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/common/common.c b/src/common/common.c index c8890cd2..2616da25 100644 --- a/src/common/common.c +++ b/src/common/common.c @@ -1413,10 +1413,8 @@ static inline void handle_conversion_specifier_std(char *buf, char **buf_ch, switch (length_mod) { case LENGTH_MOD_NONE: - BUF_STD_APPEND_SINGLE_ARG(int); - break; case LENGTH_MOD_LOW_L: - BUF_STD_APPEND_SINGLE_ARG(wint_t); + BUF_STD_APPEND_SINGLE_ARG(int); break; default: abort(); -- 2.34.1