Skip to content

Commit 12c1691

Browse files
cmuellnerpalmer-dabbelt
authored andcommitted
tools: selftests: riscv: Fix compile warnings in mm tests
When building the mm tests with a riscv32 compiler, we see a range of shift-count-overflow errors from shifting 1UL by more than 32 bits in do_mmaps(). Since, the relevant code is only called from code that is gated by `__riscv_xlen == 64`, we can just apply the same gating to do_mmaps(). Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu> Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com> Reviewed-by: Andrew Jones <ajones@ventanamicro.com> Link: https://lore.kernel.org/r/20231123185821.2272504-6-christoph.muellner@vrull.eu Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
1 parent e1baf5e commit 12c1691

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

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
{

0 commit comments

Comments
 (0)