support: kconfig: Fix compiler warnings
v2 cover support: kconfig: Fix compiler warnings
Hi,
While building the master branch on Ubuntu 24.04.4 I am getting the warning of -Wformat-overflow=.
```
./util.c: In function ‘file_write_dep’:
./util.c:86:26: warning: ‘%s’ directive writing 10 or more bytes into a region of size between 1 and 4097 [-Wformat-overflow=]
86 | sprintf(buf2, "%s%s", dir, name);
| ^~
./util.c:86:9: note: ‘sprintf’ output 11 or more bytes (assuming 4107) into a destination of size 4097
86 | sprintf(buf2, "%s%s", dir, name);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```I tried this on the release 2026.02.x and this warning exists there as well. I am running GCC version (Ubuntu 13.3.0-6ubuntu2~24.04.1) 13.3.0
Kanak Shilledar (1):
support: kconfig: Fix compiler warnings
.../24-support-kconfig-fix-compiler-warnings.patch | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 support/kconfig/patches/24-support-kconfig-fix-compiler-warnings.patch
Signature · 6 lines
2.43.0 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH v2 1/1 support: kconfig: Fix compiler warnings
On Ubuntu 24.04.4, the compiler gives the warning of -Wformat-overflow=.
```
./util.c: In function ‘file_write_dep’:
./util.c:86:26: warning: ‘%s’ directive writing 10 or more bytes into a region of size between 1 and 4097 [-Wformat-overflow=]
86 | sprintf(buf2, "%s%s", dir, name);
| ^~
./util.c:86:9: note: ‘sprintf’ output 11 or more bytes (assuming 4107) into a destination of size 4097
86 | sprintf(buf2, "%s%s", dir, name);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```Update buf2 to PATH_MAX+20 similar to buf, thus giving enough headroom for the filename suffix.
--
Changes in v2:
* Changed from direct file fix to patch based fix.
--- .../24-support-kconfig-fix-compiler-warnings.patch | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 support/kconfig/patches/24-support-kconfig-fix-compiler-warnings.patch
support/kconfig/patches/24-support-kconfig-fix-compiler-warnings.patch new file +14 -0
@@ -0,0 +1,14 @@ +Index: kconfig/util.c +=================================================================== +--- kconfig.orig/util.c ++++ kconfig/util.c +@@ -35,7 +35,7 @@ struct file *file_lookup(const char *name) + int file_write_dep(const char *name) + { + char *str; +- char buf[PATH_MAX+20], buf2[PATH_MAX+1], dir[PATH_MAX+1]; ++ char buf[PATH_MAX+20], buf2[PATH_MAX+20], dir[PATH_MAX+1]; + struct symbol *sym, *env_sym; + struct expr *e; + struct file *file; +
Signature · 6 lines
2.43.0 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Quoted 17 lines · Kanak Shilledar
On Ubuntu 24.04.4, the compiler gives the warning of
-Wformat-overflow=.``` ./util.c: In function ‘file_write_dep’: ./util.c:86:26: warning: ‘%s’ directive writing 10 or more bytes into a region of size between 1 and 4097 [-Wformat-overflow=] 86 | sprintf(buf2, "%s%s", dir, name); | ^~ ./util.c:86:9: note: ‘sprintf’ output 11 or more bytes (assuming 4107) into a destination of size 4097 86 | sprintf(buf2, "%s%s", dir, name); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ```Update
buf2toPATH_MAX+20similar tobuf, thus giving enough headroom for the filename suffix.
Quoted 8 lines
--
Changes in v2:
* Changed from direct file fix to patch based fix.Signed-off-by Kanak Shilledar <[email protected]>--- .../24-support-kconfig-fix-compiler-warnings.patch | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
It requires to add this patch to support/kconfig/patches/series.
support/kconfig/patches/24-support-kconfig-fix-compiler-warnings.patch line 2
Quoted 10 lines
create mode 100644 support/kconfig/patches/24-support-kconfig-fix-compiler-warnings.patchsupport/kconfig/patches/24-support-kconfig-fix-compiler-warnings.patch new file +2
-0@@ -0,0 +1,14 @@ +Index: kconfig/util.c +===================================================================
Maybe use git patch (used in 22-kconfig-lxdialog-fix-check-with-GCC14.patch or 23-kconfig-mn-conf-handle-backspace-H-key.patch) to have the reason documented in the patch itself?
Kind regards,
Petr
Quoted 13 lines
support/kconfig/patches/24-support-kconfig-fix-compiler-warnings.patch new file +12
-1+--- kconfig.orig/util.c ++++ kconfig/util.c +@@ -35,7 +35,7 @@ struct file *file_lookup(const char *name) + int file_write_dep(const char *name) + { + char *str; +- char buf[PATH_MAX+20], buf2[PATH_MAX+1], dir[PATH_MAX+1]; ++ char buf[PATH_MAX+20], buf2[PATH_MAX+20], dir[PATH_MAX+1]; + struct symbol *sym, *env_sym; + struct expr *e; + struct file *file; + --
Quoted 2 lines
2.43.0
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot