All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kdb: Fix incorrect naming of history arrow keys in code
@ 2024-10-31 19:23 Nir Lichtman
  2024-10-31 23:06 ` Doug Anderson
  0 siblings, 1 reply; 8+ messages in thread
From: Nir Lichtman @ 2024-10-31 19:23 UTC (permalink / raw)
  To: jason.wessel, daniel.thompson, dianders, linux-kernel

Problem: The kdb CLI code that handles the history up and down
navigation incorrectly names the up and down arrows as ctrl p and n.

Details: This could be some kind of left over legacy.
(maybe inspired by ddb which only reacts to ctrl p and n for history nav).
kdb doesn't react to ctrl p and n, and following the code flow with GDB
reveals that these values map to the up and down arrows.

Solution: Rename the macros accordingly and rename the function name
to reflect that it relates to arrows and not ctrl commands.

Signed-off-by: Nir Lichtman <nir@lichtman.org>
---
 kernel/debug/kdb/kdb_main.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
index f5f7d7fb5936..d4b407afb888 100644
--- a/kernel/debug/kdb/kdb_main.c
+++ b/kernel/debug/kdb/kdb_main.c
@@ -1123,22 +1123,22 @@ int kdb_parse(const char *cmdstr)
 }
 
 
-static int handle_ctrl_cmd(char *cmd)
+static int handle_arrow_cmd(char *cmd)
 {
-#define CTRL_P	16
-#define CTRL_N	14
+#define ARROW_UP	16
+#define ARROW_DOWN	14
 
 	/* initial situation */
 	if (cmd_head == cmd_tail)
 		return 0;
 	switch (*cmd) {
-	case CTRL_P:
+	case ARROW_UP:
 		if (cmdptr != cmd_tail)
 			cmdptr = (cmdptr + KDB_CMD_HISTORY_COUNT - 1) %
 				 KDB_CMD_HISTORY_COUNT;
 		strscpy(cmd_cur, cmd_hist[cmdptr], CMD_BUFLEN);
 		return 1;
-	case CTRL_N:
+	case ARROW_DOWN:
 		if (cmdptr != cmd_head)
 			cmdptr = (cmdptr+1) % KDB_CMD_HISTORY_COUNT;
 		strscpy(cmd_cur, cmd_hist[cmdptr], CMD_BUFLEN);
@@ -1351,7 +1351,7 @@ static int kdb_local(kdb_reason_t reason, int error, struct pt_regs *regs,
 					*(cmd_hist[cmd_head] +
 					  strlen(cmd_hist[cmd_head])-1) = '\0';
 				}
-				if (!handle_ctrl_cmd(cmdbuf))
+				if (!handle_arrow_cmd(cmdbuf))
 					*(cmd_cur+strlen(cmd_cur)-1) = '\0';
 				cmdbuf = cmd_cur;
 				goto do_full_getstr;
-- 
2.39.2

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-11-01 19:28 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-31 19:23 [PATCH] kdb: Fix incorrect naming of history arrow keys in code Nir Lichtman
2024-10-31 23:06 ` Doug Anderson
2024-11-01  0:26   ` Nir Lichtman
2024-11-01  6:21     ` Nir Lichtman
2024-11-01 15:29     ` Doug Anderson
2024-11-01 18:34       ` Daniel Thompson
2024-11-01 18:57         ` Nir Lichtman
2024-11-01 19:28           ` Doug Anderson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.