Skip to contentSkip to conversation

kconfig: nconf: Format and print 'line' without a temporary copy

PATCH Applied Thorsten Blum 3 participants 3 messages Aug 11, 2025 – Aug 18, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kconfig: nconf: Format and print 'line' without a temporary copy

Use "%.*s" as the format specifier and supply the 'line' length 'len' to mvwprintw() to format and print each line without making a temporary copy. Remove the temporary buffer.

---
 scripts/kconfig/nconf.gui.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
scripts/kconfig/nconf.gui.c +3 -5
index 7206437e784a..2d097bc7ef1a 100644
@@ -173,12 +173,10 @@ void fill_window(WINDOW *win, const char *text)
 	/* do not go over end of line */
 	total_lines = min(total_lines, y);
 	for (i = 0; i < total_lines; i++) {
-		char tmp[x+10];
 		const char *line = get_line(text, i);
-		int len = get_line_length(line);
-		strncpy(tmp, line, min(len, x));
-		tmp[len] = '\0';
-		mvwprintw(win, i, 0, "%s", tmp);
+		int len = min(get_line_length(line), x);
+
+		mvwprintw(win, i, 0, "%.*s", len, line);
 	}
 }
 
Signature · 1 line
2.50.1
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Thorsten Blum

Use "%.*s" as the format specifier and supply the 'line' length 'len' to mvwprintw() to format and print each line without making a temporary copy. Remove the temporary buffer.

---
 scripts/kconfig/nconf.gui.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

thanks!

As kconfig is currently orphaned, I am going to take this via kbuild tree.

Kind regards,
Nicolas

maintainer Applied
#2 lore raw
In reply to Thorsten Blum
Quoted 5 lines · Thorsten Blum

Use "%.*s" as the format specifier and supply the 'line' length 'len' to mvwprintw() to format and print each line without making a temporary copy. Remove the temporary buffer.

Applied, thanks!

[1/1] kconfig: nconf: Format and print 'line' without a temporary copy

      https://git.kernel.org/kbuild/c/35883b030c5f1

Best regards,

Signature · 1 line
Nathan Chancellor <[email protected]>