Skip to content

Commit 67caa52

Browse files
calebsanderaxboe
authored andcommitted
ublk: fix narrowing warnings in UAPI header
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 <[email protected]> Signed-off-by: Caleb Sander Mateos <[email protected]> Fixes: 99c1e4e ("ublk: register buffer to local io_uring with provided buf index via UBLK_F_AUTO_BUF_REG") Reviewed-by: Ming Lei <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 5223372 commit 67caa52

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

include/uapi/linux/ublk_cmd.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -450,10 +450,10 @@ static inline struct ublk_auto_buf_reg ublk_sqe_addr_to_auto_buf_reg(
450450
__u64 sqe_addr)
451451
{
452452
struct ublk_auto_buf_reg reg = {
453-
.index = sqe_addr & 0xffff,
454-
.flags = (sqe_addr >> 16) & 0xff,
455-
.reserved0 = (sqe_addr >> 24) & 0xff,
456-
.reserved1 = sqe_addr >> 32,
453+
.index = (__u16)sqe_addr,
454+
.flags = (__u8)(sqe_addr >> 16),
455+
.reserved0 = (__u8)(sqe_addr >> 24),
456+
.reserved1 = (__u32)(sqe_addr >> 32),
457457
};
458458

459459
return reg;

0 commit comments

Comments
 (0)