1
0
Fork 0
mirror of synced 2025-03-06 20:59:54 +01:00
linux/drivers/net/ethernet/amd/xgbe
Justin Stitt 2afe46474b 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>
2022-07-11 19:53:51 -07:00
..
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
xgbe-common.h net: amd-xgbe: Alter the port speed bit range 2021-12-20 18:42:39 -08:00
xgbe-dcb.c amd-xgbe: fix clang -Wformat warnings 2022-07-11 19:53:51 -07:00
xgbe-debugfs.c xgbe: no need to check return value of debugfs_create functions 2019-08-10 15:25:47 -07:00
xgbe-desc.c net: Use skb accessors in network drivers 2019-07-22 20:47:56 -07:00
xgbe-dev.c ethernet: constify references to netdev->dev_addr in drivers 2021-10-14 09:22:11 -07:00
xgbe-drv.c net: add skb_[inner_]tcp_all_headers helpers 2022-07-02 16:22:25 +01:00
xgbe-ethtool.c ethtool: extend ringparam setting/getting API with rx_buf_len 2021-11-22 12:31:49 +00:00
xgbe-i2c.c net: amd-xgbe: convert tasklets to use new tasklet_setup() API 2020-09-14 13:02:37 -07:00
xgbe-main.c ethernet: use eth_hw_addr_set() for dev->addr_len cases 2021-10-05 13:16:48 +01:00
xgbe-mdio.c net: amd-xgbe: Reset link when the link never comes back 2021-02-16 14:09:45 -08:00
xgbe-pci.c net: amd-xgbe: disable interrupts during pci removal 2022-02-09 12:52:59 +00:00
xgbe-phy-v1.c amd-xgbe: Convert to using the new link mode settings 2017-08-18 16:30:17 -07:00
xgbe-phy-v2.c net: amd-xgbe: Alter the port speed bit range 2021-12-20 18:42:39 -08:00
xgbe-platform.c amd-xgbe: Use platform_irq_count() 2022-06-13 23:12:39 -07:00
xgbe-ptp.c amd-xgbe: Use the proper register during PTP initialization 2017-06-29 15:14:16 -04:00
xgbe.h amd/xgbe: fix repeated words in comments 2022-06-27 22:06:18 -07:00