]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ublk: fix narrowing warnings in UAPI header
authorCaleb Sander Mateos <csander@purestorage.com>
Sat, 21 Jun 2025 16:28:41 +0000 (10:28 -0600)
committerJens Axboe <axboe@kernel.dk>
Wed, 25 Jun 2025 02:45:31 +0000 (20:45 -0600)
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>
Link: https://lore.kernel.org/r/20250621162842.337452-1-csander@purestorage.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
include/uapi/linux/ublk_cmd.h

index 77d9d6af46da878cf30df6e3e31758a6f8f61afa..c062109cb686cfa736089db4e3e9dcc6a2c3ab57 100644 (file)
@@ -450,10 +450,10 @@ 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;