public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 1/2] gdb, python: do minor modernization in execute_gdb_command
@ 2023-02-24 14:04 Tankut Baris Aktemur
  2023-02-24 14:04 ` [PATCH 2/2] gdb, python: selectively omit enabling stdin in gdb.execute exception Tankut Baris Aktemur
  2023-02-24 19:37 ` [PATCH 1/2] gdb, python: do minor modernization in execute_gdb_command Tom Tromey
  0 siblings, 2 replies; 7+ messages in thread
From: Tankut Baris Aktemur @ 2023-02-24 14:04 UTC (permalink / raw)
  To: gdb-patches

Use nullptr instead of NULL and boolify two local variables in
execute_gdb_command.
---
 gdb/python/python.c | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/gdb/python/python.c b/gdb/python/python.c
index ed466cc4511..5719f351528 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -621,31 +621,32 @@ static PyObject *
 execute_gdb_command (PyObject *self, PyObject *args, PyObject *kw)
 {
   const char *arg;
-  PyObject *from_tty_obj = NULL, *to_string_obj = NULL;
-  int from_tty, to_string;
-  static const char *keywords[] = { "command", "from_tty", "to_string", NULL };
+  PyObject *from_tty_obj = nullptr;
+  PyObject *to_string_obj = nullptr;
+  static const char *keywords[] = { "command", "from_tty", "to_string",
+				    nullptr };
 
   if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "s|O!O!", keywords, &arg,
 					&PyBool_Type, &from_tty_obj,
 					&PyBool_Type, &to_string_obj))
-    return NULL;
+    return nullptr;
 
-  from_tty = 0;
-  if (from_tty_obj)
+  bool from_tty = false;
+  if (from_tty_obj != nullptr)
     {
       int cmp = PyObject_IsTrue (from_tty_obj);
       if (cmp < 0)
-	return NULL;
-      from_tty = cmp;
+	return nullptr;
+      from_tty = ((cmp == 0) ? false : true);
     }
 
-  to_string = 0;
-  if (to_string_obj)
+  bool to_string = false;
+  if (to_string_obj != nullptr)
     {
       int cmp = PyObject_IsTrue (to_string_obj);
       if (cmp < 0)
-	return NULL;
-      to_string = cmp;
+	return nullptr;
+      to_string = ((cmp == 0) ? false : true);
     }
 
   std::string to_string_res;
-- 
2.25.1

Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de <http://www.intel.de>
Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva  
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928


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

end of thread, other threads:[~2023-02-27  9:53 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-24 14:04 [PATCH 1/2] gdb, python: do minor modernization in execute_gdb_command Tankut Baris Aktemur
2023-02-24 14:04 ` [PATCH 2/2] gdb, python: selectively omit enabling stdin in gdb.execute exception Tankut Baris Aktemur
2023-02-24 19:43   ` Tom Tromey
2023-02-27  9:53     ` Aktemur, Tankut Baris
2023-02-24 19:37 ` [PATCH 1/2] gdb, python: do minor modernization in execute_gdb_command Tom Tromey
2023-02-25 11:08   ` Andrew Burgess
2023-02-27  9:34     ` Aktemur, Tankut Baris

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).