kdb: unify CMD_BUFLEN definition into kdb_private.h

CMD_BUFLEN was defined separately in kdb_io.c (256) and kdb_main.c
(200), causing kdb_main.c to use the wrong size when formatting the
prompt string into kdb_prompt_str (which is 256 bytes).

Move CMD_BUFLEN (256) into kdb_private.h so all users share a single
consistent definition, and remove the local definitions from both
files.

Fixes: 5d5314d679 ("kdb: core for kgdb back end (1 of 2)")
Signed-off-by: Naveen Kumar Chaudhary <naveen.osdev@gmail.com>
Link: https://lore.kernel.org/r/l6b6bomrw3bvkehlv73fyghk6loz6jpdwqk5c4nthnhl7j7kzk@4jjhfpzv5zon
Signed-off-by: Daniel Thompson <daniel@riscstar.com>
This commit is contained in:
Naveen Kumar Chaudhary 2026-06-17 07:58:20 +05:30 committed by Daniel Thompson
parent 22d59ccad2
commit 2a05207458
3 changed files with 4 additions and 6 deletions

View File

@ -22,7 +22,6 @@
#include <linux/kallsyms.h>
#include "kdb_private.h"
#define CMD_BUFLEN 256
char kdb_prompt_str[CMD_BUFLEN];
int kdb_trap_printk;

View File

@ -784,8 +784,6 @@ static int kdb_exec_defcmd(int argc, const char **argv)
/* Command history */
#define KDB_CMD_HISTORY_COUNT 32
#define CMD_BUFLEN 200 /* kdb_printf: max printline
* size == 256 */
static unsigned int cmd_head, cmd_tail;
static unsigned int cmdptr;
static char cmd_hist[KDB_CMD_HISTORY_COUNT][CMD_BUFLEN];
@ -1266,8 +1264,8 @@ static int kdb_local(kdb_reason_t reason, int error, struct pt_regs *regs,
do_full_getstr:
/* PROMPT can only be set if we have MEM_READ permission. */
snprintf(kdb_prompt_str, CMD_BUFLEN, kdbgetenv("PROMPT"),
raw_smp_processor_id());
snprintf(kdb_prompt_str, CMD_BUFLEN,
kdbgetenv("PROMPT"), raw_smp_processor_id());
/*
* Fetch command from keyboard

View File

@ -225,7 +225,8 @@ extern void kdb_kbd_cleanup_state(void);
#define kdb_kbd_cleanup_state()
#endif /* ! CONFIG_KDB_KEYBOARD */
extern char kdb_prompt_str[];
#define CMD_BUFLEN 256
extern char kdb_prompt_str[CMD_BUFLEN];
#define KDB_WORD_SIZE ((int)sizeof(unsigned long))