]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
selftests/bpf: Fix test_progs compilation failure in 32-bit arch
authorYang Jihong <yangjihong1@huawei.com>
Tue, 8 Nov 2022 01:58:57 +0000 (09:58 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 26 Nov 2022 08:27:30 +0000 (09:27 +0100)
[ Upstream commit 5704bc7e8991164b14efb748b5afa0715c25fac3 ]

test_progs fails to be compiled in the 32-bit arch, log is as follows:

  test_progs.c:1013:52: error: format '%ld' expects argument of type 'long int', but argument 3 has type 'size_t' {aka 'unsigned int'} [-Werror=format=]
   1013 |                 sprintf(buf, "MSG_TEST_LOG (cnt: %ld, last: %d)",
        |                                                  ~~^
        |                                                    |
        |                                                    long int
        |                                                  %d
   1014 |                         strlen(msg->test_log.log_buf),
        |                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        |                         |
        |                         size_t {aka unsigned int}

Fix it.

Fixes: 91b2c0afd00c ("selftests/bpf: Add parallelism to test_progs")
Signed-off-by: Yang Jihong <yangjihong1@huawei.com>
Acked-by: Yonghong Song <yhs@fb.com>
Link: https://lore.kernel.org/r/20221108015857.132457-1-yangjihong1@huawei.com
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
tools/testing/selftests/bpf/test_progs.c

index 3561c97701f24a194914c2ff8839b80219a238e6..a07b8ae64bf839e5941d134ab0f3d5721a4aa5c7 100644 (file)
@@ -993,7 +993,7 @@ static inline const char *str_msg(const struct msg *msg, char *buf)
                        msg->subtest_done.have_log);
                break;
        case MSG_TEST_LOG:
-               sprintf(buf, "MSG_TEST_LOG (cnt: %ld, last: %d)",
+               sprintf(buf, "MSG_TEST_LOG (cnt: %zu, last: %d)",
                        strlen(msg->test_log.log_buf),
                        msg->test_log.is_last);
                break;