Fix: fix wint_t warning on MSYS2/mingw
authorSimon Marchi <simon.marchi@efficios.com>
Wed, 9 Oct 2019 16:12:38 +0000 (12:12 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Wed, 9 Oct 2019 18:31:16 +0000 (14:31 -0400)
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 <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2160
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
src/common/common.c

index c8890cd2cab5748690d8951fb4fea9aab3ce795d..2616da2596afd87d6158c4c0cd0c457ab256b4b1 100644 (file)
@@ -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();
This page took 0.025208 seconds and 4 git commands to generate.