* [PATCH] kconfig: nconf: Format and print 'line' without a temporary copy
@ 2025-08-11 16:16 Thorsten Blum
2025-08-14 7:42 ` Nicolas Schier
2025-08-18 18:14 ` Nathan Chancellor
0 siblings, 2 replies; 3+ messages in thread
From: Thorsten Blum @ 2025-08-11 16:16 UTC (permalink / raw)
To: Masahiro Yamada, Thorsten Blum, Randy Dunlap, Shankari Anand,
Nicolas Schier
Cc: linux-kbuild, linux-kernel
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@linux.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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] kconfig: nconf: Format and print 'line' without a temporary copy
2025-08-11 16:16 [PATCH] kconfig: nconf: Format and print 'line' without a temporary copy Thorsten Blum
@ 2025-08-14 7:42 ` Nicolas Schier
2025-08-18 18:14 ` Nathan Chancellor
1 sibling, 0 replies; 3+ messages in thread
From: Nicolas Schier @ 2025-08-14 7:42 UTC (permalink / raw)
To: Thorsten Blum
Cc: Masahiro Yamada, Randy Dunlap, Shankari Anand, linux-kbuild,
linux-kernel
On Mon, Aug 11, 2025 at 06:16:48PM +0200, Thorsten Blum wrote:
> 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@linux.dev>
> ---
> scripts/kconfig/nconf.gui.c | 8 +++-----
> 1 file changed, 3 insertions(+), 5 deletions(-)
>
thanks!
Reviewed-by: Nicolas Schier <nsc@kernel.org>
As kconfig is currently orphaned, I am going to take this via kbuild
tree.
Kind regards,
Nicolas
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] kconfig: nconf: Format and print 'line' without a temporary copy
2025-08-11 16:16 [PATCH] kconfig: nconf: Format and print 'line' without a temporary copy Thorsten Blum
2025-08-14 7:42 ` Nicolas Schier
@ 2025-08-18 18:14 ` Nathan Chancellor
1 sibling, 0 replies; 3+ messages in thread
From: Nathan Chancellor @ 2025-08-18 18:14 UTC (permalink / raw)
To: Masahiro Yamada, Randy Dunlap, Shankari Anand, Nicolas Schier,
Thorsten Blum
Cc: linux-kbuild, linux-kernel
On Mon, 11 Aug 2025 18:16:48 +0200, Thorsten Blum wrote:
> 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,
--
Nathan Chancellor <nathan@kernel.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-08-18 18:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-11 16:16 [PATCH] kconfig: nconf: Format and print 'line' without a temporary copy Thorsten Blum
2025-08-14 7:42 ` Nicolas Schier
2025-08-18 18:14 ` Nathan Chancellor
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).