* [PATCH] ublk: fix narrowing warnings in UAPI header
@ 2025-06-21 16:28 Caleb Sander Mateos
2025-06-23 1:40 ` Ming Lei
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Caleb Sander Mateos @ 2025-06-21 16:28 UTC (permalink / raw)
To: Ming Lei; +Cc: Caleb Sander Mateos, Uday Shankar, linux-block, linux-kernel
When a C++ file compiled with -Wc++11-narrowing includes the UAPI header
linux/ublk_cmd.h, ublk_sqe_addr_to_auto_buf_reg()'s assignments of u64
values to u8, u16, and u32 fields result in compiler warnings. Add
explicit casts to the intended types to avoid these warnings. Drop the
unnecessary bitmasks.
Reported-by: Uday Shankar <ushankar@purestorage.com>
Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
Fixes: 99c1e4eb6a3f ("ublk: register buffer to local io_uring with provided buf index via UBLK_F_AUTO_BUF_REG")
---
include/uapi/linux/ublk_cmd.h | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/include/uapi/linux/ublk_cmd.h b/include/uapi/linux/ublk_cmd.h
index 77d9d6af46da..c062109cb686 100644
--- a/include/uapi/linux/ublk_cmd.h
+++ b/include/uapi/linux/ublk_cmd.h
@@ -448,14 +448,14 @@ struct ublk_auto_buf_reg {
*/
static inline struct ublk_auto_buf_reg ublk_sqe_addr_to_auto_buf_reg(
__u64 sqe_addr)
{
struct ublk_auto_buf_reg reg = {
- .index = sqe_addr & 0xffff,
- .flags = (sqe_addr >> 16) & 0xff,
- .reserved0 = (sqe_addr >> 24) & 0xff,
- .reserved1 = sqe_addr >> 32,
+ .index = (__u16)sqe_addr,
+ .flags = (__u8)(sqe_addr >> 16),
+ .reserved0 = (__u8)(sqe_addr >> 24),
+ .reserved1 = (__u32)(sqe_addr >> 32),
};
return reg;
}
--
2.45.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] ublk: fix narrowing warnings in UAPI header
2025-06-21 16:28 [PATCH] ublk: fix narrowing warnings in UAPI header Caleb Sander Mateos
@ 2025-06-23 1:40 ` Ming Lei
2025-06-23 18:52 ` Uday Shankar
2025-06-24 14:51 ` Jens Axboe
2 siblings, 0 replies; 4+ messages in thread
From: Ming Lei @ 2025-06-23 1:40 UTC (permalink / raw)
To: Caleb Sander Mateos; +Cc: Uday Shankar, linux-block, linux-kernel
On Sat, Jun 21, 2025 at 10:28:41AM -0600, Caleb Sander Mateos wrote:
> When a C++ file compiled with -Wc++11-narrowing includes the UAPI header
> linux/ublk_cmd.h, ublk_sqe_addr_to_auto_buf_reg()'s assignments of u64
> values to u8, u16, and u32 fields result in compiler warnings. Add
> explicit casts to the intended types to avoid these warnings. Drop the
> unnecessary bitmasks.
>
> Reported-by: Uday Shankar <ushankar@purestorage.com>
> Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
> Fixes: 99c1e4eb6a3f ("ublk: register buffer to local io_uring with provided buf index via UBLK_F_AUTO_BUF_REG")
Reviewed-by: Ming Lei <ming.lei@redhat.com>
thanks,
Ming
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ublk: fix narrowing warnings in UAPI header
2025-06-21 16:28 [PATCH] ublk: fix narrowing warnings in UAPI header Caleb Sander Mateos
2025-06-23 1:40 ` Ming Lei
@ 2025-06-23 18:52 ` Uday Shankar
2025-06-24 14:51 ` Jens Axboe
2 siblings, 0 replies; 4+ messages in thread
From: Uday Shankar @ 2025-06-23 18:52 UTC (permalink / raw)
To: Caleb Sander Mateos; +Cc: Ming Lei, linux-block, linux-kernel
On Sat, Jun 21, 2025 at 10:28:41AM -0600, Caleb Sander Mateos wrote:
> When a C++ file compiled with -Wc++11-narrowing includes the UAPI header
> linux/ublk_cmd.h, ublk_sqe_addr_to_auto_buf_reg()'s assignments of u64
> values to u8, u16, and u32 fields result in compiler warnings. Add
> explicit casts to the intended types to avoid these warnings. Drop the
> unnecessary bitmasks.
>
> Reported-by: Uday Shankar <ushankar@purestorage.com>
> Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
> Fixes: 99c1e4eb6a3f ("ublk: register buffer to local io_uring with provided buf index via UBLK_F_AUTO_BUF_REG")
Looks good: https://godbolt.org/z/qovrerdhd
Reviewed-by: Uday Shankar <ushankar@purestorage.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ublk: fix narrowing warnings in UAPI header
2025-06-21 16:28 [PATCH] ublk: fix narrowing warnings in UAPI header Caleb Sander Mateos
2025-06-23 1:40 ` Ming Lei
2025-06-23 18:52 ` Uday Shankar
@ 2025-06-24 14:51 ` Jens Axboe
2 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2025-06-24 14:51 UTC (permalink / raw)
To: Ming Lei, Caleb Sander Mateos; +Cc: Uday Shankar, linux-block, linux-kernel
On Sat, 21 Jun 2025 10:28:41 -0600, Caleb Sander Mateos wrote:
> When a C++ file compiled with -Wc++11-narrowing includes the UAPI header
> linux/ublk_cmd.h, ublk_sqe_addr_to_auto_buf_reg()'s assignments of u64
> values to u8, u16, and u32 fields result in compiler warnings. Add
> explicit casts to the intended types to avoid these warnings. Drop the
> unnecessary bitmasks.
>
>
> [...]
Applied, thanks!
[1/1] ublk: fix narrowing warnings in UAPI header
commit: 03912ca894e4e5d6499bc57e9f10dda9f0965c1d
Best regards,
--
Jens Axboe
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-06-24 14:51 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-21 16:28 [PATCH] ublk: fix narrowing warnings in UAPI header Caleb Sander Mateos
2025-06-23 1:40 ` Ming Lei
2025-06-23 18:52 ` Uday Shankar
2025-06-24 14:51 ` Jens Axboe
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).