Move declaration of max_user_call_depth to header

Message ID 20191010173131.96822-1-cbiesinger@google.com
State New, archived
Headers

Commit Message

Terekhov, Mikhail via Gdb-patches Oct. 10, 2019, 5:31 p.m. UTC
  Also removes an unnecessary declaration of cmdlist in cli-cmds.c.
I don't understand why it is there, the definition of cmdlist is
at the top of the same file.

gdb/ChangeLog:

2019-10-09  Christian Biesinger  <cbiesinger@google.com>

	* cli/cli-cmds.c (max_user_call_depth): Move comment to header.
	(show_user): Remove declaration of cmdlist.
	* cli/cli-cmds.h (max_user_call_depth): Declare.
	* cli/cli-script.c (execute_user_command): Remove declaration
	of max_user_call_depth.
---
 gdb/cli/cli-cmds.c   | 3 +--
 gdb/cli/cli-cmds.h   | 4 ++++
 gdb/cli/cli-script.c | 1 -
 3 files changed, 5 insertions(+), 3 deletions(-)
  

Comments

Tom Tromey Oct. 11, 2019, 1:13 p.m. UTC | #1
>>>>> "Christian" == Christian Biesinger via gdb-patches <gdb-patches@sourceware.org> writes:

Christian> 2019-10-09  Christian Biesinger  <cbiesinger@google.com>

Christian> 	* cli/cli-cmds.c (max_user_call_depth): Move comment to header.
Christian> 	(show_user): Remove declaration of cmdlist.
Christian> 	* cli/cli-cmds.h (max_user_call_depth): Declare.
Christian> 	* cli/cli-script.c (execute_user_command): Remove declaration
Christian> 	of max_user_call_depth.

Thanks, this is ok.

Christian>  /* Define all cmd_list_elements.  */
Christian> @@ -1538,7 +1538,6 @@ static void
Christian>  show_user (const char *args, int from_tty)
Christian>  {
Christian>    struct cmd_list_element *c;
Christian> -  extern struct cmd_list_element *cmdlist;

Changes like this particular one qualify as obvious IMO.

Christian> I don't understand why it is there, the definition of cmdlist is
Christian> at the top of the same file.

Could be the result of an earlier refactoring, or just plain old
mistake.

Tom
  
Terekhov, Mikhail via Gdb-patches Oct. 12, 2019, 7:33 p.m. UTC | #2
On Fri, Oct 11, 2019 at 8:13 AM Tom Tromey <tom@tromey.com> wrote:
>
> >>>>> "Christian" == Christian Biesinger via gdb-patches <gdb-patches@sourceware.org> writes:
>
> Christian> 2019-10-09  Christian Biesinger  <cbiesinger@google.com>
>
> Christian>      * cli/cli-cmds.c (max_user_call_depth): Move comment to header.
> Christian>      (show_user): Remove declaration of cmdlist.
> Christian>      * cli/cli-cmds.h (max_user_call_depth): Declare.
> Christian>      * cli/cli-script.c (execute_user_command): Remove declaration
> Christian>      of max_user_call_depth.
>
> Thanks, this is ok.

Thanks, pushed.

To ssh://sourceware.org/git/binutils-gdb.git
   03d0d46a0e6..cc8dee1f1c6  HEAD -> master

Christian

> Christian>  /* Define all cmd_list_elements.  */
> Christian> @@ -1538,7 +1538,6 @@ static void
> Christian>  show_user (const char *args, int from_tty)
> Christian>  {
> Christian>    struct cmd_list_element *c;
> Christian> -  extern struct cmd_list_element *cmdlist;
>
> Changes like this particular one qualify as obvious IMO.

Thanks, will keep that in mind, in this case I wanted to make sure I
wasn't missing anything.

Christian
  

Patch

diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
index 9f7b052d8e0..a39ea226045 100644
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -74,7 +74,7 @@  static void ambiguous_line_spec (gdb::array_view<const symtab_and_line> sals,
 static void filter_sals (std::vector<symtab_and_line> &);
 
 
-/* Limit the call depth of user-defined commands */
+/* See cli-cmds.h. */
 unsigned int max_user_call_depth;
 
 /* Define all cmd_list_elements.  */
@@ -1538,7 +1538,6 @@  static void
 show_user (const char *args, int from_tty)
 {
   struct cmd_list_element *c;
-  extern struct cmd_list_element *cmdlist;
 
   if (args)
     {
diff --git a/gdb/cli/cli-cmds.h b/gdb/cli/cli-cmds.h
index 1a8b9a0d506..94ae81475d6 100644
--- a/gdb/cli/cli-cmds.h
+++ b/gdb/cli/cli-cmds.h
@@ -101,6 +101,10 @@  extern struct cmd_list_element *setchecklist;
 
 extern struct cmd_list_element *showchecklist;
 
+/* Limit the call depth of user-defined commands */
+
+extern unsigned int max_user_call_depth;
+
 /* Exported to gdb/top.c */
 
 void init_cmd_lists (void);
diff --git a/gdb/cli/cli-script.c b/gdb/cli/cli-script.c
index 4fc9c70259c..3137955265f 100644
--- a/gdb/cli/cli-script.c
+++ b/gdb/cli/cli-script.c
@@ -449,7 +449,6 @@  void
 execute_user_command (struct cmd_list_element *c, const char *args)
 {
   counted_command_line cmdlines_copy;
-  extern unsigned int max_user_call_depth;
 
   /* Ensure that the user commands can't be deleted while they are
      executing.  */