netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf] selftests/bpf: Fix broken build where char is unsigned
@ 2023-11-02 10:35 Björn Töpel
  2023-11-02 10:49 ` Larysa Zaremba
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Björn Töpel @ 2023-11-02 10:35 UTC (permalink / raw)
  To: Andrii Nakryiko, Mykola Lysenko, bpf, Daniel Borkmann, netdev
  Cc: Björn Töpel, Alexei Starovoitov, linux-kselftest,
	linux-kernel, Larysa Zaremba

From: Björn Töpel <bjorn@rivosinc.com>

There are architectures where char is not signed. If so, the following
error is triggered:

  | xdp_hw_metadata.c:435:42: error: result of comparison of constant -1 \
  |   with expression of type 'char' is always true \
  |   [-Werror,-Wtautological-constant-out-of-range-compare]
  |   435 |         while ((opt = getopt(argc, argv, "mh")) != -1) {
  |       |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~~
  | 1 error generated.

Correct by changing the char to int.

Fixes: bb6a88885fde ("selftests/bpf: Add options and frags to xdp_hw_metadata")
Signed-off-by: Björn Töpel <bjorn@rivosinc.com>
---
 tools/testing/selftests/bpf/xdp_hw_metadata.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/bpf/xdp_hw_metadata.c b/tools/testing/selftests/bpf/xdp_hw_metadata.c
index 17c0f92ff160..c3ba40d0b9de 100644
--- a/tools/testing/selftests/bpf/xdp_hw_metadata.c
+++ b/tools/testing/selftests/bpf/xdp_hw_metadata.c
@@ -430,7 +430,7 @@ static void print_usage(void)
 
 static void read_args(int argc, char *argv[])
 {
-	char opt;
+	int opt;
 
 	while ((opt = getopt(argc, argv, "mh")) != -1) {
 		switch (opt) {

base-commit: cb3c6a58be50c65014296aa3455cae0fa1e82eac
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH bpf] selftests/bpf: Fix broken build where char is unsigned
  2023-11-02 10:35 [PATCH bpf] selftests/bpf: Fix broken build where char is unsigned Björn Töpel
@ 2023-11-02 10:49 ` Larysa Zaremba
  2023-11-02 11:14 ` Anders Roxell
  2023-11-02 15:00 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Larysa Zaremba @ 2023-11-02 10:49 UTC (permalink / raw)
  To: Björn Töpel
  Cc: Andrii Nakryiko, Mykola Lysenko, bpf, Daniel Borkmann, netdev,
	Björn Töpel, Alexei Starovoitov, linux-kselftest,
	linux-kernel

On Thu, Nov 02, 2023 at 11:35:37AM +0100, Björn Töpel wrote:
> From: Björn Töpel <bjorn@rivosinc.com>
> 
> There are architectures where char is not signed. If so, the following
> error is triggered:
> 
>   | xdp_hw_metadata.c:435:42: error: result of comparison of constant -1 \
>   |   with expression of type 'char' is always true \
>   |   [-Werror,-Wtautological-constant-out-of-range-compare]
>   |   435 |         while ((opt = getopt(argc, argv, "mh")) != -1) {
>   |       |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~~
>   | 1 error generated.
> 
> Correct by changing the char to int.
> 
> Fixes: bb6a88885fde ("selftests/bpf: Add options and frags to xdp_hw_metadata")
> Signed-off-by: Björn Töpel <bjorn@rivosinc.com>

Acked-by: Larysa Zaremba <larysa.zaremba@intel.com>

> ---
>  tools/testing/selftests/bpf/xdp_hw_metadata.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/bpf/xdp_hw_metadata.c b/tools/testing/selftests/bpf/xdp_hw_metadata.c
> index 17c0f92ff160..c3ba40d0b9de 100644
> --- a/tools/testing/selftests/bpf/xdp_hw_metadata.c
> +++ b/tools/testing/selftests/bpf/xdp_hw_metadata.c
> @@ -430,7 +430,7 @@ static void print_usage(void)
>  
>  static void read_args(int argc, char *argv[])
>  {
> -	char opt;
> +	int opt;
>  
>  	while ((opt = getopt(argc, argv, "mh")) != -1) {
>  		switch (opt) {
> 
> base-commit: cb3c6a58be50c65014296aa3455cae0fa1e82eac
> -- 
> 2.40.1
> 
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH bpf] selftests/bpf: Fix broken build where char is unsigned
  2023-11-02 10:35 [PATCH bpf] selftests/bpf: Fix broken build where char is unsigned Björn Töpel
  2023-11-02 10:49 ` Larysa Zaremba
