From: Zhangjin Wu <falcon@tinylab.org> To: w@1wt.eu Cc: falcon@tinylab.org, arnd@arndb.de, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org, thomas@t-8ch.de Subject: [PATCH v3 04/12] selftests/nolibc: fix up compile warning with glibc on x86_64 Date: Sat, 3 Jun 2023 16:05:30 +0800 [thread overview] Message-ID: <0626464891e7fc938e6f7a55f1f475f31fbc6f37.1685777982.git.falcon@tinylab.org> (raw) In-Reply-To: <cover.1685777982.git.falcon@tinylab.org> 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> --- tools/testing/selftests/nolibc/nolibc-test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index d417ca5d976f..403f6255c177 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -174,7 +174,7 @@ static int expect_eq(uint64_t expr, int llen, uint64_t val) { int ret = !(expr == val); - llen += printf(" = %lld ", expr); + llen += printf(" = %lld ", (long long)expr); pad_spc(llen, 64, ret ? "[FAIL]\n" : " [OK]\n"); return ret; } -- 2.25.1
WARNING: multiple messages have this Message-ID (diff)
From: Zhangjin Wu <falcon@tinylab.org> To: w@1wt.eu Cc: falcon@tinylab.org, arnd@arndb.de, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org, thomas@t-8ch.de Subject: [PATCH v3 04/12] selftests/nolibc: fix up compile warning with glibc on x86_64 Date: Sat, 3 Jun 2023 16:05:30 +0800 [thread overview] Message-ID: <0626464891e7fc938e6f7a55f1f475f31fbc6f37.1685777982.git.falcon@tinylab.org> (raw) In-Reply-To: <cover.1685777982.git.falcon@tinylab.org> 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> --- tools/testing/selftests/nolibc/nolibc-test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index d417ca5d976f..403f6255c177 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -174,7 +174,7 @@ static int expect_eq(uint64_t expr, int llen, uint64_t val) { int ret = !(expr == val); - llen += printf(" = %lld ", expr); + llen += printf(" = %lld ", (long long)expr); pad_spc(llen, 64, ret ? "[FAIL]\n" : " [OK]\n"); return ret; } -- 2.25.1 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2023-06-03 8:06 UTC|newest] Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-06-03 7:59 [PATCH v3 00/12] nolibc: add generic part1 of prepare for rv32 Zhangjin Wu 2023-06-03 7:59 ` Zhangjin Wu 2023-06-03 8:00 ` [PATCH v3 01/12] selftests/nolibc: syscall_args: use generic __NR_statx Zhangjin Wu 2023-06-03 8:00 ` Zhangjin Wu 2023-06-03 8:02 ` [PATCH v3 02/12] tools/nolibc: add missing nanoseconds support for __NR_statx Zhangjin Wu 2023-06-03 8:02 ` Zhangjin Wu 2023-06-04 11:18 ` Willy Tarreau 2023-06-04 11:18 ` Willy Tarreau 2023-06-04 12:00 ` Thomas Weißschuh 2023-06-04 12:00 ` Thomas Weißschuh 2023-06-04 12:53 ` Willy Tarreau 2023-06-04 12:53 ` Willy Tarreau 2023-06-03 8:04 ` [PATCH v3 03/12] selftests/nolibc: allow specify extra arguments for qemu Zhangjin Wu 2023-06-03 8:04 ` Zhangjin Wu 2023-06-03 8:05 ` Zhangjin Wu [this message] 2023-06-03 8:05 ` [PATCH v3 04/12] selftests/nolibc: fix up compile warning with glibc on x86_64 Zhangjin Wu 2023-06-03 8:06 ` [PATCH v3 05/12] selftests/nolibc: not include limits.h for nolibc Zhangjin Wu 2023-06-03 8:06 ` Zhangjin Wu 2023-06-03 8:08 ` [PATCH v3 06/12] selftests/nolibc: use INT_MAX instead of __INT_MAX__ Zhangjin Wu 2023-06-03 8:08 ` Zhangjin Wu 2023-06-03 8:09 ` [PATCH v3 07/12] tools/nolibc: arm: add missing my_syscall6 Zhangjin Wu 2023-06-03 8:09 ` Zhangjin Wu 2023-06-03 8:11 ` [PATCH v3 08/12] tools/nolibc: open: fix up compile warning for arm Zhangjin Wu 2023-06-03 8:11 ` Zhangjin Wu 2023-06-03 8:13 ` [PATCH v3 09/12] selftests/nolibc: support two errnos with EXPECT_SYSER2() Zhangjin Wu 2023-06-03 8:13 ` Zhangjin Wu 2023-06-03 8:14 ` [PATCH v3 10/12] selftests/nolibc: remove gettimeofday_bad1/2 completely Zhangjin Wu 2023-06-03 8:14 ` Zhangjin Wu 2023-06-03 8:16 ` [PATCH v3 11/12] selftests/nolibc: add new gettimeofday test cases Zhangjin Wu 2023-06-03 8:16 ` Zhangjin Wu 2023-06-04 6:46 ` Thomas Weißschuh 2023-06-04 6:46 ` Thomas Weißschuh [not found] ` <tencent_4668A50A08C3D31E7531619E@qq.com> 2023-06-04 9:24 ` Arnd Bergmann 2023-06-04 9:24 ` Arnd Bergmann 2023-06-04 11:27 ` Willy Tarreau 2023-06-04 11:27 ` Willy Tarreau 2023-06-04 11:38 ` Arnd Bergmann 2023-06-04 11:38 ` Arnd Bergmann 2023-06-04 11:46 ` Willy Tarreau 2023-06-04 11:46 ` Willy Tarreau 2023-06-05 11:12 ` Zhangjin Wu 2023-06-05 11:12 ` Zhangjin Wu 2023-06-03 8:17 ` [PATCH v3 12/12] selftests/nolibc: test_fork: fix up duplicated print Zhangjin Wu 2023-06-03 8:17 ` Zhangjin Wu 2023-06-04 6:49 ` [PATCH v3 00/12] nolibc: add generic part1 of prepare for rv32 Thomas Weißschuh 2023-06-04 6:49 ` Thomas Weißschuh 2023-06-04 12:54 ` Willy Tarreau 2023-06-04 12:54 ` Willy Tarreau
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=0626464891e7fc938e6f7a55f1f475f31fbc6f37.1685777982.git.falcon@tinylab.org \ --to=falcon@tinylab.org \ --cc=arnd@arndb.de \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-kselftest@vger.kernel.org \ --cc=linux-riscv@lists.infradead.org \ --cc=thomas@t-8ch.de \ --cc=w@1wt.eu \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.