Skip to content

Commit

Permalink
wifi: mt7601u: eeprom: fix clang -Wformat warning
Browse files Browse the repository at this point in the history
jira LE-1907
Rebuild_History Non-Buildable kernel-4.18.0-448.el8
commit-author Justin Stitt <[email protected]>
commit 07db88f

When building with Clang we encounter the following warning:
| drivers/net/wireless/mediatek/mt7601u/eeprom.c:193:5: error: format
| specifies type 'char' but the argument has type 'int' [-Werror,-Wformat]
| chan_bounds[idx].start + chan_bounds[idx].num - 1);

Variadic functions (printf-like) undergo default argument promotion.
Documentation/core-api/printk-formats.rst specifically recommends using
the promoted-to-type's format flag.

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.`

With this information in hand, we really should stop using `%hh[dxu]` or
`%h[dxu]` as they usually prompt Clang -Wformat warnings as well as go
against documented standard recommendations.

Link: ClangBuiltLinux/linux#378
	Signed-off-by: Justin Stitt <[email protected]>
	Signed-off-by: Kalle Valo <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
(cherry picked from commit 07db88f)
	Signed-off-by: Jonathan Maple <[email protected]>
  • Loading branch information
PlaidCat committed Sep 12, 2024
1 parent f7d1e8c commit 289dfee
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/net/wireless/mediatek/mt7601u/eeprom.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ mt7601u_set_country_reg(struct mt7601u_dev *dev, u8 *eeprom)

if (idx != -1)
dev_info(dev->dev,
"EEPROM country region %02hhx (channels %hhd-%hhd)\n",
"EEPROM country region %02x (channels %d-%d)\n",
val, chan_bounds[idx].start,
chan_bounds[idx].start + chan_bounds[idx].num - 1);
else
Expand Down

0 comments on commit 289dfee

Please sign in to comment.