Thread (59 messages) 59 messages, 9 authors, 2016-09-15

Re: [PATCH 3/5] nbd: use flags instead of bool

flat view

From: Jens Axboe <hidden>
Date: 2016-09-09 16:12:30
Also in: lkml

On 09/09/2016 10:04 AM, Joe Perches wrote:
On Fri, 2016-09-09 at 07:55 -0600, Jens Axboe wrote:
quoted
On 09/08/2016 07:20 PM, Joe Perches wrote:
quoted
On Thu, 2016-09-08 at 17:12 -0400, Josef Bacik wrote:
quoted
In preparation for some future changes, change a few of the state bools over to
normal bits to set/clear properly.
[]
quoted
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
[]
quoted
@@ -41,8 +41,12 @@

 #include <linux/nbd.h>

+#define NBD_TIMEDOUT			0
+#define NBD_DISCONNECT_REQUESTED	1
+
 struct nbd_device {
 	u32 flags;
+	unsigned long runtime_flags;
Better to use DECLARE_BITMAP
quoted
It's a few flags, we know it fits in a long. There's no point to using
anything but that, and set/test/clear_bit().
It lets the reader know how it's used.
The variable is called 'runtime_flags' - if that doesn't already tell
the reader how it's used, then I'd suggest the reader go read something
else.

I'm all for using established APIs where it makes sense. Declaring a
bitmap for a few fields isn't that.

-- 
Jens Axboe
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help