kconfig: nconf: Format and print 'line' without a temporary copy
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
@@ -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
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.Signed-off-by Thorsten Blum <[email protected]>--- 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
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]>