* [RFA] Avoid -Wduplicated-cond warnings in gdb/python
@ 2016-07-21 19:48 Tom Tromey
2016-09-07 16:44 ` Tom Tromey
0 siblings, 1 reply; 3+ messages in thread
From: Tom Tromey @ 2016-07-21 19:48 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
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 <tom@tromey.com>
* 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 <tom@tromey.com>
+ * 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 <tom@tromey.com>
+
* configure: Rebuild.
* warning.m4 (AM_GDB_WARNINGS) <build_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);
--
2.7.4
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFA] Avoid -Wduplicated-cond warnings in gdb/python
2016-07-21 19:48 [RFA] Avoid -Wduplicated-cond warnings in gdb/python Tom Tromey
@ 2016-09-07 16:44 ` Tom Tromey
2016-09-15 15:21 ` Pedro Alves
0 siblings, 1 reply; 3+ messages in thread
From: Tom Tromey @ 2016-09-07 16:44 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
>>>>> "Tom" == Tom Tromey <tom@tromey.com> writes:
Tom> I tried building gdb with -Wduplicated-cond. This patch fixes the
Tom> simpler issue that was found.
[...]
Tom> 2016-07-21 Tom Tromey <tom@tromey.com>
Tom> * python/py-value.c (convert_value_from_python): Make PyInt_Check
Tom> conditional on Python 2.
Tom> * python/py-arch.c (archpy_disassemble): Make PyInt_Check
Tom> conditional on Python 2.
Ping.
I realized today that this was never reviewed.
Tom
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFA] Avoid -Wduplicated-cond warnings in gdb/python
2016-09-07 16:44 ` Tom Tromey
@ 2016-09-15 15:21 ` Pedro Alves
0 siblings, 0 replies; 3+ messages in thread
From: Pedro Alves @ 2016-09-15 15:21 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
On 09/07/2016 05:26 PM, Tom Tromey wrote:
>>>>>> "Tom" == Tom Tromey <tom@tromey.com> writes:
>
> Tom> I tried building gdb with -Wduplicated-cond. This patch fixes the
> Tom> simpler issue that was found.
>
> [...]
>
> Tom> 2016-07-21 Tom Tromey <tom@tromey.com>
>
> Tom> * python/py-value.c (convert_value_from_python): Make PyInt_Check
> Tom> conditional on Python 2.
> Tom> * python/py-arch.c (archpy_disassemble): Make PyInt_Check
> Tom> conditional on Python 2.
>
> Ping.
> I realized today that this was never reviewed.
This is OK. I'd be totally fine with you self approving
this...
Thanks,
Pedro Alves
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-09-15 15:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-21 19:48 [RFA] Avoid -Wduplicated-cond warnings in gdb/python Tom Tromey
2016-09-07 16:44 ` Tom Tromey
2016-09-15 15:21 ` Pedro Alves
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).