* [patch] block: precedence bug in bio_set_op_attrs() macro
@ 2016-11-10 20:04 Dan Carpenter
2016-11-10 20:07 ` Christoph Hellwig
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2016-11-10 20:04 UTC (permalink / raw)
To: Jens Axboe, Christoph Hellwig
Cc: Mike Christie, Shaun Tancheff, Hannes Reinecke,
Johannes Thumshirn, Bart Van Assche, Ming Lei, linux-block,
linux-btrfs, kernel-janitors
This code causes a problem for flush_epd_write_bio() because | has
higher precedence than ?: so it basically turns into:
((bio)->bi_opf |= REQ_SYNC;
Which is wrong.
Fixes: ef295ecf090d ("block: better op and flags encoding")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h
index 562ac46..67fae32 100644
--- a/include/linux/blk_types.h
+++ b/include/linux/blk_types.h
@@ -208,7 +208,7 @@ enum req_flag_bits {
/* obsolete, don't use in new code */
#define bio_set_op_attrs(bio, op, op_flags) \
- ((bio)->bi_opf |= (op | op_flags))
+ ((bio)->bi_opf |= ((op) | (op_flags)))
static inline bool op_is_write(unsigned int op)
{
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [patch] block: precedence bug in bio_set_op_attrs() macro
2016-11-10 20:04 [patch] block: precedence bug in bio_set_op_attrs() macro Dan Carpenter
@ 2016-11-10 20:07 ` Christoph Hellwig
0 siblings, 0 replies; 2+ messages in thread
From: Christoph Hellwig @ 2016-11-10 20:07 UTC (permalink / raw)
To: Dan Carpenter
Cc: Jens Axboe, Christoph Hellwig, Mike Christie, Shaun Tancheff,
Hannes Reinecke, Johannes Thumshirn, Bart Van Assche, Ming Lei,
linux-block, linux-btrfs, kernel-janitors
On Thu, Nov 10, 2016 at 11:04:38PM +0300, Dan Carpenter wrote:
> This code causes a problem for flush_epd_write_bio() because | has
> higher precedence than ?: so it basically turns into:
>
> ((bio)->bi_opf |= REQ_SYNC;
>
> Which is wrong.
Its is. And while we're at it the macro should really be doing a
= instead of |=.
And we really should stop using it, at least in the block core even
ASAP.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-11-10 20:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-10 20:04 [patch] block: precedence bug in bio_set_op_attrs() macro Dan Carpenter
2016-11-10 20:07 ` Christoph Hellwig
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).