History

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.

Caleb Sander Mateos committed 1 year ago

Commit 67caa521 parent 52233721 file · +4 −4Browse files

Showing the changes to include/uapi/linux (1 of 1 file). Show all

Unified · Split

include/uapi/linux/ublk_cmd.h+4−4
@@ -450,10 +450,10 @@ static inline struct ublk_auto_buf_reg ublk_sqe_addr_to_auto_buf_reg( · 449 unmodified lines
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;