lkml.org 
[lkml]   [2023]   [Jul]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH net-next][resend v1 1/1] netlink: Don't use int as bool in netlink_update_socket_mc()
From
Date
On Tue, 2023-07-11 at 09:33 +0300, Leon Romanovsky wrote:
> On Mon, Jul 10, 2023 at 01:06:24PM +0300, Andy Shevchenko wrote:
> > The bit operations take boolean parameter and return also boolean
> > (in test_bit()-like cases). Don't threat booleans as integers when
> > it's not needed.
> >
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > ---
> > net/netlink/af_netlink.c | 7 ++++---
> > 1 file changed, 4 insertions(+), 3 deletions(-)
> >
> > diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
> > index 383631873748..d81e7a43944c 100644
> > --- a/net/netlink/af_netlink.c
> > +++ b/net/netlink/af_netlink.c
> > @@ -1623,9 +1623,10 @@ EXPORT_SYMBOL(netlink_set_err);
> > /* must be called with netlink table grabbed */
> > static void netlink_update_socket_mc(struct netlink_sock *nlk,
> > unsigned int group,
> > - int is_new)
> > + bool new)
> > {
> > - int old, new = !!is_new, subscriptions;
> > + int subscriptions;
> > + bool old;
> >
> > old = test_bit(group - 1, nlk->groups);
> > subscriptions = nlk->subscriptions - old + new;
>
> So what is the outcome of "int - bool + bool" in the line above?

FTR, I agree with Leon, the old code is more readable to me/I don't see
a practical gain with this change.

Cheers,

Paolo

\
 
 \ /
  Last update: 2023-07-11 12:23    [W:0.049 / U:0.036 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site