Skip to content

Commit 35883b0

Browse files
tobluxnathanchance
authored andcommitted
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>
1 parent 2d0ec4a commit 35883b0

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

scripts/kconfig/nconf.gui.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,12 +173,10 @@ void fill_window(WINDOW *win, const char *text)
173173
/* do not go over end of line */
174174
total_lines = min(total_lines, y);
175175
for (i = 0; i < total_lines; i++) {
176-
char tmp[x+10];
177176
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);
182180
}
183181
}
184182

0 commit comments

Comments
 (0)