Skip to content

Commit 532ad47

Browse files
committed
platform/x86/intel/tpmi/plr: Make char[] longer to silence warning
JIRA: https://issues.redhat.com/browse/RHEL-79669 commit 3bc0183 Author: Ilpo Järvinen <[email protected]> Date: Tue Dec 10 16:01:14 2024 +0200 platform/x86/intel/tpmi/plr: Make char[] longer to silence warning W=1 build triggers this warning: drivers/platform/x86/intel/plr_tpmi.c:315:55: error: ‘snprintf’ output may be truncated before the last format character [-Werror=format-truncation=] 315 | snprintf(name, sizeof(name), "domain%d", i); | ^ drivers/platform/x86/intel/plr_tpmi.c:315:17: note: ‘snprintf’ output between 8 and 17 bytes into a destination of size 16 315 | snprintf(name, sizeof(name), "domain%d", i); Inspecting the code tells that maximum i in intel_plr_probe() will fit into u8 because it comes from: struct intel_tpmi_pfs_entry { ... u64 num_entries:8; ...but compiler does not know that. Saving one byte in name[] at the expense of a warning with W=1 seems a bad trade so simply make it name[17]. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Ilpo Järvinen <[email protected]> Reviewed-by: Ilpo Järvinen <[email protected]> Signed-off-by: David Arcari <[email protected]>
1 parent 3d1ffbe commit 532ad47

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/platform/x86/intel/plr_tpmi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ static int intel_plr_probe(struct auxiliary_device *auxdev, const struct auxilia
262262
struct resource *res;
263263
struct tpmi_plr *plr;
264264
void __iomem *base;
265-
char name[16];
265+
char name[17];
266266
int err;
267267

268268
plat_info = tpmi_get_platform_data(auxdev);

0 commit comments

Comments
 (0)