diff mbox

[v2,04/26] monitor: Convert mon_cmd_t to MonitorCommand

Message ID 1408109759-1100-5-git-send-email-benoit.canet@nodalink.com
State New
Headers show

Commit Message

Benoît Canet Aug. 15, 2014, 1:35 p.m. UTC
Signed-off-by: Benoît Canet <benoit.canet@nodalink.com>
---
 monitor.c | 68 +++++++++++++++++++++++++++++++--------------------------------
 1 file changed, 34 insertions(+), 34 deletions(-)
diff mbox

Patch

diff --git a/monitor.c b/monitor.c
index 48a147c..f57dae5 100644
--- a/monitor.c
+++ b/monitor.c
@@ -123,7 +123,7 @@  struct MonitorCompletionData {
     void (*user_print)(Monitor *mon, const QObject *data);
 };
 
-typedef struct mon_cmd_t {
+typedef struct MonitorCommand {
     const char *name;
     const char *args_type;
     const char *params;
@@ -140,9 +140,9 @@  typedef struct mon_cmd_t {
      * mhandler should be used. If it exist, sub_table[?].mhandler should be
      * used, and mhandler of 1st level plays the role of help function.
      */
-    struct mon_cmd_t *sub_table;
+    struct MonitorCommand *sub_table;
     void (*command_completion)(ReadLineState *rs, int nb_args, const char *str);
-} mon_cmd_t;
+} MonitorCommand;
 
 /* file descriptors passed via SCM_RIGHTS */
 typedef struct mon_fd_t mon_fd_t;
@@ -208,7 +208,7 @@  struct Monitor {
     CPUState *mon_cpu;
     BlockDriverCompletionFunc *password_completion_cb;
     void *password_opaque;
-    mon_cmd_t *cmd_table;
+    MonitorCommand *cmd_table;
     QError *error;
     QLIST_HEAD(,mon_fd_t) fds;
     QLIST_ENTRY(Monitor) entry;
@@ -224,10 +224,10 @@  static QLIST_HEAD(mon_list, Monitor) mon_list;
 static QLIST_HEAD(mon_fdsets, MonFdset) mon_fdsets;
 static int mon_refcount;
 
-static mon_cmd_t mon_cmds[];
-static mon_cmd_t info_cmds[];
+static MonitorCommand mon_cmds[];
+static MonitorCommand info_cmds[];
 
-static const mon_cmd_t qmp_cmds[];
+static const MonitorCommand qmp_cmds[];
 
 Monitor *cur_mon;
 Monitor *default_mon;
@@ -391,12 +391,12 @@  static int GCC_FMT_ATTR(2, 3) monitor_fprintf(FILE *stream,
 
 void monitor_user_noop(Monitor *mon, const QObject *data) { }
 
-static inline int handler_is_qobject(const mon_cmd_t *cmd)
+static inline int handler_is_qobject(const MonitorCommand *cmd)
 {
     return cmd->user_print != NULL;
 }
 
-static inline bool handler_is_async(const mon_cmd_t *cmd)
+static inline bool handler_is_async(const MonitorCommand *cmd)
 {
     return cmd->flags & MONITOR_CMD_ASYNC;
 }
@@ -804,7 +804,7 @@  int parse_cmdline(const char *cmdline, int *pnb_args, char **args)
 }
 
 static void help_cmd_dump_one(Monitor *mon,
-                              const mon_cmd_t *cmd,
+                              const MonitorCommand *cmd,
                               char **prefix_args,
                               int prefix_args_nb)
 {
@@ -817,10 +817,10 @@  static void help_cmd_dump_one(Monitor *mon,
 }
 
 /* @args[@arg_index] is the valid command need to find in @cmds */
-static void help_cmd_dump(Monitor *mon, const mon_cmd_t *cmds,
+static void help_cmd_dump(Monitor *mon, const MonitorCommand *cmds,
                           char **args, int nb_args, int arg_index)
 {
-    const mon_cmd_t *cmd;
+    const MonitorCommand *cmd;
 
     /* No valid arg need to compare with, dump all in *cmds */
     if (arg_index >= nb_args) {
@@ -940,13 +940,13 @@  static void qmp_monitor_complete(void *opaque, QObject *ret_data)
     monitor_protocol_emitter(opaque, ret_data);
 }
 
-static int qmp_async_cmd_handler(Monitor *mon, const mon_cmd_t *cmd,
+static int qmp_async_cmd_handler(Monitor *mon, const MonitorCommand *cmd,
                                  const QDict *params)
 {
     return cmd->mhandler.cmd_async(mon, params, qmp_monitor_complete, mon);
 }
 
-static void user_async_cmd_handler(Monitor *mon, const mon_cmd_t *cmd,
+static void user_async_cmd_handler(Monitor *mon, const MonitorCommand *cmd,
                                    const QDict *params)
 {
     int ret;
@@ -971,7 +971,7 @@  static void do_info_help(Monitor *mon, const QDict *qdict)
 CommandInfoList *qmp_query_commands(Error **errp)
 {
     CommandInfoList *info, *cmd_list = NULL;
-    const mon_cmd_t *cmd;
+    const MonitorCommand *cmd;
 
     for (cmd = qmp_cmds; cmd->name != NULL; cmd++) {
         info = g_malloc0(sizeof(*info));
@@ -2595,7 +2595,7 @@  int monitor_handle_fd_param2(Monitor *mon, const char *fdname, Error **errp)
 }
 
 /* Please update hmp-commands.hx when adding or changing commands */
-static mon_cmd_t info_cmds[] = {
+static MonitorCommand info_cmds[] = {
     {
         .name       = "version",
         .args_type  = "",
@@ -2921,12 +2921,12 @@  static mon_cmd_t info_cmds[] = {
 };
 
 /* mon_cmds and info_cmds would be sorted at runtime */
-static mon_cmd_t mon_cmds[] = {
+static MonitorCommand mon_cmds[] = {
 #include "hmp-commands.h"
     { NULL, NULL, },
 };
 
-static const mon_cmd_t qmp_cmds[] = {
+static const MonitorCommand qmp_cmds[] = {
 #include "qmp-commands-old.h"
     { /* NULL */ },
 };
@@ -3643,10 +3643,10 @@  static int is_valid_option(const char *c, const char *typestr)
     return (typestr != NULL);
 }
 
-static const mon_cmd_t *search_dispatch_table(const mon_cmd_t *disp_table,
+static const MonitorCommand *search_dispatch_table(const MonitorCommand *disp_table,
                                               const char *cmdname)
 {
-    const mon_cmd_t *cmd;
+    const MonitorCommand *cmd;
 
     for (cmd = disp_table; cmd->name != NULL; cmd++) {
         if (compare_cmd(cmdname, cmd->name)) {
@@ -3657,7 +3657,7 @@  static const mon_cmd_t *search_dispatch_table(const mon_cmd_t *disp_table,
     return NULL;
 }
 
-static const mon_cmd_t *qmp_find_cmd(const char *cmdname)
+static const MonitorCommand *qmp_find_cmd(const char *cmdname)
 {
     return search_dispatch_table(qmp_cmds, cmdname);
 }
@@ -3674,15 +3674,15 @@  static const mon_cmd_t *qmp_find_cmd(const char *cmdname)
  * Do not assume the returned command points into @table!  It doesn't
  * when the command is a sub-command.
  */
-static const mon_cmd_t *monitor_parse_command(Monitor *mon,
+static const MonitorCommand *monitor_parse_command(Monitor *mon,
                                               const char *cmdline,
                                               int start,
-                                              mon_cmd_t *table,
+                                              MonitorCommand *table,
                                               QDict *qdict)
 {
     const char *p, *typestr;
     int c;
-    const mon_cmd_t *cmd;
+    const MonitorCommand *cmd;
     char cmdname[256];
     char buf[1024];
     char *key;
@@ -4078,7 +4078,7 @@  void monitor_set_error(Monitor *mon, QError *qerror)
     }
 }
 
-static void handler_audit(Monitor *mon, const mon_cmd_t *cmd, int ret)
+static void handler_audit(Monitor *mon, const MonitorCommand *cmd, int ret)
 {
     if (ret && !monitor_has_error(mon)) {
         /*
@@ -4093,7 +4093,7 @@  static void handler_audit(Monitor *mon, const mon_cmd_t *cmd, int ret)
 void handle_user_command(Monitor *mon, const char *cmdline)
 {
     QDict *qdict;
-    const mon_cmd_t *cmd;
+    const MonitorCommand *cmd;
 
     qdict = qdict_new();
 
@@ -4653,14 +4653,14 @@  void loadvm_completion(ReadLineState *rs, int nb_args, const char *str)
 }
 
 static void monitor_find_completion_by_table(Monitor *mon,
-                                             const mon_cmd_t *cmd_table,
+                                             const MonitorCommand *cmd_table,
                                              char **args,
                                              int nb_args)
 {
     const char *cmdname;
     int i;
     const char *ptype, *str;
-    const mon_cmd_t *cmd;
+    const MonitorCommand *cmd;
     MonitorBlockComplete mbs;
 
     if (nb_args <= 1) {
@@ -4951,7 +4951,7 @@  out:
  * 3. Each argument provided by the client must have the type expected
  *    by the command
  */
-static int qmp_check_client_args(const mon_cmd_t *cmd, QDict *client_args)
+static int qmp_check_client_args(const MonitorCommand *cmd, QDict *client_args)
 {
     int flags, err;
     QDict *cmd_args;
@@ -5027,7 +5027,7 @@  static QDict *qmp_check_input_obj(QObject *input_obj)
     return input_dict;
 }
 
-static void qmp_call_cmd(Monitor *mon, const mon_cmd_t *cmd,
+static void qmp_call_cmd(Monitor *mon, const MonitorCommand *cmd,
                          const QDict *params)
 {
     int ret;
@@ -5044,7 +5044,7 @@  static void handle_qmp_command(JSONMessageParser *parser, QList *tokens)
     int err;
     QObject *obj;
     QDict *input, *args;
-    const mon_cmd_t *cmd;
+    const MonitorCommand *cmd;
     const char *cmd_name;
     Monitor *mon = cur_mon;
 
@@ -5257,14 +5257,14 @@  static void monitor_event(void *opaque, int event)
 static int
 compare_mon_cmd(const void *a, const void *b)
 {
-    return strcmp(((const mon_cmd_t *)a)->name,
-            ((const mon_cmd_t *)b)->name);
+    return strcmp(((const MonitorCommand *)a)->name,
+            ((const MonitorCommand *)b)->name);
 }
 
 static void sortcmdlist(void)
 {
     int array_num;
-    int elem_size = sizeof(mon_cmd_t);
+    int elem_size = sizeof(MonitorCommand);
 
     array_num = sizeof(mon_cmds)/elem_size-1;
     qsort((void *)mon_cmds, array_num, elem_size, compare_mon_cmd);