Skip to contentSkip to conversation

libbpf: Delete an unneeded bool conversion

PATCH In review Zhen Lei 3 participants 7 messages May 10, 2021 – May 13, 2021

Subsystems (4)
lore
Share & tools
lore

Zhen Lei

author
#0 lore raw

PATCH 1/1 libbpf: Delete an unneeded bool conversion

The result of an expression consisting of a single relational operator is already of the bool type and does not need to be evaluated explicitly.

No functional change.

---
 tools/lib/bpf/libbpf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/lib/bpf/libbpf.c +1 -1
index e2a3cf4378140f2..fa02213c451f4d2 100644
@@ -1504,7 +1504,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
2.26.0.106.g9fadedd
#1 lore raw
Quoted 8 lines · Zhen Lei

The result of an expression consisting of a single relational operator is already of the bool type and does not need to be evaluated explicitly.

No functional change.

---

See [0] and [1].

[0] https://lore.kernel.org/bpf/CAEf4BzYgLf5g3oztbA-CJR4gQ7AVKQAGrsHWCOgTtUMUM-Mxfg@mail.gmail.com/
[1] https://lore.kernel.org/bpf/CAEf4BzZQ6=-h3g1duXFwDLr92z7nE6ajv8Rz_Zv=qx=-F3sRVA@mail.gmail.com/

Quoted 20 lines
 tools/lib/bpf/libbpf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/lib/bpf/libbpf.c +1 -2
index e2a3cf4378140f2..fa02213c451f4d2 100644
@@ -1504,7 +1504,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.26.0.106.g9fadedd

#2 lore raw
Quoted 7 lines · Andrii Nakryiko
Quoted 6 lines · Zhen Lei

The result of an expression consisting of a single relational operator is already of the bool type and does not need to be evaluated explicitly.

No functional change.

Quoted 7 lines
Quoted 2 lines

---

See [0] and [1].

[0] https://lore.kernel.org/bpf/CAEf4BzYgLf5g3oztbA-CJR4gQ7AVKQAGrsHWCOgTtUMUM-Mxfg@mail.gmail.com/
[1] https://lore.kernel.org/bpf/CAEf4BzZQ6=-h3g1duXFwDLr92z7nE6ajv8Rz_Zv=qx=-F3sRVA@mail.gmail.com/

How long do you plan to fight with such patches?

Thanks

Quoted 21 lines
Quoted 21 lines
 tools/lib/bpf/libbpf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/lib/bpf/libbpf.c +1 -2
index e2a3cf4378140f2..fa02213c451f4d2 100644
@@ -1504,7 +1504,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.26.0.106.g9fadedd

#3 lore raw
Quoted 12 lines · Leon Romanovsky
Quoted 10 lines · Andrii Nakryiko
Quoted 8 lines · Zhen Lei

The result of an expression consisting of a single relational operator is already of the bool type and does not need to be evaluated explicitly.

No functional change.

---

Quoted 6 lines
Quoted 4 lines

See [0] and [1].

[0] https://lore.kernel.org/bpf/CAEf4BzYgLf5g3oztbA-CJR4gQ7AVKQAGrsHWCOgTtUMUM-Mxfg@mail.gmail.com/
[1] https://lore.kernel.org/bpf/CAEf4BzZQ6=-h3g1duXFwDLr92z7nE6ajv8Rz_Zv=qx=-F3sRVA@mail.gmail.com/

How long do you plan to fight with such patches?

As long as necessary. There are better ways to contribute to libbpf than doing cosmetic changes to the perfectly correct code.

Quoted 24 lines

Thanks

Quoted 21 lines
Quoted 21 lines
 tools/lib/bpf/libbpf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/lib/bpf/libbpf.c +1 -2
index e2a3cf4378140f2..fa02213c451f4d2 100644
@@ -1504,7 +1504,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.26.0.106.g9fadedd

#4 lore raw
Quoted 15 lines · Andrii Nakryiko
Quoted 14 lines · Leon Romanovsky
Quoted 12 lines · Andrii Nakryiko
Quoted 8 lines · Zhen Lei

The result of an expression consisting of a single relational operator is already of the bool type and does not need to be evaluated explicitly.

No functional change.

---

See [0] and [1].

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

