public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCH] io_uring: fix 1-bit bitfields to be unsigned
@ 2020-02-06  4:57 Randy Dunlap
  2020-02-06 20:42 ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: Randy Dunlap @ 2020-02-06  4:57 UTC (permalink / raw)
  To: LKML, axboe, io-uring

From: Randy Dunlap <[email protected]>

Make bitfields of size 1 bit be unsigned (since there is no room
for the sign bit).
This clears up the sparse warnings:

  CHECK   ../fs/io_uring.c
../fs/io_uring.c:207:50: error: dubious one-bit signed bitfield
../fs/io_uring.c:208:55: error: dubious one-bit signed bitfield
../fs/io_uring.c:209:63: error: dubious one-bit signed bitfield
../fs/io_uring.c:210:54: error: dubious one-bit signed bitfield
../fs/io_uring.c:211:57: error: dubious one-bit signed bitfield

Found by sight and then verified with sparse.

Fixes: 69b3e546139a ("io_uring: change io_ring_ctx bool fields into bit fields")
Signed-off-by: Randy Dunlap <[email protected]>
Cc: Jens Axboe <[email protected]>
Cc: [email protected]
---
 fs/io_uring.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

--- linux-next-20200205.orig/fs/io_uring.c
+++ linux-next-20200205/fs/io_uring.c
@@ -204,11 +204,11 @@ struct io_ring_ctx {
 
 	struct {
 		unsigned int		flags;
-		int			compat: 1;
-		int			account_mem: 1;
-		int			cq_overflow_flushed: 1;
-		int			drain_next: 1;
-		int			eventfd_async: 1;
+		unsigned int		compat: 1;
+		unsigned int		account_mem: 1;
+		unsigned int		cq_overflow_flushed: 1;
+		unsigned int		drain_next: 1;
+		unsigned int		eventfd_async: 1;
 
 		/*
 		 * Ring buffer of indices into array of io_uring_sqe, which is


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

* Re: [PATCH] io_uring: fix 1-bit bitfields to be unsigned
  2020-02-06  4:57 [PATCH] io_uring: fix 1-bit bitfields to be unsigned Randy Dunlap
@ 2020-02-06 20:42 ` Jens Axboe
  0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2020-02-06 20:42 UTC (permalink / raw)
  To: Randy Dunlap, LKML, io-uring

On 2/5/20 9:57 PM, Randy Dunlap wrote:
> From: Randy Dunlap <[email protected]>
> 
> Make bitfields of size 1 bit be unsigned (since there is no room
> for the sign bit).
> This clears up the sparse warnings:
> 
>   CHECK   ../fs/io_uring.c
> ../fs/io_uring.c:207:50: error: dubious one-bit signed bitfield
> ../fs/io_uring.c:208:55: error: dubious one-bit signed bitfield
> ../fs/io_uring.c:209:63: error: dubious one-bit signed bitfield
> ../fs/io_uring.c:210:54: error: dubious one-bit signed bitfield
> ../fs/io_uring.c:211:57: error: dubious one-bit signed bitfield
> 
> Found by sight and then verified with sparse.

Always thought those were pretty silly, it's not like this change is
suddenly going to make:

if (ctx->compat < 0)

be anymore valid (or invalid) than they already are. We also have
cases of:

bool foo:1;

does sparse warn about those?

-- 
Jens Axboe


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

end of thread, other threads:[~2020-02-06 20:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-02-06  4:57 [PATCH] io_uring: fix 1-bit bitfields to be unsigned Randy Dunlap
2020-02-06 20:42 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox