* [PATCH] hwmon: pmbus: ibm-cffps: avoid format truncation warnings
@ 2026-09-23 2:48 Eduard Zateev
2026-09-23 2:56 ` sashiko-bot
2026-09-24 17:01 ` Guenter Roeck
0 siblings, 2 replies; 3+ messages 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 related [flat|nested] 3+ messages in thread
* Re: [PATCH] hwmon: pmbus: ibm-cffps: avoid format truncation warnings
2026-09-23 2:48 [PATCH] hwmon: pmbus: ibm-cffps: avoid format truncation warnings Eduard Zateev
@ 2026-09-23 2:56 ` sashiko-bot
2026-09-24 17:01 ` Guenter Roeck
1 sibling, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-09-23 2:56 UTC (permalink / raw)
To: Eduard Zateev; +Cc: linux-hwmon
> 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>
Sashiko has reviewed this patch and found no issues. It looks great!
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260923024827.56445-1-hackerowskiy@gmail.com?part=1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] hwmon: pmbus: ibm-cffps: avoid format truncation warnings
2026-09-23 2:48 [PATCH] hwmon: pmbus: ibm-cffps: avoid format truncation warnings Eduard Zateev
2026-09-23 2:56 ` sashiko-bot
@ 2026-09-24 17:01 ` Guenter Roeck
1 sibling, 0 replies; 3+ messages in thread
From: Guenter Roeck @ 2026-09-24 17:01 UTC (permalink / raw)
To: Eduard Zateev; +Cc: linux-hwmon, linux-kernel
On Wed, Sep 23, 2026 at 04:48:27AM +0200, Eduard Zateev wrote:
> 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>
Applied.
Thanks,
Guenter
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-09-24 17:01 UTC | newest]
Thread overview: 3+ messages (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
2026-09-23 2:56 ` sashiko-bot
2026-09-24 17:01 ` Guenter Roeck
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.