Remove "cmd_type" function

Message ID 20200622160854.30481-1-tom@tromey.com
State New
Headers show
Series
  • Remove "cmd_type" function
Related show

Commit Message

Tom Tromey June 22, 2020, 4:08 p.m.
The cmd_type function only has a single caller, which is in the CLI
implementation code.  This patch removes the function, and moves the
cmd_types enum definition from command.h to cli-decode.h, fixing an 18
year old FIXME.

gdb/ChangeLog
2020-06-22  Tom Tromey  <tom@tromey.com>

	* command.h (cmd_types): Remove.
	(cmd_type): Don't declare.
	* cli/cli-decode.h (enum cmd_types): Uncomment.  No longer a
	typedef.
	* cli/cli-cmds.c (setting_cmd): Use cmd->type directly.
	* cli/cli-decode.c (cmd_type): Remove.
---
 gdb/ChangeLog        |  9 +++++++++
 gdb/cli/cli-cmds.c   |  2 +-
 gdb/cli/cli-decode.c |  6 ------
 gdb/cli/cli-decode.h | 17 ++++++-----------
 gdb/command.h        | 16 ----------------
 5 files changed, 16 insertions(+), 34 deletions(-)

-- 
2.17.2

Comments

Simon Marchi via Gdb-patches June 26, 2020, 12:27 p.m. | #1
Tom Tromey wrote:
> The cmd_type function only has a single caller, which is in the CLI

> implementation code.  This patch removes the function, and moves the

> cmd_types enum definition from command.h to cli-decode.h, fixing an 18

> year old FIXME.

> 

> gdb/ChangeLog

> 2020-06-22  Tom Tromey  <tom@tromey.com>

> 

> 	* command.h (cmd_types): Remove.

> 	(cmd_type): Don't declare.

> 	* cli/cli-decode.h (enum cmd_types): Uncomment.  No longer a

> 	typedef.

> 	* cli/cli-cmds.c (setting_cmd): Use cmd->type directly.

> 	* cli/cli-decode.c (cmd_type): Remove.


LGTM.

Cheers,
Gary

-- 
Gary Benson - he / him / his
Principal Software Engineer, Red Hat
Tom Tromey June 28, 2020, 4:38 p.m. | #2
>> * command.h (cmd_types): Remove.

>> (cmd_type): Don't declare.

>> * cli/cli-decode.h (enum cmd_types): Uncomment.  No longer a

>> typedef.

>> * cli/cli-cmds.c (setting_cmd): Use cmd->type directly.

>> * cli/cli-decode.c (cmd_type): Remove.


Gary> LGTM.

Thanks, I'm checking this in now.

Tom

Patch

diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
index cd6f7856599..15d605eba41 100644
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -1940,7 +1940,7 @@  setting_cmd (const char *fnname, struct cmd_list_element *showlist,
   const char *a0 = (const char *) value_contents (argv[0]);
   cmd_list_element *cmd = lookup_cmd (&a0, showlist, "", -1, 0);
 
-  if (cmd == nullptr || cmd_type (cmd) != show_cmd)
+  if (cmd == nullptr || cmd->type != show_cmd)
     error (_("First argument of %s must be a "
 	     "valid setting of the 'show' command."), fnname);
 
diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c
index a4ef93c62b0..05e63b4b742 100644
--- a/gdb/cli/cli-decode.c
+++ b/gdb/cli/cli-decode.c
@@ -139,12 +139,6 @@  get_cmd_context (struct cmd_list_element *cmd)
   return cmd->context;
 }
 
-enum cmd_types
-cmd_type (struct cmd_list_element *cmd)
-{
-  return cmd->type;
-}
-
 void
 set_cmd_completer (struct cmd_list_element *cmd, completer_ftype *completer)
 {
diff --git a/gdb/cli/cli-decode.h b/gdb/cli/cli-decode.h
index f4719bfac47..c4386ec87cd 100644
--- a/gdb/cli/cli-decode.h
+++ b/gdb/cli/cli-decode.h
@@ -27,20 +27,15 @@ 
 #include "cli-script.h"
 #include "completer.h"
 
-#if 0
-/* FIXME: cagney/2002-03-17: Once cmd_type() has been removed, ``enum
-   cmd_types'' can be moved from "command.h" to "cli-decode.h".  */
 /* Not a set/show command.  Note that some commands which begin with
    "set" or "show" might be in this category, if their syntax does
    not fall into one of the following categories.  */
-typedef enum cmd_types
-  {
-    not_set_cmd,
-    set_cmd,
-    show_cmd
-  }
-cmd_types;
-#endif
+enum cmd_types
+{
+  not_set_cmd,
+  set_cmd,
+  show_cmd
+};
 
 /* This structure records one command'd definition.  */
 
diff --git a/gdb/command.h b/gdb/command.h
index 32b5b35b0c5..3184f19b2de 100644
--- a/gdb/command.h
+++ b/gdb/command.h
@@ -71,19 +71,6 @@  enum command_class
   no_set_class
 };
 
-/* FIXME: cagney/2002-03-17: Once cmd_type() has been removed, ``enum
-   cmd_types'' can be moved from "command.h" to "cli-decode.h".  */
-/* Not a set/show command.  Note that some commands which begin with
-   "set" or "show" might be in this category, if their syntax does
-   not fall into one of the following categories.  */
-typedef enum cmd_types
-  {
-    not_set_cmd,
-    set_cmd,
-    show_cmd
-  }
-cmd_types;
-
 /* Types of "set" or "show" command.  */
 typedef enum var_types
   {
@@ -282,9 +269,6 @@  extern void *get_cmd_context (struct cmd_list_element *cmd);
 extern void execute_cmd_pre_hook (struct cmd_list_element *cmd);
 extern void execute_cmd_post_hook (struct cmd_list_element *cmd);
 
-/* Return the type of the command.  */
-extern enum cmd_types cmd_type (struct cmd_list_element *cmd);
-
 /* Flag for an ambiguous cmd_list result.  */
 #define CMD_LIST_AMBIGUOUS ((struct cmd_list_element *) -1)