From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38638) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VEIZN-0006nO-Hk for qemu-devel@nongnu.org; Tue, 27 Aug 2013 08:40:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VEIZE-0000No-J0 for qemu-devel@nongnu.org; Tue, 27 Aug 2013 08:40:25 -0400 Received: from e23smtp04.au.ibm.com ([202.81.31.146]:39442) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VEIZD-0000NP-VV for qemu-devel@nongnu.org; Tue, 27 Aug 2013 08:40:16 -0400 Received: from /spool/local by e23smtp04.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 27 Aug 2013 22:23:01 +1000 Received: from d23relay05.au.ibm.com (d23relay05.au.ibm.com [9.190.235.152]) by d23dlp02.au.ibm.com (Postfix) with ESMTP id DE4142BB004F for ; Tue, 27 Aug 2013 22:40:11 +1000 (EST) Received: from d23av01.au.ibm.com (d23av01.au.ibm.com [9.190.234.96]) by d23relay05.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r7RCNvSu10355066 for ; Tue, 27 Aug 2013 22:23:58 +1000 Received: from d23av01.au.ibm.com (localhost [127.0.0.1]) by d23av01.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id r7RCeAaY031330 for ; Tue, 27 Aug 2013 22:40:11 +1000 From: Wenchao Xia Date: Tue, 27 Aug 2013 20:38:15 +0800 Message-Id: <1377607107-11612-4-git-send-email-xiawenc@linux.vnet.ibm.com> In-Reply-To: <1377607107-11612-1-git-send-email-xiawenc@linux.vnet.ibm.com> References: <1377607107-11612-1-git-send-email-xiawenc@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH V10 03/15] monitor: avoid use of global *cur_mon in block_completion_it() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Wenchao Xia , armbru@redhat.com, lcapitulino@redhat.com Signed-off-by: Wenchao Xia Reviewed-by: Eric Blake --- monitor.c | 18 ++++++++++++++---- 1 files changed, 14 insertions(+), 4 deletions(-) diff --git a/monitor.c b/monitor.c index a59a402..d1a6bda 100644 --- a/monitor.c +++ b/monitor.c @@ -4090,14 +4090,21 @@ static void file_completion(Monitor *mon, const char *input) closedir(ffs); } +typedef struct MonitorBlockComplete { + Monitor *mon; + const char *input; +} MonitorBlockComplete; + static void block_completion_it(void *opaque, BlockDriverState *bs) { const char *name = bdrv_get_device_name(bs); - const char *input = opaque; + MonitorBlockComplete *mbc = opaque; + Monitor *mon = mbc->mon; + const char *input = mbc->input; if (input[0] == '\0' || !strncmp(name, (char *)input, strlen(input))) { - readline_add_completion(cur_mon->rs, name); + readline_add_completion(mon->rs, name); } } @@ -4141,6 +4148,7 @@ static void monitor_find_completion(const char *cmdline) const char *ptype, *str; const mon_cmd_t *cmd; Monitor *mon = cur_mon; + MonitorBlockComplete mbs; parse_cmdline(cmdline, &nb_args, args); #ifdef DEBUG_COMPLETION @@ -4199,8 +4207,10 @@ static void monitor_find_completion(const char *cmdline) break; case 'B': /* block device name completion */ - readline_set_completion_index(cur_mon->rs, strlen(str)); - bdrv_iterate(block_completion_it, (void *)str); + mbs.mon = mon; + mbs.input = str; + readline_set_completion_index(mon->rs, strlen(str)); + bdrv_iterate(block_completion_it, &mbs); break; case 's': /* XXX: more generic ? */ -- 1.7.1