Skip to contentSkip to conversation

mei: me: fix clang -Wformat warning

PATCH In review Justin Stitt 2 participants 2 messages Jul 8, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mei: me: fix clang -Wformat warning

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.

---
 drivers/misc/mei/hw-me.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/mei/hw-me.c +1 -1
index befa491e3344..3a95fe7d4e33 100644
@@ -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;
Signature · 1 line
2.37.0.rc0.161.g10f37bed90-goog
Reviewed-by Tested-by on v1 1/1
#1 lore raw
Quoted 11 lines · 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.

Thanks for the patch! This fixes the warning I observe when building x86_64 allmodconfig with -Wno-format removed.

Quoted 20 lines
---
 drivers/misc/mei/hw-me.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/mei/hw-me.c +1 -2
index befa491e3344..3a95fe7d4e33 100644
@@ -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

Signature · 2 lines
Thanks,
~Nick Desaulniers