From: Tom Tromey Date: Thu, 21 Jul 2016 19:41:54 +0000 (-0600) Subject: Avoid -Wduplicated-cond warnings in gdb/python X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=12c58cd4dc805cbac97a6d93c971c2496313dce4;p=binutils-gdb.git Avoid -Wduplicated-cond warnings in gdb/python 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-09-20 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. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 2b0589a4900..ef18a19a878 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,10 @@ +2016-09-20 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-09-20 Edjunior Barbosa Machado * rs6000-tdep.c (ppc_process_record_op31): Fix record of Store String diff --git a/gdb/python/py-arch.c b/gdb/python/py-arch.c index 0f7d432e2d1..4a2dcbf82ee 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 21e9247857a..b0d3df3e42d 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);