* [PATCH] platform/chrome: cros_ec_typec: fix clang -Wformat warning
@ 2021-03-22 11:55 Arnd Bergmann
2021-03-22 14:14 ` Guenter Roeck
2021-03-31 7:37 ` Enric Balletbo i Serra
0 siblings, 2 replies; 3+ messages in thread
From: Arnd Bergmann @ 2021-03-22 11:55 UTC (permalink / raw)
To: Benson Leung, Enric Balletbo i Serra, Nathan Chancellor,
Nick Desaulniers, Prashant Malani, Heikki Krogerus
Cc: Arnd Bergmann, Guenter Roeck, Greg Kroah-Hartman, Azhar Shaikh,
Utkarsh Patel, linux-kernel, clang-built-linux
From: Arnd Bergmann <arnd@arndb.de>
Clang warns about using the %h format modifier to truncate an
integer:
drivers/platform/chrome/cros_ec_typec.c:1031:3: error: format specifies type 'unsigned char' but the argument has type 'unsigned int' [-Werror,-Wformat]
typec->pd_ctrl_ver);
^~~~~~~~~~~~~~~~~~
include/linux/dev_printk.h:131:47: note: expanded from macro 'dev_dbg'
dev_printk(KERN_DEBUG, dev, dev_fmt(fmt), ##__VA_ARGS__); \
~~~ ^~~~~~~~~~~
Use an explicit bit mask to limit the number to its lower eight bits
instead.
Fixes: ad7c0510c99e ("platform/chrome: cros_ec_typec: Update port info from EC")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/platform/chrome/cros_ec_typec.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
index 0811562deecc..f07b7e946560 100644
--- a/drivers/platform/chrome/cros_ec_typec.c
+++ b/drivers/platform/chrome/cros_ec_typec.c
@@ -1027,8 +1027,8 @@ static int cros_typec_get_cmd_version(struct cros_typec_data *typec)
else
typec->pd_ctrl_ver = 0;
- dev_dbg(typec->dev, "PD Control has version mask 0x%hhx\n",
- typec->pd_ctrl_ver);
+ dev_dbg(typec->dev, "PD Control has version mask 0x%02x\n",
+ typec->pd_ctrl_ver & 0xff);
return 0;
}
--
2.29.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] platform/chrome: cros_ec_typec: fix clang -Wformat warning
2021-03-22 11:55 [PATCH] platform/chrome: cros_ec_typec: fix clang -Wformat warning Arnd Bergmann
@ 2021-03-22 14:14 ` Guenter Roeck
2021-03-31 7:37 ` Enric Balletbo i Serra
1 sibling, 0 replies; 3+ messages in thread
From: Guenter Roeck @ 2021-03-22 14:14 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Benson Leung, Enric Balletbo i Serra, Nathan Chancellor,
Nick Desaulniers, Prashant Malani, Heikki Krogerus,
Arnd Bergmann, Guenter Roeck, Greg Kroah-Hartman, Azhar Shaikh,
Utkarsh Patel, linux-kernel, clang-built-linux
On Mon, Mar 22, 2021 at 4:56 AM Arnd Bergmann <arnd@kernel.org> wrote:
>
> From: Arnd Bergmann <arnd@arndb.de>
>
> Clang warns about using the %h format modifier to truncate an
> integer:
>
> drivers/platform/chrome/cros_ec_typec.c:1031:3: error: format specifies type 'unsigned char' but the argument has type 'unsigned int' [-Werror,-Wformat]
> typec->pd_ctrl_ver);
> ^~~~~~~~~~~~~~~~~~
> include/linux/dev_printk.h:131:47: note: expanded from macro 'dev_dbg'
> dev_printk(KERN_DEBUG, dev, dev_fmt(fmt), ##__VA_ARGS__); \
> ~~~ ^~~~~~~~~~~
>
> Use an explicit bit mask to limit the number to its lower eight bits
> instead.
>
> Fixes: ad7c0510c99e ("platform/chrome: cros_ec_typec: Update port info from EC")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Guenter Roeck <groeck@chromium.org>
>
> ---
> drivers/platform/chrome/cros_ec_typec.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
> index 0811562deecc..f07b7e946560 100644
> --- a/drivers/platform/chrome/cros_ec_typec.c
> +++ b/drivers/platform/chrome/cros_ec_typec.c
> @@ -1027,8 +1027,8 @@ static int cros_typec_get_cmd_version(struct cros_typec_data *typec)
> else
> typec->pd_ctrl_ver = 0;
>
> - dev_dbg(typec->dev, "PD Control has version mask 0x%hhx\n",
> - typec->pd_ctrl_ver);
> + dev_dbg(typec->dev, "PD Control has version mask 0x%02x\n",
> + typec->pd_ctrl_ver & 0xff);
>
> return 0;
> }
> --
> 2.29.2
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] platform/chrome: cros_ec_typec: fix clang -Wformat warning
2021-03-22 11:55 [PATCH] platform/chrome: cros_ec_typec: fix clang -Wformat warning Arnd Bergmann
2021-03-22 14:14 ` Guenter Roeck
@ 2021-03-31 7:37 ` Enric Balletbo i Serra
1 sibling, 0 replies; 3+ messages in thread
From: Enric Balletbo i Serra @ 2021-03-31 7:37 UTC (permalink / raw)
To: Nathan Chancellor, Heikki Krogerus, Arnd Bergmann,
Prashant Malani, Benson Leung, Nick Desaulniers
Cc: clang-built-linux, Utkarsh Patel, Guenter Roeck,
Greg Kroah-Hartman, Azhar Shaikh, Arnd Bergmann, linux-kernel
On Mon, 22 Mar 2021 12:55:55 +0100, Arnd Bergmann wrote:
> Clang warns about using the %h format modifier to truncate an
> integer:
>
> drivers/platform/chrome/cros_ec_typec.c:1031:3: error: format specifies type 'unsigned char' but the argument has type 'unsigned int' [-Werror,-Wformat]
> typec->pd_ctrl_ver);
> ^~~~~~~~~~~~~~~~~~
> include/linux/dev_printk.h:131:47: note: expanded from macro 'dev_dbg'
> dev_printk(KERN_DEBUG, dev, dev_fmt(fmt), ##__VA_ARGS__); \
> ~~~ ^~~~~~~~~~~
>
> [...]
Applied, thanks!
[1/1] platform/chrome: cros_ec_typec: fix clang -Wformat warning
commit: c6e939c63c80c26460b25cf1150ebe8396e8adcf
Best regards,
--
Enric Balletbo i Serra <enric.balletbo@collabora.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-03-31 7:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-22 11:55 [PATCH] platform/chrome: cros_ec_typec: fix clang -Wformat warning Arnd Bergmann
2021-03-22 14:14 ` Guenter Roeck
2021-03-31 7:37 ` Enric Balletbo i Serra
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).