[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20250811161650.37428-2-thorsten.blum@linux.dev>
Date: Mon, 11 Aug 2025 18:16:48 +0200
From: Thorsten Blum <thorsten.blum@...ux.dev>
To: Masahiro Yamada <masahiroy@...nel.org>,
Thorsten Blum <thorsten.blum@...ux.dev>,
Randy Dunlap <rdunlap@...radead.org>,
Shankari Anand <shankari.ak0208@...il.com>,
Nicolas Schier <nicolas.schier@...ux.dev>
Cc: linux-kbuild@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH] 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.
Signed-off-by: Thorsten Blum <thorsten.blum@...ux.dev>
---
scripts/kconfig/nconf.gui.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/scripts/kconfig/nconf.gui.c b/scripts/kconfig/nconf.gui.c
index 7206437e784a..2d097bc7ef1a 100644
--- a/scripts/kconfig/nconf.gui.c
+++ b/scripts/kconfig/nconf.gui.c
@@ -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);
}
}
--
2.50.1
Powered by blists - more mailing lists