Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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@linux.dev>
Reviewed-by: Nicolas Schier <nsc@kernel.org>
Link: https://lore.kernel.org/r/20250811161650.37428-2-thorsten.blum@linux.dev
Signed-off-by: Nathan Chancellor <nathan@kernel.org>

authored by

Thorsten Blum and committed by
Nathan Chancellor
35883b03 2d0ec4a9

+3 -5
+3 -5
scripts/kconfig/nconf.gui.c
··· 173 173 /* do not go over end of line */ 174 174 total_lines = min(total_lines, y); 175 175 for (i = 0; i < total_lines; i++) { 176 - char tmp[x+10]; 177 176 const char *line = get_line(text, i); 178 - int len = get_line_length(line); 179 - strncpy(tmp, line, min(len, x)); 180 - tmp[len] = '\0'; 181 - mvwprintw(win, i, 0, "%s", tmp); 177 + int len = min(get_line_length(line), x); 178 + 179 + mvwprintw(win, i, 0, "%.*s", len, line); 182 180 } 183 181 } 184 182