aboutsummaryrefslogtreecommitdiff
path: root/gdb/python/python.c
diff options
context:
space:
mode:
authorTankut Baris Aktemur <tankut.baris.aktemur@intel.com>2023-02-27 10:28:40 +0100
committerTankut Baris Aktemur <tankut.baris.aktemur@intel.com>2023-02-27 10:28:40 +0100
commit4e08903f679f22be6d7ea6e33f21a9fc43210567 (patch)
treebfcabf51bc9d1fbd9b8f6b7f949b125dc1b539ba /gdb/python/python.c
parent4dd74c176b8a656eca76f2713ca25371d52e40b0 (diff)
downloadbinutils-4e08903f679f22be6d7ea6e33f21a9fc43210567.zip
binutils-4e08903f679f22be6d7ea6e33f21a9fc43210567.tar.gz
binutils-4e08903f679f22be6d7ea6e33f21a9fc43210567.tar.bz2
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>
Diffstat (limited to 'gdb/python/python.c')
-rw-r--r--gdb/python/python.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/gdb/python/python.c b/gdb/python/python.c
index ed466cc..1ed13f2 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;