kdb: Remove optional size arguments from strscpy() calls
authorThorsten Blum <thorsten.blum@linux.dev>
Wed, 19 Mar 2025 16:33:39 +0000 (17:33 +0100)
committerDaniel Thompson <daniel@riscstar.com>
Fri, 28 Mar 2025 21:28:28 +0000 (21:28 +0000)
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>
kernel/debug/kdb/kdb_io.c

index 6a77f1c779c4cc8b3fa10b9125a7765350b5b8b2..9b11b10b120cf07e451a7a4d92ce50f9a6c066b2 100644 (file)
@@ -334,7 +334,7 @@ poll_again:
                *cp = '\0';
                p_tmp = strrchr(buffer, ' ');
                p_tmp = (p_tmp ? p_tmp + 1 : buffer);
-               strscpy(tmpbuffer, p_tmp, sizeof(tmpbuffer));
+               strscpy(tmpbuffer, p_tmp);
                *cp = tmp;
 
                len = strlen(tmpbuffer);
@@ -452,7 +452,7 @@ poll_again:
 char *kdb_getstr(char *buffer, size_t bufsize, const char *prompt)
 {
        if (prompt && kdb_prompt_str != prompt)
-               strscpy(kdb_prompt_str, prompt, CMD_BUFLEN);
+               strscpy(kdb_prompt_str, prompt);
        kdb_printf("%s", kdb_prompt_str);
        kdb_nextline = 1;       /* Prompt and input resets line number */
        return kdb_read(buffer, bufsize);