Skip to content

Commit 9b1d9ab

Browse files
Merge patch series "tools: selftests: riscv: Fix compiler warnings"
Christoph Muellner <christoph.muellner@vrull.eu> says: From: Christoph Müllner <christoph.muellner@vrull.eu> When building the RISC-V selftests with a riscv32 compiler I ran into a couple of compiler warnings. While riscv32 support for these tests is questionable, the fixes are so trivial that it is probably best to simply apply them. Note that the missing-include patch and some format string warnings are also relevant for riscv64. * b4-shazam-merge: tools: selftests: riscv: Fix compile warnings in mm tests tools: selftests: riscv: Fix compile warnings in vector tests tools: selftests: riscv: Add missing include for vector test tools: selftests: riscv: Fix compile warnings in cbo tools: selftests: riscv: Fix compile warnings in hwprobe Link: https://lore.kernel.org/r/20231123185821.2272504-1-christoph.muellner@vrull.eu Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
2 parents 54d7431 + 12c1691 commit 9b1d9ab

File tree

6 files changed

+14
-8
lines changed

6 files changed

+14
-8
lines changed

tools/testing/selftests/riscv/hwprobe/cbo.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ static void test_zicboz(void *arg)
9797
block_size = pair.value;
9898
ksft_test_result(rc == 0 && pair.key == RISCV_HWPROBE_KEY_ZICBOZ_BLOCK_SIZE &&
9999
is_power_of_2(block_size), "Zicboz block size\n");
100-
ksft_print_msg("Zicboz block size: %ld\n", block_size);
100+
ksft_print_msg("Zicboz block size: %llu\n", block_size);
101101

102102
illegal_insn = false;
103103
cbo_zero(&mem[block_size]);
@@ -121,7 +121,7 @@ static void test_zicboz(void *arg)
121121
for (j = 0; j < block_size; ++j) {
122122
if (mem[i * block_size + j] != expected) {
123123
ksft_test_result_fail("cbo.zero check\n");
124-
ksft_print_msg("cbo.zero check: mem[%d] != 0x%x\n",
124+
ksft_print_msg("cbo.zero check: mem[%llu] != 0x%x\n",
125125
i * block_size + j, expected);
126126
return;
127127
}
@@ -201,7 +201,7 @@ int main(int argc, char **argv)
201201
pair.key = RISCV_HWPROBE_KEY_IMA_EXT_0;
202202
rc = riscv_hwprobe(&pair, 1, sizeof(cpu_set_t), (unsigned long *)&cpus, 0);
203203
if (rc < 0)
204-
ksft_exit_fail_msg("hwprobe() failed with %d\n", rc);
204+
ksft_exit_fail_msg("hwprobe() failed with %ld\n", rc);
205205
assert(rc == 0 && pair.key == RISCV_HWPROBE_KEY_IMA_EXT_0);
206206

207207
if (pair.value & RISCV_HWPROBE_EXT_ZICBOZ) {

tools/testing/selftests/riscv/hwprobe/hwprobe.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ int main(int argc, char **argv)
2929
/* Fail if the kernel claims not to recognize a base key. */
3030
if ((i < 4) && (pairs[i].key != i))
3131
ksft_exit_fail_msg("Failed to recognize base key: key != i, "
32-
"key=%ld, i=%ld\n", pairs[i].key, i);
32+
"key=%lld, i=%ld\n", pairs[i].key, i);
3333

3434
if (pairs[i].key != RISCV_HWPROBE_KEY_BASE_BEHAVIOR)
3535
continue;
3636

3737
if (pairs[i].value & RISCV_HWPROBE_BASE_BEHAVIOR_IMA)
3838
continue;
3939

40-
ksft_exit_fail_msg("Unexpected pair: (%ld, %ld)\n", pairs[i].key, pairs[i].value);
40+
ksft_exit_fail_msg("Unexpected pair: (%lld, %llu)\n", pairs[i].key, pairs[i].value);
4141
}
4242

4343
out = riscv_hwprobe(pairs, 8, 0, 0, 0);

tools/testing/selftests/riscv/mm/mmap_test.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ struct addresses {
1818
int *on_56_addr;
1919
};
2020

21+
// Only works on 64 bit
22+
#if __riscv_xlen == 64
2123
static inline void do_mmaps(struct addresses *mmap_addresses)
2224
{
2325
/*
@@ -50,6 +52,7 @@ static inline void do_mmaps(struct addresses *mmap_addresses)
5052
mmap_addresses->on_56_addr =
5153
mmap(on_56_bits, 5 * sizeof(int), prot, flags, 0, 0);
5254
}
55+
#endif /* __riscv_xlen == 64 */
5356

5457
static inline int memory_layout(void)
5558
{

tools/testing/selftests/riscv/vector/v_initval_nolibc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ int main(void)
2727

2828
datap = malloc(MAX_VSIZE);
2929
if (!datap) {
30-
ksft_test_result_fail("fail to allocate memory for size = %lu\n", MAX_VSIZE);
30+
ksft_test_result_fail("fail to allocate memory for size = %d\n", MAX_VSIZE);
3131
exit(-1);
3232
}
3333

tools/testing/selftests/riscv/vector/vstate_exec_nolibc.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
// SPDX-License-Identifier: GPL-2.0-only
2+
3+
#include <linux/wait.h>
4+
25
#define THIS_PROGRAM "./vstate_exec_nolibc"
36

47
int main(int argc, char **argv)

tools/testing/selftests/riscv/vector/vstate_prctl.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ int test_and_compare_child(long provided, long expected, int inherit)
6060
}
6161
rc = launch_test(inherit);
6262
if (rc != expected) {
63-
ksft_test_result_fail("Test failed, check %d != %d\n", rc,
63+
ksft_test_result_fail("Test failed, check %d != %ld\n", rc,
6464
expected);
6565
return -2;
6666
}
@@ -79,7 +79,7 @@ int main(void)
7979
pair.key = RISCV_HWPROBE_KEY_IMA_EXT_0;
8080
rc = riscv_hwprobe(&pair, 1, 0, NULL, 0);
8181
if (rc < 0) {
82-
ksft_test_result_fail("hwprobe() failed with %d\n", rc);
82+
ksft_test_result_fail("hwprobe() failed with %ld\n", rc);
8383
return -1;
8484
}
8585

0 commit comments

Comments
 (0)