From: "Satyam Sharma" <satyam.sharma@gmail.com>
To: "Al Viro" <viro@ftp.linux.org.uk>
Cc: "Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>
Subject: Re: double exclamation (!!) suckage in the kernel
Date: Sat, 26 May 2007 02:26:11 +0530 [thread overview]
Message-ID: <a781481a0705251356s2e9e0e2dsbed40a84231cd4fa@mail.gmail.com> (raw)
In-Reply-To: <20070525204127.GK4095@ftp.linux.org.uk>
On 5/26/07, Al Viro <viro@ftp.linux.org.uk> wrote:
> On Sat, May 26, 2007 at 01:53:59AM +0530, Satyam Sharma wrote:
> > Hello,
> >
> > Grepping through the sources I found 500+ occurrences of double
> > exclamation marks before identifier names (such as !!x -- I took care
> > to ignore occurrences of !! inside comment blocks, because there
> > are plenty of that sort too).
> >
> > !! are to be found even in the definitions of common macros such as
> > likely() and unlikely(), which hundreds of eyes must have seen over
> > the last year or so ...
> >
> > Are all these occurrences merely the debris of
> > s/something/!notsomething/g kind of patches or is there some
> > dark, unknown C / gcc wizardry I have absolutely no clue of?
>
> That's a question for a quiz in introductory course on C:
Ugh ... ok, I've embarrassed myself publicly already, so I'll
also be brave enough to take a C quiz here :-)
> what type should x have for !!x to be a valid expression?
Any integer type (includes pointers)
> what will be the type of result?
int (I guess boolean for C99?)
> what are the possible values of the result?
{0, 1}
> describe which values of x correspond to each possible value of !!x
Russell's mail has already answered that ...
> You have 10 minutes (and that's a fairly generous, actually).
Hmmm, looking through the grep output, actually, it seems some of the
occurrences of !! are indeed debris, but yes, most are actually a way to
force the output to {0, 1} when dealing with individual bits in code.
Satyam
next prev parent reply other threads:[~2007-05-25 20:56 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-25 20:23 Satyam Sharma
2007-05-25 20:28 ` Russell King
2007-05-25 20:32 ` Satyam Sharma
2007-05-25 20:37 ` Björn Steinbrink
2007-05-25 20:41 ` Al Viro
2007-05-25 20:56 ` Satyam Sharma [this message]
2007-05-25 21:03 ` Satyam Sharma
2007-05-25 21:32 ` Al Viro
2007-05-25 21:36 ` Al Viro
2007-05-25 21:37 ` Satyam Sharma
2007-05-25 21:14 ` David Miller
2007-05-26 13:41 ` Jan Engelhardt
[not found] <8oOAk-4mP-3@gated-at.bofh.it>
[not found] ` <8oPmF-5Fb-21@gated-at.bofh.it>
[not found] ` <8p4OH-3N0-15@gated-at.bofh.it>
2007-05-26 16:38 ` Bodo Eggert
2007-05-26 16:50 ` Al Viro
2007-05-29 8:26 ` Bodo Eggert
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=a781481a0705251356s2e9e0e2dsbed40a84231cd4fa@mail.gmail.com \
--to=satyam.sharma@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@ftp.linux.org.uk \
/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®