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.
Showing the changes to include/uapi (1 of 1 file). Show all
Unified · Split
| @@ -450,10 +450,10 @@ static inline struct ublk_auto_buf_reg ublk_sqe_addr_to_auto_buf_reg( · 449 unmodified lines | ||
| 450 | 450 | __u64 sqe_addr) |
| 451 | 451 | { |
| 452 | 452 | 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), | |
| 457 | 457 | }; |
| 458 | 458 | |
| 459 | 459 | return reg; |