diff mbox series

[1/1] libbpf: Delete an unneeded bool conversion

Message ID 20210510124315.3854-1-thunder.leizhen@huawei.com
State New
Headers show
Series [1/1] libbpf: Delete an unneeded bool conversion | expand

Commit Message

Leizhen (ThunderTown) May 10, 2021, 12:43 p.m. UTC
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.

Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>

---
 tools/lib/bpf/libbpf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

-- 
2.26.0.106.g9fadedd

Comments

Andrii Nakryiko May 10, 2021, 6 p.m. UTC | #1
On Mon, May 10, 2021 at 5:43 AM Zhen Lei <thunder.leizhen@huawei.com> wrote:
>

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

>

> Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>

> ---


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/

>  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 e2a3cf4378140f2..fa02213c451f4d2 100644

> --- a/tools/lib/bpf/libbpf.c

> +++ b/tools/lib/bpf/libbpf.c

> @@ -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

>

>
Leon Romanovsky May 11, 2021, 5:09 a.m. UTC | #2
On Mon, May 10, 2021 at 11:00:29AM -0700, Andrii Nakryiko wrote:
> On Mon, May 10, 2021 at 5:43 AM Zhen Lei <thunder.leizhen@huawei.com> wrote:

> >

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

> >

> > Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>

> > ---

> 

> 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

> 

> >  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 e2a3cf4378140f2..fa02213c451f4d2 100644

> > --- a/tools/lib/bpf/libbpf.c

> > +++ b/tools/lib/bpf/libbpf.c

> > @@ -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

> >

> >
Andrii Nakryiko May 12, 2021, 7:02 p.m. UTC | #3
On Mon, May 10, 2021 at 10:09 PM Leon Romanovsky <leon@kernel.org> wrote:
>
> On Mon, May 10, 2021 at 11:00:29AM -0700, Andrii Nakryiko wrote:
> > On Mon, May 10, 2021 at 5:43 AM Zhen Lei <thunder.leizhen@huawei.com> wrote:
> > >
> > > 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.
> > >
> > > Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
> > > ---
> >
> > 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.

>
> Thanks
>
> >
> > >  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 e2a3cf4378140f2..fa02213c451f4d2 100644
> > > --- a/tools/lib/bpf/libbpf.c
> > > +++ b/tools/lib/bpf/libbpf.c
> > > @@ -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
> > >
> > >
Leizhen (ThunderTown) May 13, 2021, 2:14 a.m. UTC | #4
On 2021/5/13 3:02, Andrii Nakryiko wrote:
> On Mon, May 10, 2021 at 10:09 PM Leon Romanovsky <leon@kernel.org> wrote:

>>

>> On Mon, May 10, 2021 at 11:00:29AM -0700, Andrii Nakryiko wrote:

>>> On Mon, May 10, 2021 at 5:43 AM Zhen Lei <thunder.leizhen@huawei.com> wrote:

>>>>

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

>>>>

>>>> Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>

>>>> ---

>>>

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


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.

> 

>>

>> Thanks

>>

>>>

>>>>  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 e2a3cf4378140f2..fa02213c451f4d2 100644

>>>> --- a/tools/lib/bpf/libbpf.c

>>>> +++ b/tools/lib/bpf/libbpf.c

>>>> @@ -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

>>>>

>>>>

> 

> .

>
Leon Romanovsky May 13, 2021, 6:22 a.m. UTC | #5
On Thu, May 13, 2021 at 10:14:00AM +0800, Leizhen (ThunderTown) wrote:
> 

> 

> On 2021/5/13 3:02, Andrii Nakryiko wrote:

> > On Mon, May 10, 2021 at 10:09 PM Leon Romanovsky <leon@kernel.org> wrote:

> >>

> >> On Mon, May 10, 2021 at 11:00:29AM -0700, Andrii Nakryiko wrote:

> >>> On Mon, May 10, 2021 at 5:43 AM Zhen Lei <thunder.leizhen@huawei.com> wrote:

> >>>>

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

> >>>>

> >>>> Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>

> >>>> ---

> >>>

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

> 

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

> 

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

> 

> > 

> >>

> >> Thanks

> >>

> >>>

> >>>>  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 e2a3cf4378140f2..fa02213c451f4d2 100644

> >>>> --- a/tools/lib/bpf/libbpf.c

> >>>> +++ b/tools/lib/bpf/libbpf.c

> >>>> @@ -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

> >>>>

> >>>>

> > 

> > .

> > 

>
Leon Romanovsky May 13, 2021, 6:31 a.m. UTC | #6
On Wed, May 12, 2021 at 12:02:11PM -0700, Andrii Nakryiko wrote:
> On Mon, May 10, 2021 at 10:09 PM Leon Romanovsky <leon@kernel.org> wrote:

> >

> > On Mon, May 10, 2021 at 11:00:29AM -0700, Andrii Nakryiko wrote:

> > > On Mon, May 10, 2021 at 5:43 AM Zhen Lei <thunder.leizhen@huawei.com> wrote:

> > > >

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

> > > >

> > > > Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>

> > > > ---

> > >

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


I wish you good luck with that.

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

Thanks
diff mbox series

Patch

diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index e2a3cf4378140f2..fa02213c451f4d2 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -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')