]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
platform/x86/intel/tpmi/plr: Make char[] longer to silence warning
authorIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Tue, 10 Dec 2024 14:01:14 +0000 (16:01 +0200)
committerIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Tue, 17 Dec 2024 11:13:01 +0000 (13:13 +0200)
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/20241210140115.1375-1-ilpo.jarvinen@linux.intel.com
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
drivers/platform/x86/intel/plr_tpmi.c

index 691d43c3592c27bfe8ec544cc82a0da6b24c487c..2b55347a5a93b509510a4676613513e574f079ca 100644 (file)
@@ -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);