linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] block: use enumerate instead of integer in op_is_write()
@ 2021-08-20  1:55 brookxu
  2021-08-20  5:21 ` Christoph Hellwig
  0 siblings, 1 reply; 2+ messages in thread
From: brookxu @ 2021-08-20  1:55 UTC (permalink / raw)
  To: axboe; +Cc: linux-block, linux-kernel

From: Chunguang Xu <brookxu@tencent.com>

For mask operation, using enumerate may be safer than integer.

Signed-off-by: Chunguang Xu <brookxu@tencent.com>
---
 include/linux/blk_types.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h
index fd3860d1..b0411dc 100644
--- a/include/linux/blk_types.h
+++ b/include/linux/blk_types.h
@@ -447,7 +447,7 @@ static inline void bio_set_op_attrs(struct bio *bio, unsigned op,
 
 static inline bool op_is_write(unsigned int op)
 {
-	return (op & 1);
+	return (op & REQ_OP_WRITE);
 }
 
 /*
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] block: use enumerate instead of integer in op_is_write()
  2021-08-20  1:55 [PATCH] block: use enumerate instead of integer in op_is_write() brookxu
@ 2021-08-20  5:21 ` Christoph Hellwig
  0 siblings, 0 replies; 2+ messages in thread
From: Christoph Hellwig @ 2021-08-20  5:21 UTC (permalink / raw)
  To: brookxu; +Cc: axboe, linux-block, linux-kernel

On Fri, Aug 20, 2021 at 09:55:12AM +0800, brookxu wrote:
> From: Chunguang Xu <brookxu@tencent.com>
> 
> For mask operation, using enumerate may be safer than integer.

Except that we are explicitly checking for least significant bit as
that is part of the encoding, not a specific enum value.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-08-20  5:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-20  1:55 [PATCH] block: use enumerate instead of integer in op_is_write() brookxu
2021-08-20  5:21 ` 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).