lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZK002l0AojjdJptC@smile.fi.intel.com>
Date:   Tue, 11 Jul 2023 13:54:18 +0300
From:   Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To:     Paolo Abeni <pabeni@...hat.com>
Cc:     Leon Romanovsky <leon@...nel.org>,
        Jakub Kicinski <kuba@...nel.org>, netdev@...r.kernel.org,
        linux-kernel@...r.kernel.org,
        "David S. Miller" <davem@...emloft.net>,
        Eric Dumazet <edumazet@...gle.com>
Subject: Re: [PATCH net-next][resend v1 1/1] netlink: Don't use int as bool
 in netlink_update_socket_mc()

On Tue, Jul 11, 2023 at 12:21:12PM +0200, Paolo Abeni wrote:
> 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@...ux.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?

The same as with int - int [0 .. 1] + int [0 .. 1].

Note, the code _already_ uses boolean as integers.

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

This change does not change the status quo. The code uses booleans as integers
already (in the callers).

As I mentioned earlier, the purity of the code (converting booleans to integers
beforehand) adds unneeded churn and with this change code becomes cleaner at
least for the (existing) callers.

-- 
With Best Regards,
Andy Shevchenko


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