public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] gdb: change return type of check_quit_flag to bool
@ 2024-04-23 15:28 Simon Marchi
  0 siblings, 0 replies; only message in thread
From: Simon Marchi @ 2024-04-23 15:28 UTC (permalink / raw)
  To: gdb-cvs

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

commit 1487293966460b07f585799834c928552aaf8202
Author: Simon Marchi <simon.marchi@polymtl.ca>
Date:   Tue Apr 23 09:22:57 2024 -0400

    gdb: change return type of check_quit_flag to bool
    
    Change the return type of the check_quit_flag function to bool.  Update
    a few related spots.
    
    Change-Id: I9d3a15d3f8651efb02c7d211f06222a592bd4184
    Approved-By: Tom Tromey <tom@tromey.com>

Diff:
---
 gdb/extension-priv.h |  4 ++--
 gdb/extension.c      | 10 +++++-----
 gdb/extension.h      |  2 +-
 gdb/python/python.c  |  6 +++---
 gdb/remote-fileio.c  |  2 +-
 5 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/gdb/extension-priv.h b/gdb/extension-priv.h
index cb00cb6ff7b..1365988b40d 100644
--- a/gdb/extension-priv.h
+++ b/gdb/extension-priv.h
@@ -229,9 +229,9 @@ struct extension_language_ops
      This is called by GDB's SIGINT handler and must be async-safe.  */
   void (*set_quit_flag) (const struct extension_language_defn *);
 
-  /* Return non-zero if a SIGINT has occurred.
+  /* Return true if a SIGINT has occurred.
      This is expected to also clear the indicator.  */
-  int (*check_quit_flag) (const struct extension_language_defn *);
+  bool (*check_quit_flag) (const struct extension_language_defn *);
 
   /* Called before gdb prints its prompt, giving extension languages an
      opportunity to change it with set_prompt.
diff --git a/gdb/extension.c b/gdb/extension.c
index 2d692d05431..82d37fb09ae 100644
--- a/gdb/extension.c
+++ b/gdb/extension.c
@@ -890,21 +890,21 @@ set_quit_flag ()
 
 /* See extension.h.  */
 
-int
+bool
 check_quit_flag ()
 {
 #if CXX_STD_THREAD
   std::lock_guard guard (ext_lang_mutex);
 #endif /* CXX_STD_THREAD */
 
-  int result = 0;
+  bool result = false;
 
   for (const struct extension_language_defn *extlang : extension_languages)
     {
       if (extlang->ops != nullptr
 	  && extlang->ops->check_quit_flag != NULL)
-	if (extlang->ops->check_quit_flag (extlang) != 0)
-	  result = 1;
+	if (extlang->ops->check_quit_flag (extlang))
+	  result = true;
     }
 
   /* This is written in a particular way to avoid races.  */
@@ -915,7 +915,7 @@ check_quit_flag ()
 	 request.  */
       quit_serial_event_clear ();
       quit_flag = 0;
-      result = 1;
+      result = true;
     }
 
   return result;
diff --git a/gdb/extension.h b/gdb/extension.h
index 94a500d7458..258a77dbfcc 100644
--- a/gdb/extension.h
+++ b/gdb/extension.h
@@ -447,7 +447,7 @@ private:
    The flag is checked in all extension languages that support cooperative
    SIGINT handling, not just the current one.  This simplifies transitions.  */
 
-extern int check_quit_flag ();
+extern bool check_quit_flag ();
 
 /* Set the quit flag.
    This only sets the flag in the currently active extension language.
diff --git a/gdb/python/python.c b/gdb/python/python.c
index d6e5883476e..a6875af63db 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -121,7 +121,7 @@ static enum ext_lang_rc gdbpy_apply_type_printers
 static void gdbpy_free_type_printers (const struct extension_language_defn *,
 				      struct ext_lang_type_printers *);
 static void gdbpy_set_quit_flag (const struct extension_language_defn *);
-static int gdbpy_check_quit_flag (const struct extension_language_defn *);
+static bool gdbpy_check_quit_flag (const struct extension_language_defn *);
 static enum ext_lang_rc gdbpy_before_prompt_hook
   (const struct extension_language_defn *, const char *current_gdb_prompt);
 static std::optional<std::string> gdbpy_colorize
@@ -275,11 +275,11 @@ gdbpy_set_quit_flag (const struct extension_language_defn *extlang)
 
 /* Return true if the quit flag has been set, false otherwise.  */
 
-static int
+static bool
 gdbpy_check_quit_flag (const struct extension_language_defn *extlang)
 {
   if (!gdb_python_initialized)
-    return 0;
+    return false;
 
   gdbpy_gil gil;
   return PyOS_InterruptOccurred ();
diff --git a/gdb/remote-fileio.c b/gdb/remote-fileio.c
index 9615dedaebd..934ba3f8281 100644
--- a/gdb/remote-fileio.c
+++ b/gdb/remote-fileio.c
@@ -316,7 +316,7 @@ static void
 remote_fileio_reply (remote_target *remote, int retcode, int error)
 {
   char buf[32];
-  int ctrl_c = check_quit_flag ();
+  bool ctrl_c = check_quit_flag ();
 
   strcpy (buf, "F");
   if (retcode < 0)

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-04-23 15:28 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-23 15:28 [binutils-gdb] gdb: change return type of check_quit_flag to bool Simon Marchi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).