From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by sourceware.org (Postfix) with ESMTPS id 035C1385840F for ; Fri, 24 Feb 2023 14:04:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 035C1385840F Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1677247468; x=1708783468; h=from:to:subject:date:message-id:mime-version: content-transfer-encoding; bh=1jdQt9NXMLqF1H57AHn4M86iSpCTk+tFyiQRz5EMlHQ=; b=R/Svq8Bc7HGgw042W/DvS7oqDZwFESBNf59QCNnoCZt6/P5bR3klCQId slnX1SBhcO/+VLaTbygEYPN5/u41yqlwFsJoX78NJvDmGBmnEpGPoDo/p HxlhXwOx5usLp/htEz1gNIDaapJWk6Me7gN5dgaRkmw8bOXykGE1V/V/z LuuuFmRmi6hO9rtqjd9WThkFI2JFCwyPqCQMHlJPcXdNLva5Q8cKCfVwK 0+/Icgud1xYoosdFGddIkajumNK9vUr8eMcmI7FWKV+OeVbmJM7zXIFqP XsgF9yUV2CKkwwOdikeytcaCOjJgI7JmwL1svKnkNI0A9x49anW7eFT/a w==; X-IronPort-AV: E=McAfee;i="6500,9779,10630"; a="313114103" X-IronPort-AV: E=Sophos;i="5.97,324,1669104000"; d="scan'208";a="313114103" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Feb 2023 06:04:26 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10630"; a="674941453" X-IronPort-AV: E=Sophos;i="5.97,324,1669104000"; d="scan'208";a="674941453" Received: from ultl2604.iul.intel.com (HELO localhost) ([172.28.48.47]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Feb 2023 06:04:22 -0800 From: Tankut Baris Aktemur To: gdb-patches@sourceware.org Subject: [PATCH 1/2] gdb, python: do minor modernization in execute_gdb_command Date: Fri, 24 Feb 2023 15:04:09 +0100 Message-Id: <20230224140410.2647437-1-tankut.baris.aktemur@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-9.6 required=5.0 tests=AC_FROM_MANY_DOTS,BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,SPF_HELO_PASS,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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 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