Skip to contentSkip to conversation

libbpf: Remove unnecessary conversion to bool

PATCH In review Jiapeng Chong 2 participants 2 messages Feb 20, 2021 – Feb 23, 2021

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libbpf: Remove unnecessary conversion to bool

Fix the following coccicheck warnings:

./tools/lib/bpf/libbpf.c:1487:43-48: WARNING: conversion to bool not needed here.

---
 tools/lib/bpf/libbpf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/lib/bpf/libbpf.c +1 -1
index 6ae748f..5dfdbf3 100644
@@ -1484,7 +1484,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')
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 9 lines · Jiapeng Chong

Fix the following coccicheck warnings:

./tools/lib/bpf/libbpf.c:1487:43-48: WARNING: conversion to bool not needed here.

---

I think this came up before already. I did this on purpose and I'd like to keep it that way in the code.

Quoted 19 lines
 tools/lib/bpf/libbpf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/lib/bpf/libbpf.c +1 -2
index 6ae748f..5dfdbf3 100644
@@ -1484,7 +1484,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')
--

1.8.3.1