diff options
author | Justin Stitt <justinstitt@google.com> | 2022-07-08 16:26:53 -0700 |
---|---|---|
committer | Jakub Kicinski <kuba@kernel.org> | 2022-07-11 19:53:51 -0700 |
commit | 2afe46474ba3fd3ae6e016bab57efd73f4b96175 (patch) | |
tree | 4ca3a15a635c35f694dc6131c878c4660c186d74 | |
parent | 9e433ac1a381bb1fa5e7ccbe3d226780e5b10bed (diff) | |
download | linux-stable-2afe46474ba3fd3ae6e016bab57efd73f4b96175.tar.gz linux-stable-2afe46474ba3fd3ae6e016bab57efd73f4b96175.tar.bz2 linux-stable-2afe46474ba3fd3ae6e016bab57efd73f4b96175.zip |
amd-xgbe: fix clang -Wformat warnings
When building with Clang we encounter the following warning:
| drivers/net/ethernet/amd/xgbe/xgbe-dcb.c:234:42: error: format specifies
| type 'unsigned char' but the argument has type '__u16' (aka 'unsigned
| short') [-Werror,-Wformat] pfc->pfc_cap, pfc->pfc_en, pfc->mbc,
| pfc->delay);
pfc->pfc_cap , pfc->pfc_cn, pfc->mbc are all of type `u8` while pfc->delay is
of type `u16`. The correct format specifiers `%hh[u|x]` were used for
the first three but not for pfc->delay, which is causing the warning
above.
Variadic functions (printf-like) undergo default argument promotion.
Documentation/core-api/printk-formats.rst specifically recommends using
the promoted-to-type's format flag. In this case `%d` (or `%x` to
maintain hex representation) should be used since both u8's and u16's
are fully representable by an int.
Moreover, C11 6.3.1.1 states:
(https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1548.pdf) `If an int
can represent all values of the original type ..., the value is
converted to an int; otherwise, it is converted to an unsigned int.
These are called the integer promotions.`
Link: https://github.com/ClangBuiltLinux/linux/issues/378
Signed-off-by: Justin Stitt <justinstitt@google.com>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Tested-by: Nick Desaulniers <ndesaulniers@google.com>
Link: https://lore.kernel.org/r/20220708232653.556488-1-justinstitt@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
-rw-r--r-- | drivers/net/ethernet/amd/xgbe/xgbe-dcb.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-dcb.c b/drivers/net/ethernet/amd/xgbe/xgbe-dcb.c index 895d35639129..c68ace804e37 100644 --- a/drivers/net/ethernet/amd/xgbe/xgbe-dcb.c +++ b/drivers/net/ethernet/amd/xgbe/xgbe-dcb.c @@ -230,7 +230,7 @@ static int xgbe_dcb_ieee_setpfc(struct net_device *netdev, struct xgbe_prv_data *pdata = netdev_priv(netdev); netif_dbg(pdata, drv, netdev, - "cap=%hhu, en=%#hhx, mbc=%hhu, delay=%hhu\n", + "cap=%d, en=%#x, mbc=%d, delay=%d\n", pfc->pfc_cap, pfc->pfc_en, pfc->mbc, pfc->delay); /* Check PFC for supported number of traffic classes */ |