All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jiri Slaby <jirislaby@gmail.com>
To: Christoph Hellwig <hch@lst.de>
Cc: Jiri Slaby <jslaby@suse.cz>,
	akpm@linux-foundation.org, linux-raid@vger.kernel.org,
	linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
	Jens Axboe <axboe@kernel.dk>
Subject: Re: [PATCH v2] BLOCK: fix bio.bi_rw handling
Date: Thu, 12 Aug 2010 18:24:39 +0200	[thread overview]
Message-ID: <4C642047.6030108@gmail.com> (raw)
In-Reply-To: <20100812160809.GC28689@lst.de>

On 08/12/2010 06:08 PM, Christoph Hellwig wrote:
> On Thu, Aug 12, 2010 at 02:31:06PM +0200, Jiri Slaby wrote:
>> Return of the bi_rw tests is no longer bool after commit 74450be1. But
>> results of such tests are stored in bools. This doesn't fit in there
>> for some compilers (gcc 4.5 here), so either use !! magic to get real
>> bools or use ulong where the result is assigned somewhere.
> 
> I'd have to look at my copy of the C standard if it's guaranteed,

§6.5.3.3 of ANSI C99, par 5:
The result of the logical negation operator ! is 0 if the value of its
operand compares unequal to 0, 1 if the value of its operand compares
equal to 0. The result has type int. The expression !E is equivalent to
(0==E).

On == (§6.5.9 par 3):
The == (equal to) and != (not equal to) operators are analogous to the
relational operators except for their lower precedence. Each of the
operators yields 1 if the specified relation is true and 0 if it is
false. The result has type int. For any pair of operands, exactly one of
the relations is true.

On bool => _Bool (§6.2.5 par 2)
An object declared as type _Bool is large enough to store the values 0
and 1.

So it should be safe :).

BTW just of curiosity, sizeof(bool) is 1 here (8 bits).

regards,
-- 
js
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

WARNING: multiple messages have this Message-ID (diff)
From: Jiri Slaby <jirislaby@gmail.com>
To: Christoph Hellwig <hch@lst.de>
Cc: Jiri Slaby <jslaby@suse.cz>,
	akpm@linux-foundation.org, linux-raid@vger.kernel.org,
	linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
	Jens Axboe <axboe@kernel.dk>
Subject: Re: [PATCH v2] BLOCK: fix bio.bi_rw handling
Date: Thu, 12 Aug 2010 18:24:39 +0200	[thread overview]
Message-ID: <4C642047.6030108@gmail.com> (raw)
In-Reply-To: <20100812160809.GC28689@lst.de>

On 08/12/2010 06:08 PM, Christoph Hellwig wrote:
> On Thu, Aug 12, 2010 at 02:31:06PM +0200, Jiri Slaby wrote:
>> Return of the bi_rw tests is no longer bool after commit 74450be1. But
>> results of such tests are stored in bools. This doesn't fit in there
>> for some compilers (gcc 4.5 here), so either use !! magic to get real
>> bools or use ulong where the result is assigned somewhere.
> 
> I'd have to look at my copy of the C standard if it's guaranteed,

§6.5.3.3 of ANSI C99, par 5:
The result of the logical negation operator ! is 0 if the value of its
operand compares unequal to 0, 1 if the value of its operand compares
equal to 0. The result has type int. The expression !E is equivalent to
(0==E).

On == (§6.5.9 par 3):
The == (equal to) and != (not equal to) operators are analogous to the
relational operators except for their lower precedence. Each of the
operators yields 1 if the specified relation is true and 0 if it is
false. The result has type int. For any pair of operands, exactly one of
the relations is true.

On bool => _Bool (§6.2.5 par 2)
An object declared as type _Bool is large enough to store the values 0
and 1.

So it should be safe :).

BTW just of curiosity, sizeof(bool) is 1 here (8 bits).

regards,
-- 
js

  reply	other threads:[~2010-08-12 16:24 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-12 12:31 [PATCH v2] MD: raid, fix BUG caused by flags handling Jiri Slaby
2010-08-12 12:31 ` [PATCH v2] SCSI: fix bio.bi_rw handling Jiri Slaby
2010-08-12 13:30   ` Jeff Moyer
2010-08-12 16:06   ` Christoph Hellwig
2010-08-12 12:31 ` [PATCH v2] BLOCK: " Jiri Slaby
2010-08-12 13:35   ` Jeff Moyer
2010-08-12 16:08   ` Christoph Hellwig
2010-08-12 16:24     ` Jiri Slaby [this message]
2010-08-12 16:24       ` Jiri Slaby
2010-08-23 10:33   ` Jens Axboe
2010-08-12 13:26 ` [PATCH v2] MD: raid, fix BUG caused by flags handling Jeff Moyer
2010-08-12 16:05 ` Christoph Hellwig

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=4C642047.6030108@gmail.com \
    --to=jirislaby@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=axboe@kernel.dk \
    --cc=hch@lst.de \
    --cc=jslaby@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=linux-scsi@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.