EDAC/amd64: avoid -Wformat-security warning
Subsystems (2)
PATCH 1/1 EDAC/amd64: avoid -Wformat-security warning
From: Arnd Bergmann <[email protected]>
Using a variable as a format string causes a (default-disabled) warning:
drivers/edac/amd64_edac.c: In function 'per_family_init':drivers/edac/amd64_edac.c:3914:17: error: format not a string literal and no format arguments [-Werror=format-security]
3914 | scnprintf(pvt->ctl_name, sizeof(pvt->ctl_name), tmp_name);
| ^~~~~~~~~The code here is safe, but in order to enable the warning by default in the future, change this instance to pass the name indirectly.
--- drivers/edac/amd64_edac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/edac/amd64_edac.c +1 -1
@@ -3911,7 +3911,7 @@ static int per_family_init(struct amd64_pvt *pvt) }if (tmp_name) -scnprintf (pvt->ctl_name,sizeof (pvt->ctl_name), tmp_name); +scnprintf (pvt->ctl_name,sizeof (pvt->ctl_name),"%s" , tmp_name);else scnprintf (pvt->ctl_name,sizeof (pvt->ctl_name),"F%02Xh_M%02Xh" , pvt->fam, pvt->model);
Signature · 1 line
2.39.5
Quoted 22 lines
From: Arnd Bergmann <[email protected]>
Sent: Thursday, December 4, 2025 6:02 PM
To: Yazen Ghannam <[email protected]>; Borislav Petkov <[email protected]>; Luck, Tony <[email protected]>; Avadhut Naik <[email protected]>
Cc: Arnd Bergmann <[email protected]>; Ingo Molnar <[email protected]>; Zhuo, Qiuxu <[email protected]>; Thorsten Blum <[email protected]>; Mario Limonciello <[email protected]>; [email protected]; linux- [email protected]
Subject: [PATCH] EDAC/amd64: avoid -Wformat-security warningFrom: Arnd Bergmann <[email protected]>
Using a variable as a format string causes a (default-disabled) warning:
drivers/edac/amd64_edac.c: In function 'per_family_init':drivers/edac/amd64_edac.c:3914:17: error: format not a string literal and no format arguments [-Werror=format-security]3914 | scnprintf(pvt->ctl_name, sizeof(pvt->ctl_name), tmp_name); | ^~~~~~~~~
Quoted 6 lines
The code here is safe, but in order to enable the warning by default in the future, change this instance to pass the name indirectly.
Fixes e9abd990aefd ("EDAC/amd64: Generate ctl_name string at runtime")Signed-off-by Arnd Bergmann <[email protected]>---
LGTM. Thanks!
[...]
Quoted 23 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
Using a variable as a format string causes a (default-disabled) warning:
drivers/edac/amd64_edac.c: In function 'per_family_init':drivers/edac/amd64_edac.c:3914:17: error: format not a string literal and no format arguments [-Werror=format-security]3914 | scnprintf(pvt->ctl_name, sizeof(pvt->ctl_name), tmp_name); | ^~~~~~~~~The code here is safe, but in order to enable the warning by default in the future, change this instance to pass the name indirectly.
Fixes e9abd990aefd ("EDAC/amd64: Generate ctl_name string at runtime")Signed-off-by Arnd Bergmann <[email protected]>--- drivers/edac/amd64_edac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/edac/amd64_edac.c +0
-0
drivers/edac/amd64_edac.c static int per_family_init(struct amd64_pvt *pvt) · line 3917
Quoted 8 lines
drivers/edac/amd64_edac.c +1
-1@@ -3911,7 +3911,7 @@ static int per_family_init(struct amd64_pvt *pvt) }if (tmp_name) -scnprintf (pvt->ctl_name,sizeof (pvt->ctl_name), tmp_name); +scnprintf (pvt->ctl_name,sizeof (pvt->ctl_name),"%s" , tmp_name);else scnprintf (pvt->ctl_name,sizeof (pvt->ctl_name),"F%02Xh_M%02Xh" , pvt->fam, pvt->model);
Thanks for fixing this!
Signature · 2 lines
Thanks, Avadhut Naik
Quoted 9 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
Using a variable as a format string causes a (default-disabled) warning:
drivers/edac/amd64_edac.c: In function 'per_family_init':drivers/edac/amd64_edac.c:3914:17: error: format not a string literal and no format arguments [-Werror=format-security]3914 | scnprintf(pvt->ctl_name, sizeof(pvt->ctl_name), tmp_name); | ^~~~~~~~~
Quoted 6 lines
The code here is safe, but in order to enable the warning by default in the future, change this instance to pass the name indirectly.
Fixes e9abd990aefd ("EDAC/amd64: Generate ctl_name string at runtime")Signed-off-by Arnd Bergmann <[email protected]>---
Thanks,
Yazen
Quoted 24 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
Using a variable as a format string causes a (default-disabled) warning:
drivers/edac/amd64_edac.c: In function 'per_family_init':drivers/edac/amd64_edac.c:3914:17: error: format not a string literal and no format arguments [-Werror=format-security]3914 | scnprintf(pvt->ctl_name, sizeof(pvt->ctl_name), tmp_name); | ^~~~~~~~~The code here is safe, but in order to enable the warning by default in the future, change this instance to pass the name indirectly.
Fixes e9abd990aefd ("EDAC/amd64: Generate ctl_name string at runtime")Signed-off-by Arnd Bergmann <[email protected]>--- drivers/edac/amd64_edac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/edac/amd64_edac.c +0
-0
drivers/edac/amd64_edac.c static int per_family_init(struct amd64_pvt *pvt) · line 3917
Quoted 8 lines
drivers/edac/amd64_edac.c +1
-1@@ -3911,7 +3911,7 @@ static int per_family_init(struct amd64_pvt *pvt) }if (tmp_name) -scnprintf (pvt->ctl_name,sizeof (pvt->ctl_name), tmp_name); +scnprintf (pvt->ctl_name,sizeof (pvt->ctl_name),"%s" , tmp_name);else scnprintf (pvt->ctl_name,sizeof (pvt->ctl_name),"F%02Xh_M%02Xh" , pvt->fam, pvt->model);
Applied, thanks.
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette