linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: rubini@unipv.it (Alessandro Rubini)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] arm: nomadik: avoid assigning u32 to bool
Date: Sun, 3 Apr 2011 12:52:46 +0200	[thread overview]
Message-ID: <20110403105246.GA11998@mail.gnudd.com> (raw)
In-Reply-To: <20110403122611.4cca78b9@absol.kitzblitz>

>> Why?  There are dozens of places in the kernel where this done, the code
>> generated should be the same, and it's pretty obvious what is being done
>> as it is.
> 
> Primarily because we were asked to avoid casts to bool even if
> they are safe.

[I have studied, meanwhile]

Actually the point of Rabin is, I think, that the patch is not needed.
Our "bool" is the C99 "_Bool" type, for which the compiler
automatically converts all non-0 assignments to 1.  Even if storage
is still one byte.

IIUC, the point of _Bool is allowing comparisong with "true", while in
general non-0 is considered true if evaluated in a conditional
but may be "!= 1" so "!= true" if compared explicitly.

You can compile a one-liner to check. I used a few more:

    _Bool i[10];

    int main(void)
    {
        i[0] = 1;
        i[1] = 10;
        return i[0];
    }

/alessandro

      reply	other threads:[~2011-04-03 10:52 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-01 21:51 [PATCH] arm: nomadik: avoid assigning u32 to bool Nicolas Kaiser
2011-04-02 21:02 ` Linus Walleij
2011-04-02 21:19   ` Alessandro Rubini
2011-04-03  3:58 ` Rabin Vincent
2011-04-03 10:26   ` Nicolas Kaiser
2011-04-03 10:52     ` Alessandro Rubini [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=20110403105246.GA11998@mail.gnudd.com \
    --to=rubini@unipv.it \
    --cc=linux-arm-kernel@lists.infradead.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;
as well as URLs for NNTP newsgroup(s).