From: Bodo Eggert <7eggert@gmx.de>
To: Jan Engelhardt <jengelh@linux01.gwdg.de>,
David Miller <davem@davemloft.net>,
satyam.sharma@gmail.com, linux-kernel@vger.kernel.org
Subject: Re: double exclamation (!!) suckage in the kernel
Date: Sat, 26 May 2007 18:38:07 +0200 [thread overview]
Message-ID: <E1HrzHL-0000s2-Pv@be1.lrz> (raw)
In-Reply-To: <8p4OH-3N0-15@gated-at.bofh.it>
Jan Engelhardt <jengelh@linux01.gwdg.de> wrote:
> On May 25 2007 14:14, David Miller wrote:
>>"!!" is used in contexts where pointers might be being
>>tested as well as plain integers, the "!!" turns a pointer
>>into the equivalent integer boolean for testing.
>>
>>NULL pointers become 0
>>non-NULL pointers become 1
>
> Though,
> if(!!ptr)
> is effectively the same as
> if(ptr)
Not exactly, if(foo) is the same as if( (int) foo), which is not
guaranteed to result in non-null values for non-null pointers.
ISO 9899/1999 says: "Any pointer may be converted to an integer type. [...]
The result need not be in the range of values of any integer type."
"if(!!foo)" is the same as "if(0 == (0 == foo))", which is (I asume) the same
as "if(0 == ((type_of_foo)NULL == foo))", or if((type_of_foo)NULL != foo).
--
Funny quotes:
11. Atheism is a non-prophet orgainization.
Friß, Spammer: bj@eTTCYWgi.7eggert.dyndns.org IsWw@efwjh45.7eggert.dyndns.org
next parent reply other threads:[~2007-05-26 16:38 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
[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 [this message]
2007-05-26 16:50 ` Al Viro
2007-05-29 8:26 ` Bodo Eggert
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
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
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=E1HrzHL-0000s2-Pv@be1.lrz \
--to=7eggert@gmx.de \
--cc=davem@davemloft.net \
--cc=jengelh@linux01.gwdg.de \
--cc=linux-kernel@vger.kernel.org \
--cc=satyam.sharma@gmail.com \
/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®