From: "Arend van Spriel" <arend@broadcom.com>
To: "David Laight" <David.Laight@ACULAB.COM>
Cc: "Joe Perches" <joe@perches.com>,
"David Miller" <davem@davemloft.net>,
"jeffrey.t.kirsher@intel.com" <jeffrey.t.kirsher@intel.com>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
linux-wireless <linux-wireless@vger.kernel.org>
Subject: Re: [PATCH net-next] drivers/net: Remove boolean comparisons to true/false
Date: Fri, 10 Feb 2012 10:50:24 +0100 [thread overview]
Message-ID: <4F34E860.1020805@broadcom.com> (raw)
In-Reply-To: <AE90C24D6B3A694183C094C60CF0A2F6026B6E65@saturn3.aculab.com>
On 02/10/2012 10:32 AM, David Laight wrote:
>
>> - u32 func_encode = func |
>> - ((is_Pf == true ? 1 : 0) <<
> IGU_FID_ENCODE_IS_PF_SHIFT);
>> + u32 func_encode = func | (is_Pf ? 1 : 0) <<
> IGU_FID_ENCODE_IS_PF_SHIFT;
>
> This sort of thing is why I personally don't like 'bool' at all.
> If 'is_Pf' were an integer type that is known to only contain 0 or 1
> then the code can just be:
Properly chosing the bool type is not what is being handled by the
patch. Easiest way to convert would be using double inversion:
u32 func_encode = func | (!!is_Pf << IGU_FID_ENCODE_IS_PF_SHIFT);
The parenthesis are not needed due to operator precedence, but is more
clear this way (to me at least).
Gr. AvS
next prev parent reply other threads:[~2012-02-10 9:53 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1328783282-17760-5-git-send-email-jeffrey.t.kirsher@intel.com>
[not found] ` <AE90C24D6B3A694183C094C60CF0A2F6026B6E62@saturn3.aculab.com>
[not found] ` <20120209.133413.349832435589531136.davem@davemloft.net>
2012-02-09 21:17 ` [PATCH net-next] drivers/net: Remove boolean comparisons to true/false Joe Perches
2012-02-09 21:28 ` Jeff Kirsher
2012-02-09 22:36 ` Allan, Bruce W
2012-02-09 23:08 ` Joe Perches
2012-02-10 6:46 ` Julia Lawall
2012-02-10 9:32 ` David Laight
2012-02-10 9:50 ` Arend van Spriel [this message]
2012-02-10 13:04 ` Eric Dumazet
2012-02-13 5:50 ` David Miller
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=4F34E860.1020805@broadcom.com \
--to=arend@broadcom.com \
--cc=David.Laight@ACULAB.COM \
--cc=davem@davemloft.net \
--cc=jeffrey.t.kirsher@intel.com \
--cc=joe@perches.com \
--cc=linux-wireless@vger.kernel.org \
--cc=netdev@vger.kernel.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