[binutils-gdb] gdb/cli: convert cli_suppress_notification from int to bool

Tankut Baris Aktemur aktemur@sourceware.org
Mon Feb 7 07:34:06 GMT 2022


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=f36c8918018ae5036fafafd76df71084fc50a5a9

commit f36c8918018ae5036fafafd76df71084fc50a5a9
Author: Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
Date:   Mon Feb 7 08:26:55 2022 +0100

    gdb/cli: convert cli_suppress_notification from int to bool
    
    Convert the suppress_notification flag for the CLI from int to bool.

Diff:
---
 gdb/cli/cli-decode.c | 10 +++++-----
 gdb/cli/cli-decode.h |  2 +-
 gdb/cli/cli-interp.c |  5 +----
 gdb/command.h        |  8 ++++----
 4 files changed, 11 insertions(+), 14 deletions(-)

diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c
index 14422e098d4..3c21c6e6c5b 100644
--- a/gdb/cli/cli-decode.c
+++ b/gdb/cli/cli-decode.c
@@ -255,7 +255,7 @@ struct cmd_list_element *
 add_cmd_suppress_notification (const char *name, enum command_class theclass,
 			       cmd_simple_func_ftype *fun, const char *doc,
 			       struct cmd_list_element **list,
-			       int *suppress_notification)
+			       bool *suppress_notification)
 {
   struct cmd_list_element *element;
 
@@ -453,7 +453,7 @@ add_prefix_cmd_suppress_notification
 		cmd_simple_func_ftype *fun,
 		const char *doc, struct cmd_list_element **subcommands,
 		int allow_unknown, struct cmd_list_element **list,
-		int *suppress_notification)
+		bool *suppress_notification)
 {
   struct cmd_list_element *element
     = add_prefix_cmd (name, theclass, fun, doc, subcommands,
@@ -1329,7 +1329,7 @@ add_com_alias (const char *name, cmd_list_element *target,
 struct cmd_list_element *
 add_com_suppress_notification (const char *name, enum command_class theclass,
 			       cmd_simple_func_ftype *fun, const char *doc,
-			       int *suppress_notification)
+			       bool *suppress_notification)
 {
   return add_cmd_suppress_notification (name, theclass, fun, doc,
 					&cmdlist, suppress_notification);
@@ -2506,10 +2506,10 @@ cmd_func (struct cmd_list_element *cmd, const char *args, int from_tty)
 {
   if (!cmd->is_command_class_help ())
     {
-      gdb::optional<scoped_restore_tmpl<int>> restore_suppress;
+      gdb::optional<scoped_restore_tmpl<bool>> restore_suppress;
 
       if (cmd->suppress_notification != NULL)
-	restore_suppress.emplace (cmd->suppress_notification, 1);
+	restore_suppress.emplace (cmd->suppress_notification, true);
 
       cmd->func (args, from_tty, cmd);
     }
diff --git a/gdb/cli/cli-decode.h b/gdb/cli/cli-decode.h
index db35ea4982b..18db8822af3 100644
--- a/gdb/cli/cli-decode.h
+++ b/gdb/cli/cli-decode.h
@@ -271,7 +271,7 @@ struct cmd_list_element
      cli_suppress_notification', which will be set to true in cmd_func
      when this command is being executed.  It will be set back to false
      when the command has been executed.  */
-  int *suppress_notification = nullptr;
+  bool *suppress_notification = nullptr;
 
 private:
   /* Local state (context) for this command.  This can be anything.  */
diff --git a/gdb/cli/cli-interp.c b/gdb/cli/cli-interp.c
index 6dc3e6ae2fa..eb1edcc4ef1 100644
--- a/gdb/cli/cli-interp.c
+++ b/gdb/cli/cli-interp.c
@@ -68,10 +68,7 @@ cli_interp::~cli_interp ()
 }
 
 /* Suppress notification struct.  */
-struct cli_suppress_notification cli_suppress_notification =
-  {
-    0   /* user_selected_context_changed */
-  };
+struct cli_suppress_notification cli_suppress_notification;
 
 /* Returns the INTERP's data cast as cli_interp if INTERP is a CLI,
    and returns NULL otherwise.  */
diff --git a/gdb/command.h b/gdb/command.h
index 1746fb4d581..258ec380a44 100644
--- a/gdb/command.h
+++ b/gdb/command.h
@@ -378,7 +378,7 @@ typedef void cmd_simple_func_ftype (const char *args, int from_tty);
 struct cli_suppress_notification
 {
   /* Inferior, thread, frame selected notification suppressed?  */
-  int user_selected_context;
+  bool user_selected_context = false;
 };
 
 extern struct cli_suppress_notification cli_suppress_notification;
@@ -421,7 +421,7 @@ extern struct cmd_list_element *add_cmd_suppress_notification
 			(const char *name, enum command_class theclass,
 			 cmd_simple_func_ftype *fun, const char *doc,
 			 struct cmd_list_element **list,
-			 int *suppress_notification);
+			 bool *suppress_notification);
 
 extern struct cmd_list_element *add_alias_cmd (const char *,
 					       cmd_list_element *,
@@ -467,7 +467,7 @@ extern struct cmd_list_element *add_prefix_cmd_suppress_notification
 			 const char *doc, struct cmd_list_element **subcommands,
 			 int allow_unknown,
 			 struct cmd_list_element **list,
-			 int *suppress_notification);
+			 bool *suppress_notification);
 
 extern struct cmd_list_element *add_abbrev_prefix_cmd (const char *,
 						       enum command_class,
@@ -615,7 +615,7 @@ extern cmd_list_element *add_com_alias (const char *name,
 extern struct cmd_list_element *add_com_suppress_notification
 		       (const char *name, enum command_class theclass,
 			cmd_simple_func_ftype *fun, const char *doc,
-			int *supress_notification);
+			bool *supress_notification);
 
 extern struct cmd_list_element *add_info (const char *,
 					  cmd_simple_func_ftype *fun,


More information about the Gdb-cvs mailing list