[PATCH v4 04/12] cper: Return actual bytes written by DIMM location helpers

From: Pierre Gondois

Date: Fri Nov 13 2026 - 11:16:49 EST


Use scnprintf() instead of snprintf() to return the actual chars
written to the buffer in:
- cper_dimm_err_location()
- cper_dimm_err2_location()

This allows to make the buffer progress correctly in
the caller function.

Signed-off-by: Pierre Gondois <pierre.gondois@xxxxxxx>
---
drivers/firmware/efi/cper.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/firmware/efi/cper.c b/drivers/firmware/efi/cper.c
index 218f560a2796..d8587141f8b2 100644
--- a/drivers/firmware/efi/cper.c
+++ b/drivers/firmware/efi/cper.c
@@ -364,11 +364,11 @@ int cper_dimm_err_location(struct cper_mem_err_compact *mem, char *msg)
len = CPER_REC_LEN;
dmi_memdev_name(mem->mem_dev_handle, &bank, &device);
if (bank && device)
- n = snprintf(msg, len, "DIMM location: %s %s ", bank, device);
+ n = scnprintf(msg, len, "DIMM location: %s %s ", bank, device);
else
- n = snprintf(msg, len,
- "DIMM location: not present. DMI handle: 0x%.4x ",
- mem->mem_dev_handle);
+ n = scnprintf(msg, len,
+ "DIMM location: not present. DMI handle: 0x%.4x ",
+ mem->mem_dev_handle);

return n;
}
@@ -531,11 +531,11 @@ int cper_dimm_err2_location(const struct cper_sec_mem_err2 *mem, char *msg)

len = CPER_REC_LEN;
if (bank && device)
- n = snprintf(msg, len, "DIMM location: %s %s ", bank, device);
+ n = scnprintf(msg, len, "DIMM location: %s %s ", bank, device);
else
- n = snprintf(msg, len,
- "DIMM location: not present. DMI handle: 0x%.8x ",
- mem->mem_dev_handle);
+ n = scnprintf(msg, len,
+ "DIMM location: not present. DMI handle: 0x%.8x ",
+ mem->mem_dev_handle);

return n;
}
--
2.43.0