mbox series

[0/5] tools: selftests: riscv: Fix compiler warnings

Message ID 20231123185821.2272504-1-christoph.muellner@vrull.eu
Headers show
Series tools: selftests: riscv: Fix compiler warnings | expand

Message

Christoph Müllner Nov. 23, 2023, 6:58 p.m. UTC
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.

Christoph Müllner (5):
  tools: selftests: riscv: Fix compile warnings in hwprobe
  tools: selftests: riscv: Fix compile warnings in cbo
  tools: selftests: riscv: Add missing include for vector test
  tools: selftests: riscv: Fix compile warnings in vector tests
  tools: selftests: riscv: Fix compile warnings in mm tests

 tools/testing/selftests/riscv/hwprobe/cbo.c               | 6 +++---
 tools/testing/selftests/riscv/hwprobe/hwprobe.c           | 4 ++--
 tools/testing/selftests/riscv/mm/mmap_test.h              | 3 +++
 tools/testing/selftests/riscv/vector/v_initval_nolibc.c   | 2 +-
 tools/testing/selftests/riscv/vector/vstate_exec_nolibc.c | 3 +++
 tools/testing/selftests/riscv/vector/vstate_prctl.c       | 4 ++--
 6 files changed, 14 insertions(+), 8 deletions(-)

Comments

Christoph Müllner Dec. 15, 2023, 10:02 a.m. UTC | #1
Ping.
It would be great to have these compiler warnings fixed before the release.

On Fri, Nov 24, 2023 at 10:40 AM Andrew Jones <ajones@ventanamicro.com> wrote:
>
> On Thu, Nov 23, 2023 at 07:58:16PM +0100, Christoph Muellner wrote:
> > 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.
>
> I also posted [1] a couple days ago for the format warnings, but, as this
> series also includes rv32 fixes, then we can drop [1] in favor of this.
>
> [1] https://lore.kernel.org/all/20231122171821.130854-2-ajones@ventanamicro.com/
>
> For the series,
>
> Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
>
> Thanks,
> drew
Alexandre Ghiti Dec. 15, 2023, 1:41 p.m. UTC | #2
On 23/11/2023 19:58, Christoph Muellner wrote:
> From: Christoph Müllner <christoph.muellner@vrull.eu>
>
> GCC prints a couple of format string warnings when compiling
> the hwprobe test. Let's follow the recommendation in
> Documentation/printk-formats.txt to fix these warnings.
>
> Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
> ---
>   tools/testing/selftests/riscv/hwprobe/hwprobe.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/riscv/hwprobe/hwprobe.c b/tools/testing/selftests/riscv/hwprobe/hwprobe.c
> index c474891df307..abb825811c70 100644
> --- a/tools/testing/selftests/riscv/hwprobe/hwprobe.c
> +++ b/tools/testing/selftests/riscv/hwprobe/hwprobe.c
> @@ -29,7 +29,7 @@ int main(int argc, char **argv)
>   		/* Fail if the kernel claims not to recognize a base key. */
>   		if ((i < 4) && (pairs[i].key != i))
>   			ksft_exit_fail_msg("Failed to recognize base key: key != i, "
> -					   "key=%ld, i=%ld\n", pairs[i].key, i);
> +					   "key=%lld, i=%ld\n", pairs[i].key, i);
>   
>   		if (pairs[i].key != RISCV_HWPROBE_KEY_BASE_BEHAVIOR)
>   			continue;
> @@ -37,7 +37,7 @@ int main(int argc, char **argv)
>   		if (pairs[i].value & RISCV_HWPROBE_BASE_BEHAVIOR_IMA)
>   			continue;
>   
> -		ksft_exit_fail_msg("Unexpected pair: (%ld, %ld)\n", pairs[i].key, pairs[i].value);
> +		ksft_exit_fail_msg("Unexpected pair: (%lld, %llu)\n", pairs[i].key, pairs[i].value);
>   	}
>   
>   	out = riscv_hwprobe(pairs, 8, 0, 0, 0);


You can add:

Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com>

Thanks!