[0] https://lore.kernel.org/bpf/CAEf4BzYgLf5g3oztbA-CJR4gQ7AVKQAGrsHWCOgTtUMUM-Mxfg@mail.gmail.com/
[1] https://lore.kernel.org/bpf/CAEf4BzZQ6=-h3g1duXFwDLr92z7nE6ajv8Rz_Zv=qx=-F3sRVA@mail.gmail.com/

How long do you plan to fight with such patches?

As long as necessary. There are better ways to contribute to libbpf than doing cosmetic changes to the perfectly correct code.

No small stream, no river and sea.

There are no improvements to functionality, but may slightly speed up compilation. With more such accumulations, it is possible that the compilation of allmodconfig results in a second-level improvement.

I don't know if you agree, at least I think so.

Quoted 28 lines
Quoted 17 lines

Thanks

Quoted 13 lines
Quoted 13 lines
 tools/lib/bpf/libbpf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/lib/bpf/libbpf.c +0 -1
index e2a3cf4378140f2..fa02213c451f4d2 100644
@@ -1504,7 +1504,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;
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
tools/lib/bpf/libbpf.c +1 -1
+               *(bool *)ext_val = value == 'y';
                break;
        case KCFG_TRISTATE:
                if (value == 'y')
--

2.26.0.106.g9fadedd

.

#5 lore raw
Quoted 23 lines · Leizhen (ThunderTown)
Quoted 20 lines · Andrii Nakryiko
Quoted 18 lines · Leon Romanovsky
Quoted 7 lines · Andrii Nakryiko
Quoted 6 lines · Zhen Lei

The result of an expression consisting of a single relational operator is already of the bool type and does not need to be evaluated explicitly.

No functional change.

Quoted 7 lines
Quoted 2 lines

---

See [0] and [1].

[0] https://lore.kernel.org/bpf/CAEf4BzYgLf5g3oztbA-CJR4gQ7AVKQAGrsHWCOgTtUMUM-Mxfg@mail.gmail.com/
[1] https://lore.kernel.org/bpf/CAEf4BzZQ6=-h3g1duXFwDLr92z7nE6ajv8Rz_Zv=qx=-F3sRVA@mail.gmail.com/

How long do you plan to fight with such patches?

Quoted 8 lines
Quoted 2 lines

As long as necessary. There are better ways to contribute to libbpf than doing cosmetic changes to the perfectly correct code.

No small stream, no river and sea.

There are no improvements to functionality, but may slightly speed up compilation. With more such accumulations, it is possible that the compilation of allmodconfig results in a second-level improvement.

Unlikely with modern CPUs.

Quoted 32 lines

I don't know if you agree, at least I think so.

Quoted 28 lines
Quoted 17 lines

Thanks

Quoted 13 lines
Quoted 13 lines
 tools/lib/bpf/libbpf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/lib/bpf/libbpf.c +0 -1
index e2a3cf4378140f2..fa02213c451f4d2 100644
@@ -1504,7 +1504,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;
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
tools/lib/bpf/libbpf.c +1 -1
+               *(bool *)ext_val = value == 'y';
                break;
        case KCFG_TRISTATE:
                if (value == 'y')
--

2.26.0.106.g9fadedd

.

#6 lore raw
In reply to Andrii Nakryiko
Quoted 15 lines · Andrii Nakryiko
Quoted 14 lines · Leon Romanovsky
Quoted 12 lines · Andrii Nakryiko
Quoted 8 lines · Zhen Lei

The result of an expression consisting of a single relational operator is already of the bool type and does not need to be evaluated explicitly.

No functional change.

---

See [0] and [1].

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

[0] https://lore.kernel.org/bpf/CAEf4BzYgLf5g3oztbA-CJR4gQ7AVKQAGrsHWCOgTtUMUM-Mxfg@mail.gmail.com/
[1] https://lore.kernel.org/bpf/CAEf4BzZQ6=-h3g1duXFwDLr92z7nE6ajv8Rz_Zv=qx=-F3sRVA@mail.gmail.com/

How long do you plan to fight with such patches?

As long as necessary. There are better ways to contribute to libbpf than doing cosmetic changes to the perfectly correct code.

I wish you good luck with that.

My hope that, you have enough spare time to invest in rejects.

Thanks