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