From patchwork Wed Jan 2 16:33:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 30936 Received: (qmail 4322 invoked by alias); 2 Jan 2019 16:33:44 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 4313 invoked by uid 89); 2 Jan 2019 16:33:44 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: gateway23.websitewelcome.com Received: from gateway23.websitewelcome.com (HELO gateway23.websitewelcome.com) (192.185.49.218) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 02 Jan 2019 16:33:41 +0000 Received: from cm14.websitewelcome.com (cm14.websitewelcome.com [100.42.49.7]) by gateway23.websitewelcome.com (Postfix) with ESMTP id 9A26A5DA7 for ; Wed, 2 Jan 2019 10:33:40 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id ejSegxxYD2qH7ejSege4yU; Wed, 02 Jan 2019 10:33:40 -0600 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version :Content-Type:Content-Transfer-Encoding:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=FPa0KMMt1oxsk8e1Y9F5rdD0niWLOyUnhDUFZeGnUzU=; b=tPlEfyy1XM6MSwuWnCNyUHbBzj x1KC7j4g7a13vw1Ab3senC6y6thcoc+FMkTQW4llwAcGbS6xB52Z/jKJyOnMY2JCojx34sC328nY/ XSuRJlqi8v2qNxyI/U3/V6mdI; Received: from [50.236.237.38] (port=44172 helo=bapiya.TCHFunNetwork.pvt) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1gejSe-003p9x-E5; Wed, 02 Jan 2019 10:33:40 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [FYI] Style improvements in gdb/python Date: Wed, 2 Jan 2019 09:33:38 -0700 Message-Id: <20190102163338.24720-1-tom@tromey.com> This fixes a few minor style issues I found in gdb/python: some unnecessary casts, the removal of an unnecessary local variable, and one instance of incorrect formatting. Tested by rebuilding and re-running gdb.python. gdb/ChangeLog 2019-01-02 Tom Tromey * python/py-inferior.c (gdbpy_initialize_inferior): Fix indentation. * python/py-frame.c (frapy_older): Remove cast. (frapy_newer): Likewise. * python/py-breakpoint.c (local_setattro): Remove cast. * python/py-arch.c (archpy_name): Remove local variable. * python/py-type.c (gdbpy_lookup_type): Remove cast. --- gdb/ChangeLog | 10 ++++++++++ gdb/python/py-arch.c | 5 +---- gdb/python/py-breakpoint.c | 2 +- gdb/python/py-frame.c | 4 ++-- gdb/python/py-inferior.c | 4 ++-- gdb/python/py-type.c | 2 +- 6 files changed, 17 insertions(+), 10 deletions(-) diff --git a/gdb/python/py-arch.c b/gdb/python/py-arch.c index 64f6563e88..cbdd881873 100644 --- a/gdb/python/py-arch.c +++ b/gdb/python/py-arch.c @@ -97,14 +97,11 @@ archpy_name (PyObject *self, PyObject *args) { struct gdbarch *gdbarch = NULL; const char *name; - PyObject *py_name; ARCHPY_REQUIRE_VALID (self, gdbarch); name = (gdbarch_bfd_arch_info (gdbarch))->printable_name; - py_name = PyString_FromString (name); - - return py_name; + return PyString_FromString (name); } /* Implementation of diff --git a/gdb/python/py-breakpoint.c b/gdb/python/py-breakpoint.c index 1d0c3d2e84..f41d88dbf5 100644 --- a/gdb/python/py-breakpoint.c +++ b/gdb/python/py-breakpoint.c @@ -1196,7 +1196,7 @@ local_setattro (PyObject *self, PyObject *name, PyObject *v) } } - return PyObject_GenericSetAttr ((PyObject *)self, name, v); + return PyObject_GenericSetAttr (self, name, v); } static gdb_PyGetSetDef breakpoint_object_getset[] = { diff --git a/gdb/python/py-frame.c b/gdb/python/py-frame.c index d7f62c2c03..88a50e73e2 100644 --- a/gdb/python/py-frame.c +++ b/gdb/python/py-frame.c @@ -416,7 +416,7 @@ frapy_older (PyObject *self, PyObject *args) END_CATCH if (prev) - prev_obj = (PyObject *) frame_info_to_frame_object (prev); + prev_obj = frame_info_to_frame_object (prev); else { Py_INCREF (Py_None); @@ -449,7 +449,7 @@ frapy_newer (PyObject *self, PyObject *args) END_CATCH if (next) - next_obj = (PyObject *) frame_info_to_frame_object (next); + next_obj = frame_info_to_frame_object (next); else { Py_INCREF (Py_None); diff --git a/gdb/python/py-inferior.c b/gdb/python/py-inferior.c index 1c62a2c60e..b1b9e947ae 100644 --- a/gdb/python/py-inferior.c +++ b/gdb/python/py-inferior.c @@ -958,8 +958,8 @@ gdbpy_initialize_inferior (void) if (PyType_Ready (&membuf_object_type) < 0) return -1; - return gdb_pymodule_addobject (gdb_module, "Membuf", (PyObject *) - &membuf_object_type); + return gdb_pymodule_addobject (gdb_module, "Membuf", + (PyObject *) &membuf_object_type); } static gdb_PyGetSetDef inferior_object_getset[] = diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c index 0196eb2af9..88770fcc9f 100644 --- a/gdb/python/py-type.c +++ b/gdb/python/py-type.c @@ -1402,7 +1402,7 @@ gdbpy_lookup_type (PyObject *self, PyObject *args, PyObject *kw) if (! type) return NULL; - return (PyObject *) type_to_type_object (type); + return type_to_type_object (type); } int