Skip to content

Commit afdbe49

Browse files
tobluxdaniel-thompson
authored andcommitted
kdb: Remove optional size arguments from strscpy() calls
If the destination buffer has a fixed length, strscpy() automatically determines the size of the destination buffer using sizeof() if the argument is omitted. This makes the explicit sizeof() unnecessary. Furthermore, CMD_BUFLEN is equal to sizeof(kdb_prompt_str) and can also be removed. Remove them to shorten and simplify the code. No functional changes intended. Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev> Reviewed-by: Douglas Anderson <dianders@chromium.org> Reviewed-by: Justin Stitt <justinstitt@google.com> Link: https://lore.kernel.org/r/20250319163341.2123-2-thorsten.blum@linux.dev Signed-off-by: Daniel Thompson <daniel@riscstar.com>
1 parent a30d4ff commit afdbe49

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

kernel/debug/kdb/kdb_io.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ static char *kdb_read(char *buffer, size_t bufsize)
334334
*cp = '\0';
335335
p_tmp = strrchr(buffer, ' ');
336336
p_tmp = (p_tmp ? p_tmp + 1 : buffer);
337-
strscpy(tmpbuffer, p_tmp, sizeof(tmpbuffer));
337+
strscpy(tmpbuffer, p_tmp);
338338
*cp = tmp;
339339

340340
len = strlen(tmpbuffer);
@@ -452,7 +452,7 @@ static char *kdb_read(char *buffer, size_t bufsize)
452452
char *kdb_getstr(char *buffer, size_t bufsize, const char *prompt)
453453
{
454454
if (prompt && kdb_prompt_str != prompt)
455-
strscpy(kdb_prompt_str, prompt, CMD_BUFLEN);
455+
strscpy(kdb_prompt_str, prompt);
456456
kdb_printf("%s", kdb_prompt_str);
457457
kdb_nextline = 1; /* Prompt and input resets line number */
458458
return kdb_read(buffer, bufsize);

0 commit comments

Comments
 (0)