Patchwork [22/29] monitor: Drop args[] handling code

login
register
mail settings
Submitter Luiz Capitulino
Date Aug. 13, 2009, 1:50 p.m.
Message ID <1250171428-29308-23-git-send-email-lcapitulino@redhat.com>
Download mbox | patch
Permalink /patch/31324/
State Superseded
Headers show

Comments

Luiz Capitulino - Aug. 13, 2009, 1:50 p.m.
This commit drops all the code used to handle the 'args[]' array.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 monitor.c |   71 ++++++++----------------------------------------------------
 1 files changed, 10 insertions(+), 61 deletions(-)

Patch

diff --git a/monitor.c b/monitor.c
index f4b3872..e736de4 100644
--- a/monitor.c
+++ b/monitor.c
@@ -2644,12 +2644,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);
@@ -2673,7 +2672,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)
@@ -2686,7 +2684,6 @@  static const mon_cmd_t *monitor_parse_command(Monitor *mon,
         case 's':
             {
                 int ret;
-                char *str;
 
                 while (qemu_isspace(*p))
                     p++;
@@ -2694,8 +2691,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);
@@ -2715,18 +2711,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_add_qstring(qdict, key, qstring_from_str(str));
-                qemu_free(str);
+                qdict_add_qstring(qdict, key, qstring_from_str(buf));
             }
             break;
         case '/':
@@ -2803,11 +2788,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_add_qint(qdict, "count", qint_from_int(count));
                 qdict_add_qint(qdict, "format", qint_from_int(format));
                 qdict_add_qint(qdict, "size", qint_from_int(size));
@@ -2817,58 +2797,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_add_qint(qdict, key, qint_from_int64(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_add_qint(qdict, key, qint_from_int64(val));
-                }
+                qdict_add_qint(qdict, key, qint_from_int64(val));
             }
             break;
         case '-':
@@ -2892,9 +2844,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_add_qint(qdict, key, qint_from_int(has_option));
             }
             break;