selftests/nolibc: fix up compile warning with glibc on x86_64
authorZhangjin Wu <falcon@tinylab.org>
Sat, 3 Jun 2023 08:05:30 +0000 (16:05 +0800)
committerPaul E. McKenney <paulmck@kernel.org>
Fri, 9 Jun 2023 18:46:09 +0000 (11:46 -0700)
commit0858aec4359636e539c6f26a1f3c9a3eceb87494
tree26991a05ed8f0690a5bacd282e58374f6b802ba3
parentc88e46d6d63b789bb2d5050e62ec0a0a477d4dfb
selftests/nolibc: fix up compile warning with glibc on x86_64

Compiling nolibc-test.c with gcc on x86_64 got such warning:

tools/testing/selftests/nolibc/nolibc-test.c: In function ‘expect_eq’:
tools/testing/selftests/nolibc/nolibc-test.c:177:24: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 2 has type ‘uint64_t’ {aka ‘long unsigned int’} [-Wformat=]
  177 |  llen += printf(" = %lld ", expr);
      |                     ~~~^    ~~~~
      |                        |    |
      |                        |    uint64_t {aka long unsigned int}
      |                        long long int
      |                     %ld

It because that glibc defines uint64_t as "unsigned long int" when word
size (means sizeof(long)) is 64bit (see include/bits/types.h), but
nolibc directly use the 64bit "unsigned long long" (see
tools/include/nolibc/stdint.h), which is simpler, seems kernel uses it
too (include/uapi/asm-generic/int-ll64.h).

use a simple conversion to solve it.

Suggested-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/linux-riscv/20230529130449.GA2813@1wt.eu/
Signed-off-by: Zhangjin Wu <falcon@tinylab.org>
Reviewed-by: Thomas Weißschuh <linux@weissschuh.net>
Signed-off-by: Willy Tarreau <w@1wt.eu>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
tools/testing/selftests/nolibc/nolibc-test.c