Alex
Alexandre Ghiti Dec. 15, 2023, 1:50 p.m. UTC | #3
On 23/11/2023 19:58, Christoph Muellner wrote:
> From: Christoph Müllner <christoph.muellner@vrull.eu>
>
> 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>
> ---
>   tools/testing/selftests/riscv/mm/mmap_test.h | 3 +++
>   1 file changed, 3 insertions(+)
>
> diff --git a/tools/testing/selftests/riscv/mm/mmap_test.h b/tools/testing/selftests/riscv/mm/mmap_test.h
> index 9b8434f62f57..2e0db9c5be6c 100644
> --- a/tools/testing/selftests/riscv/mm/mmap_test.h
> +++ b/tools/testing/selftests/riscv/mm/mmap_test.h
> @@ -18,6 +18,8 @@ struct addresses {
>   	int *on_56_addr;
>   };
>   
> +// Only works on 64 bit
> +#if __riscv_xlen == 64
>   static inline void do_mmaps(struct addresses *mmap_addresses)
>   {
>   	/*
> @@ -50,6 +52,7 @@ static inline void do_mmaps(struct addresses *mmap_addresses)
>   	mmap_addresses->on_56_addr =
>   		mmap(on_56_bits, 5 * sizeof(int), prot, flags, 0, 0);
>   }
> +#endif /* __riscv_xlen == 64 */
>   
>   static inline int memory_layout(void)
>   {


You can add:

Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com>

Thanks!

Alex
Alexandre Ghiti Dec. 15, 2023, 1:52 p.m. UTC | #4
On 23/11/2023 19:58, Christoph Muellner wrote:
> From: Christoph Müllner <christoph.muellner@vrull.eu>
>
> GCC prints a couple of format string warnings when compiling
> the hwprobe test. Let's follow the recommendation in
> Documentation/printk-formats.txt to fix these warnings.
>
> Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
> ---
>   tools/testing/selftests/riscv/hwprobe/hwprobe.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/riscv/hwprobe/hwprobe.c b/tools/testing/selftests/riscv/hwprobe/hwprobe.c
> index c474891df307..abb825811c70 100644
> --- a/tools/testing/selftests/riscv/hwprobe/hwprobe.c
> +++ b/tools/testing/selftests/riscv/hwprobe/hwprobe.c
> @@ -29,7 +29,7 @@ int main(int argc, char **argv)
>   		/* Fail if the kernel claims not to recognize a base key. */
>   		if ((i < 4) && (pairs[i].key != i))
>   			ksft_exit_fail_msg("Failed to recognize base key: key != i, "
> -					   "key=%ld, i=%ld\n", pairs[i].key, i);
> +					   "key=%lld, i=%ld\n", pairs[i].key, i);
>   
>   		if (pairs[i].key != RISCV_HWPROBE_KEY_BASE_BEHAVIOR)
>   			continue;
> @@ -37,7 +37,7 @@ int main(int argc, char **argv)
>   		if (pairs[i].value & RISCV_HWPROBE_BASE_BEHAVIOR_IMA)
>   			continue;
>   
> -		ksft_exit_fail_msg("Unexpected pair: (%ld, %ld)\n", pairs[i].key, pairs[i].value);
> +		ksft_exit_fail_msg("Unexpected pair: (%lld, %llu)\n", pairs[i].key, pairs[i].value);
>   	}
>   
>   	out = riscv_hwprobe(pairs, 8, 0, 0, 0);

You can add:

Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com>

Thanks!

Alex
Alexandre Ghiti Dec. 15, 2023, 1:57 p.m. UTC | #5
On 23/11/2023 19:58, Christoph Muellner wrote:
> From: Christoph Müllner <christoph.muellner@vrull.eu>
>
> GCC raises the following warning:
>    warning: 'status' may be used uninitialized
> The warning comes from the fact, that the signature of waitpid() is
> unknown and therefore the initialization of GCC cannot be guessed.
> Let's add the relevant header to address this warning.
>
> Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
> ---
>   tools/testing/selftests/riscv/vector/vstate_exec_nolibc.c | 3 +++
>   1 file changed, 3 insertions(+)
>
> diff --git a/tools/testing/selftests/riscv/vector/vstate_exec_nolibc.c b/tools/testing/selftests/riscv/vector/vstate_exec_nolibc.c
> index 2c0d2b1126c1..1f9969bed235 100644
> --- a/tools/testing/selftests/riscv/vector/vstate_exec_nolibc.c
> +++ b/tools/testing/selftests/riscv/vector/vstate_exec_nolibc.c
> @@ -1,4 +1,7 @@
>   // SPDX-License-Identifier: GPL-2.0-only
> +
> +#include <linux/wait.h>
> +
>   #define THIS_PROGRAM "./vstate_exec_nolibc"
>   
>   int main(int argc, char **argv)

You can add:

Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com>

Thanks!

Alex
Andy Chiu Dec. 15, 2023, 3:38 p.m. UTC | #6
On Fri, Nov 24, 2023 at 2:58 AM Christoph Muellner
<christoph.muellner@vrull.eu> wrote:
>
> From: Christoph Müllner <christoph.muellner@vrull.eu>
>
> GCC raises the following warning:
>   warning: 'status' may be used uninitialized
> The warning comes from the fact, that the signature of waitpid() is
> unknown and therefore the initialization of GCC cannot be guessed.
> Let's add the relevant header to address this warning.
>
> Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>

Reviewed-by: Andy Chiu <andy.chiu@sifive.com>


> ---
>  tools/testing/selftests/riscv/vector/vstate_exec_nolibc.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/tools/testing/selftests/riscv/vector/vstate_exec_nolibc.c b/tools/testing/selftests/riscv/vector/vstate_exec_nolibc.c
> index 2c0d2b1126c1..1f9969bed235 100644
> --- a/tools/testing/selftests/riscv/vector/vstate_exec_nolibc.c
> +++ b/tools/testing/selftests/riscv/vector/vstate_exec_nolibc.c
> @@ -1,4 +1,7 @@
>  // SPDX-License-Identifier: GPL-2.0-only
> +
> +#include <linux/wait.h>
> +
>  #define THIS_PROGRAM "./vstate_exec_nolibc"
>
>  int main(int argc, char **argv)
> --
> 2.41.0
>
patchwork-bot+linux-riscv@kernel.org Jan. 12, 2024, 6:30 a.m. UTC | #7
Hello:

This series was applied to riscv/linux.git (for-next)
by Palmer Dabbelt <palmer@rivosinc.com>:

On Thu, 23 Nov 2023 19:58:16 +0100 you wrote:
> 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.
> 
> [...]

Here is the summary with links:
  - [1/5] tools: selftests: riscv: Fix compile warnings in hwprobe
    https://git.kernel.org/riscv/c/b91c26fdb0e8
  - [2/5] tools: selftests: riscv: Fix compile warnings in cbo
    https://git.kernel.org/riscv/c/ac7b2a02d62f
  - [3/5] tools: selftests: riscv: Add missing include for vector test
    https://git.kernel.org/riscv/c/b250c9089841
  - [4/5] tools: selftests: riscv: Fix compile warnings in vector tests
    https://git.kernel.org/riscv/c/e1baf5e68ed1
  - [5/5] tools: selftests: riscv: Fix compile warnings in mm tests
    https://git.kernel.org/riscv/c/12c16919652b

You are awesome, thank you!