From: David Miller <davem@davemloft.net>
To: dima@arista.com
Cc: linux-kernel@vger.kernel.org, 0x7f454c46@gmail.com,
torvalds@linux-foundation.org, herbert@gondor.apana.org.au,
steffen.klassert@secunet.com, netdev@vger.kernel.org
Subject: Re: [PATCH] netlink: Make groups check less stupid in netlink_bind()
Date: Wed, 05 Sep 2018 22:11:56 -0700 (PDT) [thread overview]
Message-ID: <20180905.221156.794134129220434079.davem@davemloft.net> (raw)
In-Reply-To: <20180903214051.4433-1-dima@arista.com>
From: Dmitry Safonov <dima@arista.com>
Date: Mon, 3 Sep 2018 22:40:51 +0100
> As Linus noted, the test for 0 is needless, groups type can follow the
> usual kernel style and 8*sizeof(unsigned long) is BITS_PER_LONG:
>
>> The code [..] isn't technically incorrect...
>> But it is stupid.
>> Why stupid? Because the test for 0 is pointless.
>>
>> Just doing
>> if (nlk->ngroups < 8*sizeof(groups))
>> groups &= (1UL << nlk->ngroups) - 1;
>>
>> would have been fine and more understandable, since the "mask by shift
>> count" already does the right thing for a ngroups value of 0. Now that
>> test for zero makes me go "what's special about zero?". It turns out
>> that the answer to that is "nothing".
> [..]
>> The type of "groups" is kind of silly too.
>>
>> Yeah, "long unsigned int" isn't _technically_ wrong. But we normally
>> call that type "unsigned long".
>
> Cleanup my piece of pointlessness.
>
> Cc: "David S. Miller" <davem@davemloft.net>
> Cc: Herbert Xu <herbert@gondor.apana.org.au>
> Cc: Steffen Klassert <steffen.klassert@secunet.com>
> Cc: netdev@vger.kernel.org
> Fairly-blamed-by: Linus Torvalds <torvalds@linux-foundation.org>
> Signed-off-by: Dmitry Safonov <dima@arista.com>
Applied to net-next, thanks.
prev parent reply other threads:[~2018-09-06 5:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-03 21:40 Dmitry Safonov
2018-09-06 5:11 ` David Miller [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180905.221156.794134129220434079.davem@davemloft.net \
--to=davem@davemloft.net \
--cc=0x7f454c46@gmail.com \
--cc=dima@arista.com \
--cc=herbert@gondor.apana.org.au \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=steffen.klassert@secunet.com \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®