@ 2023-11-02 11:14 ` Anders Roxell
  2023-11-02 15:00 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Anders Roxell @ 2023-11-02 11:14 UTC (permalink / raw)
  To: Björn Töpel
  Cc: Andrii Nakryiko, Mykola Lysenko, bpf, Daniel Borkmann, netdev,
	Björn Töpel, Alexei Starovoitov, linux-kselftest,
	linux-kernel, Larysa Zaremba

On 2023-11-02 11:35, Björn Töpel wrote:
> From: Björn Töpel <bjorn@rivosinc.com>
> 
> There are architectures where char is not signed. If so, the following
> error is triggered:
> 
>   | xdp_hw_metadata.c:435:42: error: result of comparison of constant -1 \
>   |   with expression of type 'char' is always true \
>   |   [-Werror,-Wtautological-constant-out-of-range-compare]
>   |   435 |         while ((opt = getopt(argc, argv, "mh")) != -1) {
>   |       |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~~
>   | 1 error generated.
> 
> Correct by changing the char to int.
> 
> Fixes: bb6a88885fde ("selftests/bpf: Add options and frags to xdp_hw_metadata")
> Signed-off-by: Björn Töpel <bjorn@rivosinc.com>

Thank you for the patch.
I saw the same failure when I built selftests/bpf for arm64.

With this patch ontop of today's next-20231102, fixes that build issue.

Tested-by: Anders Roxell <anders.roxell@linaro.org>


Cheers,
Anders

> ---
>  tools/testing/selftests/bpf/xdp_hw_metadata.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/bpf/xdp_hw_metadata.c b/tools/testing/selftests/bpf/xdp_hw_metadata.c
> index 17c0f92ff160..c3ba40d0b9de 100644
> --- a/tools/testing/selftests/bpf/xdp_hw_metadata.c
> +++ b/tools/testing/selftests/bpf/xdp_hw_metadata.c
> @@ -430,7 +430,7 @@ static void print_usage(void)
>  
>  static void read_args(int argc, char *argv[])
>  {
> -	char opt;
> +	int opt;
>  
>  	while ((opt = getopt(argc, argv, "mh")) != -1) {
>  		switch (opt) {
> 
> base-commit: cb3c6a58be50c65014296aa3455cae0fa1e82eac
> -- 
> 2.40.1
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH bpf] selftests/bpf: Fix broken build where char is unsigned
  2023-11-02 10:35 [PATCH bpf] selftests/bpf: Fix broken build where char is unsigned Björn Töpel
  2023-11-02 10:49 ` Larysa Zaremba
  2023-11-02 11:14 ` Anders Roxell
@ 2023-11-02 15:00 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-11-02 15:00 UTC (permalink / raw)
  To: =?utf-8?b?QmrDtnJuIFTDtnBlbCA8Ympvcm5Aa2VybmVsLm9yZz4=?=
  Cc: andrii, mykolal, bpf, daniel, netdev, bjorn, ast, linux-kselftest,
	linux-kernel, larysa.zaremba

Hello:

This patch was applied to bpf/bpf.git (master)
by Alexei Starovoitov <ast@kernel.org>:

On Thu,  2 Nov 2023 11:35:37 +0100 you wrote:
> From: Björn Töpel <bjorn@rivosinc.com>
> 
> There are architectures where char is not signed. If so, the following
> error is triggered:
> 
>   | xdp_hw_metadata.c:435:42: error: result of comparison of constant -1 \
>   |   with expression of type 'char' is always true \
>   |   [-Werror,-Wtautological-constant-out-of-range-compare]
>   |   435 |         while ((opt = getopt(argc, argv, "mh")) != -1) {
>   |       |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~~
>   | 1 error generated.
> 
> [...]

Here is the summary with links:
  - [bpf] selftests/bpf: Fix broken build where char is unsigned
    https://git.kernel.org/bpf/bpf/c/d84b139f53e8

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-11-02 15:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-02 10:35 [PATCH bpf] selftests/bpf: Fix broken build where char is unsigned Björn Töpel
2023-11-02 10:49 ` Larysa Zaremba
2023-11-02 11:14 ` Anders Roxell
2023-11-02 15:00 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).