Skip to contentSkip to conversation

support: kconfig: Fix compiler warnings

PATCH Superseded Kanak Shilledar 1 participant 2 messages Apr 29

lore
Share & tools
lore
#0 lore raw

v3 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

 ...upport-kconfig-Fix-compiler-warnings.patch | 45 +++++++++++++++++++
 support/kconfig/patches/series                |  1 +
 2 files changed, 46 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
#1 lore raw

PATCH v3 1/1 support: kconfig: Fix compiler warnings

Add a new patch to fix the compiler warning given on Ubuntu 24.04.4 in util.c 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 v3:
* Updated the commit message
* Generated the patch using git format-patch, and added to the series.

--
Changes in v2:
* Changed from direct file fix to patch based fix.

---
 ...upport-kconfig-Fix-compiler-warnings.patch | 45 +++++++++++++++++++
 support/kconfig/patches/series                |  1 +
 2 files changed, 46 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 +45 -0
new file mode 100644
index 0000000000..4c76274123
@@ -0,0 +1,45 @@
+From 392624743e7166a056474cd83b18743409d2556c Mon Sep 17 00:00:00 2001
+From: Kanak Shilledar <[email protected]>
+Date: Fri, 24 Apr 2026 13:32:36 +0200
+Subject: [PATCH] support: kconfig: Fix compiler warnings
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+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.
+
+Signed-off-by: Kanak Shilledar <[email protected]>
+---
+ support/kconfig/util.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/support/kconfig/util.c b/support/kconfig/util.c
+index 8665f5bb89..c2e7979ac1 100644
+--- a/support/kconfig/util.c
++++ b/support/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;
+-- 
+2.43.0
+
support/kconfig/patches/series +1 -0
index cc176035be..ca2193e734 100644
@@ -12,3 +12,4 @@
 21-Avoid-false-positive-matches-from-comment-lines.patch
 22-kconfig-lxdialog-fix-check-with-GCC14.patch
 23-kconfig-mn-conf-handle-backspace-H-key.patch
+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