From patchwork Thu Jul 21 19:48:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 13913 Received: (qmail 87595 invoked by alias); 21 Jul 2016 19:48:47 -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 86735 invoked by uid 89); 21 Jul 2016 19:48:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=Rebuild, *args X-HELO: gproxy8-pub.mail.unifiedlayer.com Received: from gproxy8-pub.mail.unifiedlayer.com (HELO gproxy8-pub.mail.unifiedlayer.com) (67.222.33.93) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with SMTP; Thu, 21 Jul 2016 19:48:33 +0000 Received: (qmail 21152 invoked by uid 0); 21 Jul 2016 19:48:31 -0000 Received: from unknown (HELO cmgw2) (10.0.90.83) by gproxy8.mail.unifiedlayer.com with SMTP; 21 Jul 2016 19:48:31 -0000 Received: from box522.bluehost.com ([74.220.219.122]) by cmgw2 with id MXoQ1t0192f2jeq01XoT6t; Thu, 21 Jul 2016 13:48:29 -0600 X-Authority-Analysis: v=2.1 cv=KaJB72oD c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=PnD2wP_eR3oA:10 a=C6ZbYQPAFpEA:10 a=cAmyUtKerLwA:10 a=zstS-IiYAAAA:8 a=hqCvG8uqPDYsqdoLIuEA:9 a=4G6NA9xxw8l3yy4pmD5M:22 Received: from [75.171.160.169] (port=45936 helo=bapiya.Home) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.86_2) (envelope-from ) id 1bQJxK-0007Mp-HI; Thu, 21 Jul 2016 13:48:26 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA] Avoid -Wduplicated-cond warnings in gdb/python Date: Thu, 21 Jul 2016 13:48:16 -0600 Message-Id: <1469130496-15433-1-git-send-email-tom@tromey.com> X-Identified-User: {36111:box522.bluehost.com:elynrobi:tromey.com} {sentby:smtp auth 75.171.160.169 authed with tom+tromey.com} X-Exim-ID: 1bQJxK-0007Mp-HI X-Source-Sender: (bapiya.Home) [75.171.160.169]:45936 X-Source-Auth: tom+tromey.com X-Email-Count: 0 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== I tried building gdb with -Wduplicated-cond. This patch fixes the simpler issue that was found. In Python 3, "int" and "long" are synonyms, so code like: else if (PyLong_Check (obj)) ... else if (PyInt_Check (obj)) .... will trigger this warning. The fix is to conditionalize the PyInt_Check branches on Python 2. Tested by rebuilding, with both version of Python, on x86-64 Fedora 24. 2016-07-21 Tom Tromey * python/py-value.c (convert_value_from_python): Make PyInt_Check conditional on Python 2. * python/py-arch.c (archpy_disassemble): Make PyInt_Check conditional on Python 2. --- gdb/ChangeLog | 7 +++++++ gdb/python/py-arch.c | 2 ++ gdb/python/py-value.c | 2 ++ 3 files changed, 11 insertions(+) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 706c34d..3d616aa 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,12 @@ 2016-07-21 Tom Tromey + * python/py-value.c (convert_value_from_python): Make PyInt_Check + conditional on Python 2. + * python/py-arch.c (archpy_disassemble): Make PyInt_Check + conditional on Python 2. + +2016-07-21 Tom Tromey + * configure: Rebuild. * warning.m4 (AM_GDB_WARNINGS) : Add -Wunused-but-set-parameter, -Wunused-but-set-variable. diff --git a/gdb/python/py-arch.c b/gdb/python/py-arch.c index 0f7d432..4a2dcbf 100644 --- a/gdb/python/py-arch.c +++ b/gdb/python/py-arch.c @@ -141,10 +141,12 @@ archpy_disassemble (PyObject *self, PyObject *args, PyObject *kw) conversion process. */ if (PyLong_Check (end_obj)) end = PyLong_AsUnsignedLongLong (end_obj); +#if PY_MAJOR_VERSION == 2 else if (PyInt_Check (end_obj)) /* If the end_pc value is specified without a trailing 'L', end_obj will be an integer and not a long integer. */ end = PyInt_AsLong (end_obj); +#endif else { Py_DECREF (end_obj); diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c index 21e9247..b0d3df3 100644 --- a/gdb/python/py-value.c +++ b/gdb/python/py-value.c @@ -1642,6 +1642,7 @@ convert_value_from_python (PyObject *obj) else value = value_from_longest (builtin_type_pylong, l); } +#if PY_MAJOR_VERSION == 2 else if (PyInt_Check (obj)) { long l = PyInt_AsLong (obj); @@ -1649,6 +1650,7 @@ convert_value_from_python (PyObject *obj) if (! PyErr_Occurred ()) value = value_from_longest (builtin_type_pyint, l); } +#endif else if (PyFloat_Check (obj)) { double d = PyFloat_AsDouble (obj);