[gdb/python] Fix cpychecker error in recpy_bt_goto
authorTom de Vries <tdevries@suse.de>
Tue, 2 Oct 2018 19:47:37 +0000 (21:47 +0200)
committerTom de Vries <tdevries@suse.de>
Thu, 4 Oct 2018 22:20:07 +0000 (00:20 +0200)
When using cpychecker, we run into this error:
...
gdb/python/py-record-btrace.c: \
  In function ‘PyObject* recpy_bt_goto(PyObject*, PyObject*)’:
gdb/python/py-record-btrace.c:783:25: error: Mismatching type in call to \
  PyArg_ParseTuple with format code "O" [-Werror]
   if (!PyArg_ParseTuple (args, "O", &obj))
  argument 3 ("&obj") had type
    "const struct recpy_element_object * *"
  but was expecting
    "struct PyObject * *"
  for format code "O"
...

Fix this by using a new variable of the expected type instead.

Build and reg-tested on x86_64-linux.

2018-10-05  Tom de Vries  <tdevries@suse.de>

* python/py-record-btrace.c (recpy_bt_goto): Fix type mismatch in
PyArg_ParseTuple call.

gdb/ChangeLog
gdb/python/py-record-btrace.c

index d026da0ccc9d8dae9b0eea047c420fe4c6c2f7bf..47f879fdfedf44d64fc05fac3b1256024b3219c2 100644 (file)
@@ -1,3 +1,8 @@
+2018-10-05  Tom de Vries  <tdevries@suse.de>
+
+       * python/py-record-btrace.c (recpy_bt_goto): Fix type mismatch in
+       PyArg_ParseTuple call.
+
 2018-10-04  Joel Brobecker  <brobecker@adacore.com>
 
        * psymtab.c (recursively_search_psymtabs): Reformat parameters
index 057475e112fa3fa6b21de677332c9f73150774fd..44cb4419ea8f2fb77edeea2743e50bc39a14e880 100644 (file)
@@ -776,15 +776,17 @@ recpy_bt_goto (PyObject *self, PyObject *args)
   const recpy_record_object * const record = (recpy_record_object *) self;
   thread_info *const tinfo = record->thread;
   const recpy_element_object *obj;
+  PyObject *parse_obj;
 
   if (tinfo == NULL || btrace_is_empty (tinfo))
        return PyErr_Format (gdbpy_gdb_error, _("Empty branch trace."));
 
-  if (!PyArg_ParseTuple (args, "O", &obj))
+  if (!PyArg_ParseTuple (args, "O", &parse_obj))
     return NULL;
 
-  if (Py_TYPE (obj) != &recpy_insn_type)
+  if (Py_TYPE (parse_obj) != &recpy_insn_type)
     return PyErr_Format (PyExc_TypeError, _("Argument must be instruction."));
+  obj = (const recpy_element_object *) parse_obj;
 
   TRY
     {
This page took 0.032753 seconds and 4 git commands to generate.