-Wwrite-strings: MI -info-os
authorPedro Alves <palves@redhat.com>
Wed, 5 Apr 2017 18:21:35 +0000 (19:21 +0100)
committerPedro Alves <palves@redhat.com>
Wed, 5 Apr 2017 18:21:35 +0000 (19:21 +0100)
-Wwrite-strings flags this attempt to convert a string literal to
 "char *":

      info_osdata_command ("", 0);

info_osdata_command is a command function.  We could address this by
simply passing NULL instead of "".  However, I went a little bit
further and added a new function that is called by both the CLI and
MI.

gdb/ChangeLog:
2017-04-05  Pedro Alves  <palves@redhat.com>

* mi/mi-cmd-info.c (mi_cmd_info_os): Call info_osdata instead of
info_osdata_command.
* osdata.c (info_osdata_command): Rename to ...
(info_osdata): ... this.  Constify 'type' parameter, and remove
the 'from_tty' parameter.  Accept NULL TYPE.
(info_osdata_command): New function.
* osdata.h (info_osdata_command): Remove declaration.
(info_osdata): New declaration.

gdb/ChangeLog
gdb/mi/mi-cmd-info.c
gdb/osdata.c
gdb/osdata.h

index 821aeafa8f90e23a4df857270e31131223856c8f..fe1243be8cd204465d41de48164a3161aec30578 100644 (file)
@@ -1,3 +1,14 @@
+2017-04-05  Pedro Alves  <palves@redhat.com>
+
+       * mi/mi-cmd-info.c (mi_cmd_info_os): Call info_osdata instead of
+       info_osdata_command.
+       * osdata.c (info_osdata_command): Rename to ...
+       (info_osdata): ... this.  Constify 'type' parameter, and remove
+       the 'from_tty' parameter.  Accept NULL TYPE.
+       (info_osdata_command): New function.
+       * osdata.h (info_osdata_command): Remove declaration.
+       (info_osdata): New declaration.
+
 2017-04-05  Pedro Alves  <palves@redhat.com>
 
        * mi/mi-cmd-break.c (mi_cmd_break_insert_1, mi_cmd_break_insert)
index eba1ca283b7e26d743e779a3005d639deee8b09f..1a96d6feed2be5ff3f3e26cdc90446ec253402e1 100644 (file)
@@ -106,10 +106,10 @@ mi_cmd_info_os (const char *command, char **argv, int argc)
   switch (argc)
     {
     case 0:
-      info_osdata_command ("", 0);
+      info_osdata (NULL);
       break;
     case 1:
-      info_osdata_command (argv[0], 0);
+      info_osdata (argv[0]);
       break;
     default:
       error (_("Usage: -info-os [INFOTYPE]"));
index d63ff5aac9c6bf1764957201f09b40ac022c7f1a..4b33ccbdf64353b4f2703bba1e83e28433f71b84 100644 (file)
@@ -287,7 +287,7 @@ get_osdata_column (struct osdata_item *item, const char *name)
 }
 
 void
-info_osdata_command (char *type, int from_tty)
+info_osdata (const char *type)
 {
   struct ui_out *uiout = current_uiout;
   struct osdata *osdata = NULL;
@@ -297,12 +297,15 @@ info_osdata_command (char *type, int from_tty)
   int nrows;
   int col_to_skip = -1;
 
+  if (type == NULL)
+    type = "";
+
   osdata = get_osdata (type);
   old_chain = make_cleanup_osdata_free (osdata);
 
   nrows = VEC_length (osdata_item_s, osdata->items);
 
-  if (!type && nrows == 0)
+  if (*type == '\0' && nrows == 0)
     error (_("Available types of OS data not reported."));
   
   if (!VEC_empty (osdata_item_s, osdata->items))
@@ -407,6 +410,12 @@ info_osdata_command (char *type, int from_tty)
   do_cleanups (old_chain);
 }
 
+static void
+info_osdata_command (char *arg, int from_tty)
+{
+  info_osdata (arg);
+}
+
 extern initialize_file_ftype _initialize_osdata; /* -Wmissing-prototypes */
 
 void
index bda0112cd889739cc4f083a3934c124e6cc9f88a..5921384527d6c5aff8cf1f077bc01d54faea6cb3 100644 (file)
@@ -49,6 +49,10 @@ void osdata_free (struct osdata *);
 struct cleanup *make_cleanup_osdata_free (struct osdata *data);
 struct osdata *get_osdata (const char *type);
 const char *get_osdata_column (struct osdata_item *item, const char *name);
-void info_osdata_command (char *type, int from_tty);
+
+/* Dump TYPE info to the current uiout builder.  If TYPE is either
+   NULL or empty, then dump the top level table that lists the
+   available types of OS data.  */
+void info_osdata (const char *type);
 
 #endif /* OSDATA_H */
This page took 0.0311 seconds and 4 git commands to generate.