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)
commit81a26b7c6dc1dd6758f20afde5901fd80566d57f
treec797ad578b29b8f29208275c6a5a77949b98eaf7
parent70384700489f2a26e4ddec4aaa6bd483f8820e32
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 <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
This page took 0.025047 seconds and 4 git commands to generate.