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)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 17 Oct 2019 16:13:26 +0000 (12:13 -0400)
commite7ed5b455e9407b486801bb1429bd583051eebd9
tree147b6c824ce0534008c0b8339207d2fbab35cd23
parent9e66042849916de18474fd7a98a73f017c2923f7
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.024603 seconds and 4 git commands to generate.