From patchwork Wed Aug 26 17:05:45 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 32201 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by bilbo.ozlabs.org (Postfix) with ESMTPS id 743DDB70CF for ; Thu, 27 Aug 2009 04:20:44 +1000 (EST) Received: from localhost ([127.0.0.1]:37063 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MgN6u-0007L7-NO for incoming@patchwork.ozlabs.org; Wed, 26 Aug 2009 14:20:40 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MgLxr-0003zL-L7 for qemu-devel@nongnu.org; Wed, 26 Aug 2009 13:07:15 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MgLxm-0003tU-KS for qemu-devel@nongnu.org; Wed, 26 Aug 2009 13:07:15 -0400 Received: from [199.232.76.173] (port=45832 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MgLxm-0003sw-7t for qemu-devel@nongnu.org; Wed, 26 Aug 2009 13:07:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:15515) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MgLxl-0000qJ-Fz for qemu-devel@nongnu.org; Wed, 26 Aug 2009 13:07:09 -0400 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n7QH78cA012548; Wed, 26 Aug 2009 13:07:08 -0400 Received: from localhost (vpn-10-90.bos.redhat.com [10.16.10.90]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n7QH77BC005744; Wed, 26 Aug 2009 13:07:07 -0400 From: Luiz Capitulino To: qemu-devel@nongnu.org Date: Wed, 26 Aug 2009 14:05:45 -0300 Message-Id: <1251306352-31316-23-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1251306352-31316-1-git-send-email-lcapitulino@redhat.com> References: <1251306352-31316-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.16 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: aliguori@us.ibm.com, avi@redhat.com Subject: [Qemu-devel] [PATCH 22/29] monitor: Drop args[] handling code X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This commit drops all the code used to handle the 'args[]' array, as now we use a dictionary to pass arguments. Signed-off-by: Luiz Capitulino --- monitor.c | 71 ++++++++---------------------------------------------------- 1 files changed, 10 insertions(+), 61 deletions(-) diff --git a/monitor.c b/monitor.c index 2334f7a..68fbf34 100644 --- a/monitor.c +++ b/monitor.c @@ -2572,12 +2572,11 @@ static const mon_cmd_t *monitor_parse_command(Monitor *mon, QDict *qdict) { const char *p, *typestr; - int c, nb_args, has_arg; + int c; const mon_cmd_t *cmd; char cmdname[256]; char buf[1024]; char *key; - void *args[MAX_ARGS]; #ifdef DEBUG monitor_printf(mon, "command='%s'\n", cmdline); @@ -2601,7 +2600,6 @@ static const mon_cmd_t *monitor_parse_command(Monitor *mon, /* parse the parameters */ typestr = cmd->args_type; - nb_args = 0; for(;;) { typestr = key_get_info(typestr, &key); if (!typestr) @@ -2614,7 +2612,6 @@ static const mon_cmd_t *monitor_parse_command(Monitor *mon, case 's': { int ret; - char *str; while (qemu_isspace(*p)) p++; @@ -2622,8 +2619,7 @@ static const mon_cmd_t *monitor_parse_command(Monitor *mon, typestr++; if (*p == '\0') { /* no optional string: NULL argument */ - str = NULL; - goto add_str; + break; } } ret = get_str(buf, sizeof(buf), &p); @@ -2643,18 +2639,7 @@ static const mon_cmd_t *monitor_parse_command(Monitor *mon, } goto fail; } - str = qemu_malloc(strlen(buf) + 1); - pstrcpy(str, sizeof(buf), buf); - add_str: - if (nb_args >= MAX_ARGS) { - error_args: - monitor_printf(mon, "%s: too many arguments\n", cmdname); - goto fail; - } - args[nb_args++] = str; - if (str) - qdict_put(qdict, key, qstring_from_str(str)); - qemu_free(str); + qdict_put(qdict, key, qstring_from_str(buf)); } break; case '/': @@ -2731,11 +2716,6 @@ static const mon_cmd_t *monitor_parse_command(Monitor *mon, size = -1; } } - if (nb_args + 3 > MAX_ARGS) - goto error_args; - args[nb_args++] = (void*)(long)count; - args[nb_args++] = (void*)(long)format; - args[nb_args++] = (void*)(long)size; qdict_put(qdict, "count", qint_from_int(count)); qdict_put(qdict, "format", qint_from_int(format)); qdict_put(qdict, "size", qint_from_int(size)); @@ -2745,58 +2725,30 @@ static const mon_cmd_t *monitor_parse_command(Monitor *mon, case 'l': { int64_t val; - int dict_add = 1; while (qemu_isspace(*p)) p++; if (*typestr == '?' || *typestr == '.') { if (*typestr == '?') { - if (*p == '\0') - has_arg = 0; - else - has_arg = 1; + if (*p == '\0') { + typestr++; + break; + } } else { if (*p == '.') { p++; while (qemu_isspace(*p)) p++; - has_arg = 1; } else { - has_arg = 0; + typestr++; + break; } } typestr++; - if (nb_args >= MAX_ARGS) - goto error_args; - dict_add = has_arg; - args[nb_args++] = (void *)(long)has_arg; - if (!has_arg) { - if (nb_args >= MAX_ARGS) - goto error_args; - val = -1; - goto add_num; - } } if (get_expr(mon, &val, &p)) goto fail; - add_num: - if (c == 'i') { - if (nb_args >= MAX_ARGS) - goto error_args; - args[nb_args++] = (void *)(long)val; - if (dict_add) - qdict_put(qdict, key, qint_from_int(val)); - } else { - if ((nb_args + 1) >= MAX_ARGS) - goto error_args; -#if TARGET_PHYS_ADDR_BITS > 32 - args[nb_args++] = (void *)(long)((val >> 32) & 0xffffffff); -#else - args[nb_args++] = (void *)0; -#endif - args[nb_args++] = (void *)(long)(val & 0xffffffff); - qdict_put(qdict, key, qint_from_int(val)); - } + qdict_put(qdict, key, qint_from_int(val)); } break; case '-': @@ -2820,9 +2772,6 @@ static const mon_cmd_t *monitor_parse_command(Monitor *mon, p++; has_option = 1; } - if (nb_args >= MAX_ARGS) - goto error_args; - args[nb_args++] = (void *)(long)has_option; qdict_put(qdict, key, qint_from_int(has_option)); } break;