aboutsummaryrefslogtreecommitdiff
path: root/monitor
diff options
context:
space:
mode:
authorDongli Zhang <dongli.zhang@oracle.com>2023-02-06 20:52:41 -0800
committerMarkus Armbruster <armbru@redhat.com>2023-03-01 20:46:07 +0100
commit76f5801a836504b21cf71e93d5a522d92cb435ca (patch)
tree13f2c18897bf48a7eaf0ce40e70c88d0937e2600 /monitor
parent627634031092e1514f363fd8659a579398de0f0e (diff)
readline: fix hmp completion issue
The auto completion does not work in some cases. Case 1. 1. (qemu) info reg 2. Press 'Tab'. 3. It does not auto complete. Case 2. 1. (qemu) block_resize flo 2. Press 'Tab'. 3. It does not auto complete 'floppy0'. Since the readline_add_completion_of() may add any completion when strlen(pfx) is zero, we remove the check with (name[0] == '\0') because strlen() always returns zero in that case. Fixes: 52f50b1e9f8f ("readline: Extract readline_add_completion_of() from monitor") Cc: Joe Jin <joe.jin@oracle.com> Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com> Message-Id: <20230207045241.8843-1-dongli.zhang@oracle.com> Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Markus Armbruster <armbru@redhat.com> Tested-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
Diffstat (limited to 'monitor')
-rw-r--r--monitor/hmp.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/monitor/hmp.c b/monitor/hmp.c
index 2aa85d3982..fee410362f 100644
--- a/monitor/hmp.c
+++ b/monitor/hmp.c
@@ -1189,9 +1189,7 @@ static void cmd_completion(MonitorHMP *mon, const char *name, const char *list)
}
memcpy(cmd, pstart, len);
cmd[len] = '\0';
- if (name[0] == '\0') {
- readline_add_completion_of(mon->rs, name, cmd);
- }
+ readline_add_completion_of(mon->rs, name, cmd);
if (*p == '\0') {
break;
}
@@ -1335,9 +1333,7 @@ static void monitor_find_completion_by_table(MonitorHMP *mon,
/* block device name completion */
readline_set_completion_index(mon->rs, strlen(str));
while ((blk = blk_next(blk)) != NULL) {
- if (str[0] == '\0') {
- readline_add_completion_of(mon->rs, str, blk_name(blk));
- }
+ readline_add_completion_of(mon->rs, str, blk_name(blk));
}
break;
case 's':