Commit 4723832f authored by Bill Wendling's avatar Bill Wendling Committed by Paolo Abeni

bnx2x: truncate value to original sizing

The original behavior was to print out unsigned short or unsigned char
values. The change in commit d65aea8e ("bnx2x: use correct format
characters") prints out the whole value if not truncated. So truncate
the value to an unsigned {short|char} to retain the original behavior.

Fixes: d65aea8e ("bnx2x: use correct format characters")
Link: https://github.com/ClangBuiltLinux/linux/issues/378Signed-off-by: default avatarBill Wendling <morbo@google.com>
Link: https://lore.kernel.org/r/20220321023155.106066-1-morbo@google.comSigned-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent aa80511a
...@@ -6178,7 +6178,8 @@ static int bnx2x_format_ver(u32 num, u8 *str, u16 *len) ...@@ -6178,7 +6178,8 @@ static int bnx2x_format_ver(u32 num, u8 *str, u16 *len)
return -EINVAL; return -EINVAL;
} }
ret = scnprintf(str, *len, "%x.%x", num >> 16, num); ret = scnprintf(str, *len, "%x.%x", (num >> 16) & 0xFFFF,
num & 0xFFFF);
*len -= ret; *len -= ret;
return 0; return 0;
} }
...@@ -6193,7 +6194,8 @@ static int bnx2x_3_seq_format_ver(u32 num, u8 *str, u16 *len) ...@@ -6193,7 +6194,8 @@ static int bnx2x_3_seq_format_ver(u32 num, u8 *str, u16 *len)
return -EINVAL; return -EINVAL;
} }
ret = scnprintf(str, *len, "%x.%x.%x", num >> 16, num >> 8, num); ret = scnprintf(str, *len, "%x.%x.%x", (num >> 16) & 0xFF,
(num >> 8) & 0xFF, num & 0xFF);
*len -= ret; *len -= ret;
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment