aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustin Stitt <justinstitt@google.com>2022-07-11 16:24:04 -0700
committerJakub Kicinski <kuba@kernel.org>2022-07-12 20:36:41 -0700
commitb6afeb87ad294689a9687cda28dd7a7006740fc0 (patch)
treefa1a029249fb4c404ece9472df1707cb935c3f4d
parentigb: add xdp frags support to ndo_xdp_xmit (diff)
downloadlinux-dev-b6afeb87ad294689a9687cda28dd7a7006740fc0.tar.xz
linux-dev-b6afeb87ad294689a9687cda28dd7a7006740fc0.zip
qlogic: qed: fix clang -Wformat warnings
When building with Clang we encounter these warnings: | drivers/net/ethernet/qlogic/qed/qed_dev.c:416:30: error: format | specifies type 'char' but the argument has type 'u32' (aka 'unsigned | int') [-Werror,-Wformat] i); - | drivers/net/ethernet/qlogic/qed/qed_dev.c:630:13: error: format | specifies type 'char' but the argument has type 'int' [-Werror,-Wformat] | p_llh_info->num_ppfid - 1); For the first warning, `i` is a u32 which is much wider than the format specifier `%hhd` describes. This results in a loss of bits after 2^7. The second warning involves implicit integer promotion as the resulting type of addition cannot be smaller than an int. example: `` uint8_t a = 4, b = 7; int size = sizeof(a + b - 1); printf("%d\n", size); // output: 4 ``` See more: (https://wiki.sei.cmu.edu/confluence/display/c/INT02-C.+Understand+integer+conversion+rules) "Integer types smaller than int are promoted when an operation is performed on them. If all values of the original type can be represented as an int, the value of the smaller type is converted to an int; otherwise, it is converted to an unsigned int." Link: https://github.com/ClangBuiltLinux/linux/issues/378 Signed-off-by: Justin Stitt <justinstitt@google.com> Link: https://lore.kernel.org/r/20220711232404.2189257-1-justinstitt@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
-rw-r--r--drivers/net/ethernet/qlogic/qed/qed_dev.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/net/ethernet/qlogic/qed/qed_dev.c b/drivers/net/ethernet/qlogic/qed/qed_dev.c
index 672480c9d195..d61cd32ec3b6 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_dev.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_dev.c
@@ -412,7 +412,7 @@ static int qed_llh_alloc(struct qed_dev *cdev)
continue;
p_llh_info->ppfid_array[p_llh_info->num_ppfid] = i;
- DP_VERBOSE(cdev, QED_MSG_SP, "ppfid_array[%d] = %hhd\n",
+ DP_VERBOSE(cdev, QED_MSG_SP, "ppfid_array[%d] = %u\n",
p_llh_info->num_ppfid, i);
p_llh_info->num_ppfid++;
}
@@ -626,7 +626,7 @@ static int qed_llh_abs_ppfid(struct qed_dev *cdev, u8 ppfid, u8 *p_abs_ppfid)
if (ppfid >= p_llh_info->num_ppfid) {
DP_NOTICE(cdev,
- "ppfid %d is not valid, available indices are 0..%hhd\n",
+ "ppfid %d is not valid, available indices are 0..%d\n",
ppfid, p_llh_info->num_ppfid - 1);
*p_abs_ppfid = 0;
return -EINVAL;