linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mei: me: fix clang -Wformat warning
@ 2022-07-08 20:35 Justin Stitt
  2022-07-08 23:39 ` Nick Desaulniers
  0 siblings, 1 reply; 2+ messages in thread
From: Justin Stitt @ 2022-07-08 20:35 UTC (permalink / raw)
  To: Tomas Winkler
  Cc: Arnd Bergmann, Greg Kroah-Hartman, Nathan Chancellor,
	Nick Desaulniers, Tom Rix, linux-kernel, llvm, Justin Stitt

When building with Clang we encounter the following warning:
| drivers/misc/mei/hw-me.c:564:44: error: format specifies type 'unsigned
| short' but the argument has type 'int' [-Werror,-Wformat]
| dev_dbg(dev->dev, "empty slots = %hu.\n", empty_slots);

The format specifier used is `%hu` which specifies an unsigned short,
however, empty_slots is an int -- hence the warning.

Link: https://github.com/ClangBuiltLinux/linux/issues/378
Signed-off-by: Justin Stitt <justinstitt@google.com>
---
 drivers/misc/mei/hw-me.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/misc/mei/hw-me.c b/drivers/misc/mei/hw-me.c
index befa491e3344..3a95fe7d4e33 100644
--- a/drivers/misc/mei/hw-me.c
+++ b/drivers/misc/mei/hw-me.c
@@ -561,7 +561,7 @@ static int mei_me_hbuf_write(struct mei_device *dev,
 	dev_dbg(dev->dev, MEI_HDR_FMT, MEI_HDR_PRM((struct mei_msg_hdr *)hdr));
 
 	empty_slots = mei_hbuf_empty_slots(dev);
-	dev_dbg(dev->dev, "empty slots = %hu.\n", empty_slots);
+	dev_dbg(dev->dev, "empty slots = %d.\n", empty_slots);
 
 	if (empty_slots < 0)
 		return -EOVERFLOW;
-- 
2.37.0.rc0.161.g10f37bed90-goog


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] mei: me: fix clang -Wformat warning
  2022-07-08 20:35 [PATCH] mei: me: fix clang -Wformat warning Justin Stitt
@ 2022-07-08 23:39 ` Nick Desaulniers
  0 siblings, 0 replies; 2+ messages in thread
From: Nick Desaulniers @ 2022-07-08 23:39 UTC (permalink / raw)
  To: Justin Stitt
  Cc: Tomas Winkler, Arnd Bergmann, Greg Kroah-Hartman,
	Nathan Chancellor, Tom Rix, linux-kernel, llvm

On Fri, Jul 8, 2022 at 1:36 PM Justin Stitt <justinstitt@google.com> wrote:
>
> When building with Clang we encounter the following warning:
> | drivers/misc/mei/hw-me.c:564:44: error: format specifies type 'unsigned
> | short' but the argument has type 'int' [-Werror,-Wformat]
> | dev_dbg(dev->dev, "empty slots = %hu.\n", empty_slots);
>
> The format specifier used is `%hu` which specifies an unsigned short,
> however, empty_slots is an int -- hence the warning.
>
> Link: https://github.com/ClangBuiltLinux/linux/issues/378
> Signed-off-by: Justin Stitt <justinstitt@google.com>

Thanks for the patch! This fixes the warning I observe when building
x86_64 allmodconfig with -Wno-format removed.
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Tested-by: Nick Desaulniers <ndesaulniers@google.com>

> ---
>  drivers/misc/mei/hw-me.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/misc/mei/hw-me.c b/drivers/misc/mei/hw-me.c
> index befa491e3344..3a95fe7d4e33 100644
> --- a/drivers/misc/mei/hw-me.c
> +++ b/drivers/misc/mei/hw-me.c
> @@ -561,7 +561,7 @@ static int mei_me_hbuf_write(struct mei_device *dev,
>         dev_dbg(dev->dev, MEI_HDR_FMT, MEI_HDR_PRM((struct mei_msg_hdr *)hdr));
>
>         empty_slots = mei_hbuf_empty_slots(dev);
> -       dev_dbg(dev->dev, "empty slots = %hu.\n", empty_slots);
> +       dev_dbg(dev->dev, "empty slots = %d.\n", empty_slots);
>
>         if (empty_slots < 0)
>                 return -EOVERFLOW;
> --
> 2.37.0.rc0.161.g10f37bed90-goog
>


-- 
Thanks,
~Nick Desaulniers

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-07-08 23:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-08 20:35 [PATCH] mei: me: fix clang -Wformat warning Justin Stitt
2022-07-08 23:39 ` Nick Desaulniers

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