bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] libbpf: remove unneeded conversion to bool
@ 2022-01-14  0:07 davidcomponentone
  2022-01-14  0:37 ` Song Liu
  0 siblings, 1 reply; 6+ messages in thread
From: davidcomponentone @ 2022-01-14  0:07 UTC (permalink / raw)
  To: ast
  Cc: davidcomponentone, daniel, andrii, kafai, songliubraving, yhs,
	john.fastabend, kpsingh, netdev, bpf, linux-kernel, Yang Guang,
	Zeal Robot

From: Yang Guang <yang.guang5@zte.com.cn>

The coccinelle report
./tools/lib/bpf/libbpf.c:1653:43-48:
WARNING: conversion to bool not needed here

Relational and logical operators evaluate to bool,
explicit conversion is overly verbose and unneeded.

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Yang Guang <yang.guang5@zte.com.cn>
Signed-off-by: David Yang <davidcomponentone@gmail.com>
---
 tools/lib/bpf/libbpf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index 7f10dd501a52..f87787608795 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -1650,7 +1650,7 @@ static int set_kcfg_value_tri(struct extern_desc *ext, void *ext_val,
 				ext->name, value);
 			return -EINVAL;
 		}
-		*(bool *)ext_val = value == 'y' ? true : false;
+		*(bool *)ext_val = value == 'y';
 		break;
 	case KCFG_TRISTATE:
 		if (value == 'y')
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread
* [PATCH] libbpf: Remove unneeded conversion to bool
@ 2024-03-02  0:54 Thorsten Blum
  2024-03-02 16:59 ` Yonghong Song
  0 siblings, 1 reply; 6+ messages in thread
From: Thorsten Blum @ 2024-03-02  0:54 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko
  Cc: Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
	KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa, bpf,
	linux-kernel, Thorsten Blum

Fixes Coccinelle/coccicheck warning reported by boolconv.cocci.

Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com>
---
 tools/lib/bpf/libbpf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index afd09571c482..2dda7a6c6f85 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -1801,7 +1801,7 @@ static int set_kcfg_value_tri(struct extern_desc *ext, void *ext_val,
 				ext->name, value);
 			return -EINVAL;
 		}
-		*(bool *)ext_val = value == 'y' ? true : false;
+		*(bool *)ext_val = value == 'y';
 		break;
 	case KCFG_TRISTATE:
 		if (value == 'y')
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread
* [PATCH] libbpf: remove unneeded conversion to bool
@ 2021-11-25  0:54 davidcomponentone
  2021-11-25 23:12 ` Daniel Borkmann
  0 siblings, 1 reply; 6+ messages in thread
From: davidcomponentone @ 2021-11-25  0:54 UTC (permalink / raw)
  To: ast, Daniel Borkmann, Andrii Nakryiko, Martin KaFai Lau,
	Song Liu, Yonghong Song, John Fastabend, KP Singh
  Cc: davidcomponentone, netdev, bpf, linux-kernel, Yang Guang, Zeal Robot

From: Yang Guang <yang.guang5@zte.com.cn>

The coccinelle report
./tools/lib/bpf/libbpf.c:1644:43-48:
WARNING: conversion to bool not needed here
Relational and logical operators evaluate to bool,
explicit conversion is overly verbose and unneeded.

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Yang Guang <yang.guang5@zte.com.cn>
---
 tools/lib/bpf/libbpf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index 14a89dc99937..33eb365a0b7f 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -1641,7 +1641,7 @@ static int set_kcfg_value_tri(struct extern_desc *ext, void *ext_val,
 				ext->name, value);
 			return -EINVAL;
 		}
-		*(bool *)ext_val = value == 'y' ? true : false;
+		*(bool *)ext_val = value == 'y';
 		break;
 	case KCFG_TRISTATE:
 		if (value == 'y')
-- 
2.30.2


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

end of thread, other threads:[~2024-03-02 16:59 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-14  0:07 [PATCH] libbpf: remove unneeded conversion to bool davidcomponentone
2022-01-14  0:37 ` Song Liu
  -- strict thread matches above, loose matches on Subject: below --
2024-03-02  0:54 [PATCH] libbpf: Remove " Thorsten Blum
2024-03-02 16:59 ` Yonghong Song
2021-11-25  0:54 [PATCH] libbpf: remove " davidcomponentone
2021-11-25 23:12 ` Daniel Borkmann

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).