* [PATCH] hwmon: pmbus: ibm-cffps: avoid format truncation warnings
@ 2026-09-23 2:48 Eduard Zateev
0 siblings, 0 replies; only message in thread
From: Eduard Zateev @ 2026-09-23 2:48 UTC (permalink / raw)
To: Guenter Roeck; +Cc: linux-hwmon, linux-kernel, Eduard Zateev
Building with W=1 reports format truncation warnings when formatting
the firmware version values for debugfs.
The SMBus helpers return the byte and word values as int, so the
compiler cannot infer that the formatted values fit into the small
temporary buffers. Cast the values to u8 and u16 before formatting
them.
This avoids the -Wformat-truncation warnings while keeping the existing
output format unchanged.
Signed-off-by: Eduard Zateev <hackerowskiy@gmail.com>
---
drivers/hwmon/pmbus/ibm-cffps.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/hwmon/pmbus/ibm-cffps.c b/drivers/hwmon/pmbus/ibm-cffps.c
index aad94bcb9ceb..2498c6f4778e 100644
--- a/drivers/hwmon/pmbus/ibm-cffps.c
+++ b/drivers/hwmon/pmbus/ibm-cffps.c
@@ -166,7 +166,7 @@ static ssize_t ibm_cffps_debugfs_read(struct file *file, char __user *buf,
if (rc < 0)
goto unlock;
- snprintf(&data[i * 2], 3, "%02X", rc);
+ snprintf(&data[i * 2], 3, "%02X", (u8)rc);
}
rc = i * 2;
@@ -177,7 +177,7 @@ static ssize_t ibm_cffps_debugfs_read(struct file *file, char __user *buf,
if (rc < 0)
goto unlock;
- snprintf(&data[i * 4], 5, "%04X", rc);
+ snprintf(&data[i * 4], 5, "%04X", (u16)rc);
}
rc = i * 4;
--
2.55.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-09-23 2:49 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-23 2:48 [PATCH] hwmon: pmbus: ibm-cffps: avoid format truncation warnings Eduard Zateev
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®