Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] [gdb/python] Boolify gdb_python_initialized
@ 2026-05-24 12:30 Tom de Vries
  2026-05-25  1:55 ` Kevin Buettner
  0 siblings, 1 reply; 2+ messages in thread
From: Tom de Vries @ 2026-05-24 12:30 UTC (permalink / raw)
  To: gdb-patches

I noticed that while gdb_python_initialized is an int, there's also an
assignment using false:
...
  gdb_python_initialized = false;
...

Fix this by converting gdb_python_initialized to bool type.
---
 gdb/python/python-internal.h | 2 +-
 gdb/python/python.c          | 8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h
index 82f3262ae07..10c984bad4b 100644
--- a/gdb/python/python-internal.h
+++ b/gdb/python/python-internal.h
@@ -330,7 +330,7 @@ struct program_space;
 struct bpstat;
 struct inferior;
 
-extern int gdb_python_initialized;
+extern bool gdb_python_initialized;
 
 extern PyObject *gdb_module;
 extern PyObject *gdb_python_module;
diff --git a/gdb/python/python.c b/gdb/python/python.c
index fd254a340d8..e6d58f2f16a 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -82,7 +82,7 @@ static const char *gdbpy_should_print_stack = python_excp_message;
 /* True if Python has been successfully initialized, false
    otherwise.  */
 
-int gdb_python_initialized;
+bool gdb_python_initialized;
 
 extern PyMethodDef python_GdbMethods[];
 
@@ -2796,7 +2796,7 @@ do_start_initialization ()
   PyEval_SaveThread ();
 
   /* Only set this when initialization has succeeded.  */
-  gdb_python_initialized = 1;
+  gdb_python_initialized = true;
   return true;
 }
 
@@ -2819,7 +2819,7 @@ test_python ()
   bool saw_exception = false;
   {
     scoped_restore reset_gdb_python_initialized
-      = make_scoped_restore (&gdb_python_initialized, 0);
+      = make_scoped_restore (&gdb_python_initialized, false);
     try
       {
 	CMD (output);
@@ -3123,7 +3123,7 @@ gdbpy_initialize (const struct extension_language_defn *extlang)
 static int
 gdbpy_initialized (const struct extension_language_defn *extlang)
 {
-  return gdb_python_initialized;
+  return gdb_python_initialized ? 1 : 0;
 }
 
 PyMethodDef python_GdbMethods[] =

base-commit: c5590002d8ee23c8ee3d64803e4e03c5992903c1
-- 
2.51.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] [gdb/python] Boolify gdb_python_initialized
  2026-05-24 12:30 [PATCH] [gdb/python] Boolify gdb_python_initialized Tom de Vries
@ 2026-05-25  1:55 ` Kevin Buettner
  0 siblings, 0 replies; 2+ messages in thread
From: Kevin Buettner @ 2026-05-25  1:55 UTC (permalink / raw)
  To: Tom de Vries; +Cc: gdb-patches

On Sun, 24 May 2026 14:30:22 +0200
Tom de Vries <tdevries@suse.de> wrote:

> I noticed that while gdb_python_initialized is an int, there's also an
> assignment using false:
> ...
>   gdb_python_initialized = false;
> ...
> 
> Fix this by converting gdb_python_initialized to bool type.

LGTM.

Approved-by: Kevin Buettner <kevinb@redhat.com>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-05-25  1:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-05-24 12:30 [PATCH] [gdb/python] Boolify gdb_python_initialized Tom de Vries
2026-05-25  1:55 ` Kevin Buettner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox