From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2104) id BD68A3858D20; Mon, 27 Feb 2023 09:32:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BD68A3858D20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1677490332; bh=Dz8Fr9yjxqH9i/QJQwYIBPjPPd7C0ht/2iJ/o/qx14g=; h=From:To:Subject:Date:From; b=uujur845D7i+0Bk2r2xH7GDHLuMN7ImSJJEQMyO/Ai6bA5RS56btg2ZayTz6C4SZR jMflNYZFTczF5vPc3yeD8ek7RH6gm69UlR/e7E05Sstn8qWeiIoNUCSDXVJ6UatJpr 12N68Wa7xueFqVFkOYv7cFNAX4ntX3rFIkYjCpAk= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tankut Baris Aktemur To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb, python: do minor modernization in execute_gdb_command X-Act-Checkin: binutils-gdb X-Git-Author: Tankut Baris Aktemur X-Git-Refname: refs/heads/master X-Git-Oldrev: 4dd74c176b8a656eca76f2713ca25371d52e40b0 X-Git-Newrev: 4e08903f679f22be6d7ea6e33f21a9fc43210567 Message-Id: <20230227093212.BD68A3858D20@sourceware.org> Date: Mon, 27 Feb 2023 09:32:12 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D4e08903f679f= 22be6d7ea6e33f21a9fc43210567 commit 4e08903f679f22be6d7ea6e33f21a9fc43210567 Author: Tankut Baris Aktemur Date: Mon Feb 27 10:28:40 2023 +0100 gdb, python: do minor modernization in execute_gdb_command =20 Use nullptr instead of NULL and boolify two local variables in execute_gdb_command. =20 Approved-By: Tom Tromey 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 =3D NULL, *to_string_obj =3D NULL; - int from_tty, to_string; - static const char *keywords[] =3D { "command", "from_tty", "to_string", = NULL }; + PyObject *from_tty_obj =3D nullptr; + PyObject *to_string_obj =3D nullptr; + static const char *keywords[] =3D { "command", "from_tty", "to_string", + nullptr }; =20 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; =20 - from_tty =3D 0; - if (from_tty_obj) + bool from_tty =3D false; + if (from_tty_obj !=3D nullptr) { int cmp =3D PyObject_IsTrue (from_tty_obj); if (cmp < 0) - return NULL; - from_tty =3D cmp; + return nullptr; + from_tty =3D (cmp !=3D 0); } =20 - to_string =3D 0; - if (to_string_obj) + bool to_string =3D false; + if (to_string_obj !=3D nullptr) { int cmp =3D PyObject_IsTrue (to_string_obj); if (cmp < 0) - return NULL; - to_string =3D cmp; + return nullptr; + to_string =3D (cmp !=3D 0); } =20 std::string to_string_res;