public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
From: Tankut Baris Aktemur <aktemur@sourceware.org>
To: gdb-cvs@sourceware.org
Subject: [binutils-gdb] gdb, python: do minor modernization in execute_gdb_command
Date: Mon, 27 Feb 2023 09:32:12 +0000 (GMT)	[thread overview]
Message-ID: <20230227093212.BD68A3858D20@sourceware.org> (raw)

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

commit 4e08903f679f22be6d7ea6e33f21a9fc43210567
Author: Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
Date:   Mon Feb 27 10:28:40 2023 +0100

    gdb, python: do minor modernization in execute_gdb_command
    
    Use nullptr instead of NULL and boolify two local variables in
    execute_gdb_command.
    
    Approved-By: Tom Tromey <tom@tromey.com>

Diff:
---
 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..1ed13f2789b 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);
     }
 
-  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);
     }
 
   std::string to_string_res;

                 reply	other threads:[~2023-02-27  9:32 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230227093212.BD68A3858D20@sourceware.org \
    --to=aktemur@sourceware.org \
    --cc=gdb-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).