* [PATCH 1/1] platform/x86/intel/tpmi/plr: Make char[] longer to silence warning
@ 2024-12-10 14:01 Ilpo Järvinen
2024-12-12 14:47 ` Ilpo Järvinen
0 siblings, 1 reply; 2+ messages in thread
From: Ilpo Järvinen @ 2024-12-10 14:01 UTC (permalink / raw)
To: Hans de Goede, Ilpo Järvinen, platform-driver-x86,
linux-kernel
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].
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
drivers/platform/x86/intel/plr_tpmi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/platform/x86/intel/plr_tpmi.c b/drivers/platform/x86/intel/plr_tpmi.c
index 69ace6a629bc..f57c61842622 100644
--- a/drivers/platform/x86/intel/plr_tpmi.c
+++ b/drivers/platform/x86/intel/plr_tpmi.c
@@ -262,7 +262,7 @@ static int intel_plr_probe(struct auxiliary_device *auxdev, const struct auxilia
struct resource *res;
struct tpmi_plr *plr;
void __iomem *base;
- char name[16];
+ char name[17];
int err;
plat_info = tpmi_get_platform_data(auxdev);
--
2.39.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 1/1] platform/x86/intel/tpmi/plr: Make char[] longer to silence warning
2024-12-10 14:01 [PATCH 1/1] platform/x86/intel/tpmi/plr: Make char[] longer to silence warning Ilpo Järvinen
@ 2024-12-12 14:47 ` Ilpo Järvinen
0 siblings, 0 replies; 2+ messages in thread
From: Ilpo Järvinen @ 2024-12-12 14:47 UTC (permalink / raw)
To: Hans de Goede, platform-driver-x86, linux-kernel,
Ilpo Järvinen
On Tue, 10 Dec 2024 16:01:14 +0200, Ilpo Järvinen wrote:
> 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);
>
> [...]
Thank you for your contribution, it has been applied to my local
review-ilpo-next branch. Note it will show up in the public
platform-drivers-x86/review-ilpo-next branch only once I've pushed my
local branch there, which might take a while.
The list of commits applied:
[1/1] platform/x86/intel/tpmi/plr: Make char[] longer to silence warning
commit: 45ec7a0a788372ae3d83c1142ddde52ae09606e5
--
i.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-12-12 14:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-10 14:01 [PATCH 1/1] platform/x86/intel/tpmi/plr: Make char[] longer to silence warning Ilpo Järvinen
2024-12-12 14:47 ` Ilpo Järvinen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox