From: walter harms <wharms@bfs.de>
To: kernel-janitors@vger.kernel.org
Subject: Re: boolean result from a test for a bit
Date: Sat, 28 Jan 2012 10:31:07 +0000 [thread overview]
Message-ID: <4F23CE6B.6070102@bfs.de> (raw)
In-Reply-To: <804857E1F29AAC47BF68C404FC60A1842485E4@ORSMSX102.amr.corp.intel.com>
Am 27.01.2012 21:29, schrieb Allan, Bruce W:
> For a simple boolean test of whether, for example, bit 5 is set in the variable 'flags', which of the following methods is preferred over the other?
>
> bool result = (flags & (1 << 5)) ? true : false;
>
> or
>
> bool result = !!(flags & (1 << 5));
>
> I've seen examples of both in the Linux kernel.
>
> Thanks,
> Bruce.
> --
hi Bruce,
i think this is a matter of taste, but i would say
personaly i would go for option one since since !! can
easely be overlooked.
personaly i do not like bool.
re,
wh
next prev parent reply other threads:[~2012-01-28 10:31 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-27 20:29 boolean result from a test for a bit Allan, Bruce W
2012-01-27 20:29 ` Allan, Bruce W
2012-01-28 10:31 ` walter harms [this message]
2012-02-18 1:47 ` Phil Sutter
2012-02-18 1:47 ` Phil Sutter
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=4F23CE6B.6070102@bfs.de \
--to=wharms@bfs.de \
--cc=kernel-janitors@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.