[PATCH 4/4] Remove unneeded casts to PyObject*

Tom Tromey <[email protected]>
Newsgroups gmane.comp.gdb.patches
Message-ID <20260808-python-safety-events-simple-v1-4-132aea40c801@tromey.com>
Since Python wrapper objects now derive from PyObject, upcasts to
"PyObject *" are no longer needed.  This removes many such casts.
---
 gdb/python/py-arch.c             |  2 +-
 gdb/python/py-block.c            |  2 +-
 gdb/python/py-breakpoint.c       | 19 +++++++------------
 gdb/python/py-cmd.c              |  8 ++++----
 gdb/python/py-corefile.c         |  6 +++---
 gdb/python/py-disasm.c           | 13 ++++++-------
 gdb/python/py-evts.c             |  4 +---
 gdb/python/py-finishbreakpoint.c |  7 +++----
 gdb/python/py-inferior.c         |  8 +++-----
 gdb/python/py-infthread.c        |  2 +-
 gdb/python/py-lazy-string.c      |  2 +-
 gdb/python/py-linetable.c        |  4 ++--
 gdb/python/py-membuf.c           |  2 +-
 gdb/python/py-micmd.c            |  2 +-
 gdb/python/py-objfile.c          |  7 +++----
 gdb/python/py-progspace.c        |  2 +-
 gdb/python/py-record-btrace.c    |  2 +-
 gdb/python/py-record.c           | 10 +++++-----
 gdb/python/py-registers.c        |  4 ++--
 gdb/python/py-stopevent.c        |  3 +--
 gdb/python/py-tui.c              |  2 +-
 gdb/python/py-type.c             |  6 +++---
 gdb/python/py-unwind.c           | 12 +++++-------
 23 files changed, 57 insertions(+), 72 deletions(-)

diff --git a/gdb/python/py-arch.c b/gdb/python/py-arch.c
index 5b3cfbdc876..24009c958da 100644
--- a/gdb/python/py-arch.c
+++ b/gdb/python/py-arch.c
@@ -59,7 +59,7 @@ arch_object_data_init (struct gdbarch *gdbarch)
 
   arch_obj->gdbarch = gdbarch;
 
-  return (PyObject *) arch_obj;
+  return arch_obj;
 }
 
 /* Returns the struct gdbarch value corresponding to the given Python
diff --git a/gdb/python/py-block.c b/gdb/python/py-block.c
index 99c487bc875..593c39486f8 100644
--- a/gdb/python/py-block.c
+++ b/gdb/python/py-block.c
@@ -98,7 +98,7 @@ blpy_iter (PyObject *self)
   Py_INCREF (self);
   block_iter_obj->source = (block_object *) self;
 
-  return (PyObject *) block_iter_obj;
+  return block_iter_obj;
 }
 
 static PyObject *
diff --git a/gdb/python/py-breakpoint.c b/gdb/python/py-breakpoint.c
index b628e14ae4e..60794be198d 100644
--- a/gdb/python/py-breakpoint.c
+++ b/gdb/python/py-breakpoint.c
@@ -846,7 +846,7 @@ bppy_get_locations (PyObject *self, void *closure)
       Py_INCREF (self);
       py_bploc->owner = self_bp;
       py_bploc->bp_loc = ref.release ();
-      if (PyList_Append (list.get (), (PyObject *) py_bploc.get ()) != 0)
+      if (PyList_Append (list.get (), py_bploc.get ()) != 0)
 	return nullptr;
     }
   return list.release ();
@@ -1097,7 +1097,7 @@ bppy_repr (PyObject *self)
 static bool
 build_bp_list (struct breakpoint *b, PyObject *list)
 {
-  PyObject *bp = (PyObject *) b->py_bp_object;
+  PyObject *bp = b->py_bp_object;
 
   /* Not all breakpoints will have a companion Python object.
      Only breakpoints that were created via bppy_new, or
@@ -1161,7 +1161,6 @@ gdbpy_breakpoint_cond_says_stop (const struct extension_language_defn *extlang,
 {
   int stop;
   struct gdbpy_breakpoint_object *bp_obj = b->py_bp_object;
-  PyObject *py_bp = (PyObject *) bp_obj;
 
   if (bp_obj == NULL)
     return EXT_LANG_BP_STOP_UNSET;
@@ -1173,9 +1172,9 @@ gdbpy_breakpoint_cond_says_stop (const struct extension_language_defn *extlang,
   if (bp_obj->is_finish_bp)
     bpfinishpy_pre_stop_hook (bp_obj);
 
-  if (PyObject_HasAttrString (py_bp, stop_func))
+  if (PyObject_HasAttrString (bp_obj, stop_func))
     {
-      gdbpy_ref<> result = gdbpy_call_method (py_bp, stop_func);
+      gdbpy_ref<> result = gdbpy_call_method (bp_obj, stop_func);
 
       stop = 1;
       if (result != NULL)
@@ -1210,15 +1209,11 @@ int
 gdbpy_breakpoint_has_cond (const struct extension_language_defn *extlang,
 			   struct breakpoint *b)
 {
-  PyObject *py_bp;
-
   if (b->py_bp_object == NULL)
     return 0;
 
-  py_bp = (PyObject *) b->py_bp_object;
-
   gdbpy_enter enter_py (b->gdbarch);
-  return PyObject_HasAttrString (py_bp, stop_func);
+  return PyObject_HasAttrString (b->py_bp_object, stop_func);
 }
 
 
@@ -1337,7 +1332,7 @@ gdbpy_breakpoint_modified (struct breakpoint *b)
     {
       gdbpy_enter enter_py (b->gdbarch);
 
-      PyObject *bp_obj = (PyObject *) bp->py_bp_object;
+      PyObject *bp_obj = bp->py_bp_object;
       if (bp_obj)
 	{
 	  if (!evregpy_no_listeners_p (gdb_py_events.breakpoint_modified))
@@ -1625,7 +1620,7 @@ bplocpy_get_owner (PyObject *py_self, void *closure)
   BPPY_REQUIRE_VALID (self->owner);
   BPLOCPY_REQUIRE_VALID (self->owner, self);
   Py_INCREF (self->owner);
-  return (PyObject *) self->owner;
+  return self->owner;
 }
 
 /* Attempt to get fully resolved file path for symtab.  */
diff --git a/gdb/python/py-cmd.c b/gdb/python/py-cmd.c
index 24938fcda15..c305c0ab5a4 100644
--- a/gdb/python/py-cmd.c
+++ b/gdb/python/py-cmd.c
@@ -111,7 +111,7 @@ cmdpy_function (const char *args, int from_tty, cmd_list_element *command)
      'invoke' method when it was created.  If the 'invoke' method is now
      missing, then the user has done something weird (like deleting the
      invoke method, yuck!).  */
-  if (!PyObject_HasAttr ((PyObject *) obj, invoke_cst))
+  if (!PyObject_HasAttr (obj, invoke_cst))
     error (_("Python command object missing 'invoke' method."));
 
   if (args == nullptr)
@@ -125,7 +125,7 @@ cmdpy_function (const char *args, int from_tty, cmd_list_element *command)
     }
 
   gdbpy_ref<> ttyobj (PyBool_FromLong (from_tty));
-  gdbpy_ref<> result (PyObject_CallMethodObjArgs ((PyObject *) obj, invoke_cst,
+  gdbpy_ref<> result (PyObject_CallMethodObjArgs (obj, invoke_cst,
 						  argobj.get (), ttyobj.get (),
 						  NULL));
 
@@ -170,7 +170,7 @@ cmdpy_completer_helper (struct cmd_list_element *command,
 
   if (obj == NULL)
     error (_("Invalid invocation of Python command object."));
-  if (!PyObject_HasAttr ((PyObject *) obj, complete_cst))
+  if (!PyObject_HasAttr (obj, complete_cst))
     {
       /* If there is no complete method, don't error.  */
       return NULL;
@@ -201,7 +201,7 @@ cmdpy_completer_helper (struct cmd_list_element *command,
 	}
     }
 
-  gdbpy_ref<> resultobj (PyObject_CallMethodObjArgs ((PyObject *) obj,
+  gdbpy_ref<> resultobj (PyObject_CallMethodObjArgs (obj,
 						     complete_cst,
 						     textobj.get (),
 						     wordobj.get (), NULL));
diff --git a/gdb/python/py-corefile.c b/gdb/python/py-corefile.c
index a1dee384edf..58eac984feb 100644
--- a/gdb/python/py-corefile.c
+++ b/gdb/python/py-corefile.c
@@ -123,7 +123,7 @@ gdbpy_core_file_from_inferior (inferior *inf)
   if (get_inferior_core_bfd (inf) == nullptr)
     return py_none ();
 
-  PyObject *result = (PyObject *) cfpy_inferior_corefile_data_key.get (inf);
+  PyObject *result = cfpy_inferior_corefile_data_key.get (inf);
   if (result != nullptr)
     return gdbpy_ref<>::new_reference (result);
 
@@ -294,7 +294,7 @@ cfpy_mapped_files (PyObject *self, PyObject *args)
 
 	  /* Add to the gdb.CorefileMappedFileRegion list.  */
 	  if (PyTuple_SetItem (regions.get (), regions_idx++,
-			       (PyObject *) region_obj.release ()) < 0)
+			       region_obj.release ()) < 0)
 	    return nullptr;
 	}
 
@@ -313,7 +313,7 @@ cfpy_mapped_files (PyObject *self, PyObject *args)
 
       /* Add to the gdb.CorefileMappedFile list.  */
       if (PyTuple_SetItem (tuple.get (), tuple_idx++,
-			   (PyObject *) entry.release ()) < 0)
+			   entry.release ()) < 0)
 	return nullptr;
     }
 
diff --git a/gdb/python/py-disasm.c b/gdb/python/py-disasm.c
index a2abf37a605..48a2a4f6f8b 100644
--- a/gdb/python/py-disasm.c
+++ b/gdb/python/py-disasm.c
@@ -282,7 +282,7 @@ disasm_info_init (PyObject *self, PyObject *args, PyObject *kwargs)
 
   /* As the OTHER object now holds a pointer to INFO we inc the ref count
      on INFO.  This stops INFO being deleted until OTHER has gone away.  */
-  Py_INCREF ((PyObject *) info);
+  Py_INCREF (info);
   return 0;
 }
 
@@ -296,7 +296,7 @@ disasm_info_dealloc (PyObject *self)
   /* We no longer care about the object our NEXT pointer points at, so we
      can decrement its reference count.  This macro handles the case when
      NEXT is nullptr.  */
-  Py_XDECREF ((PyObject *) obj->next);
+  Py_XDECREF (obj->next);
 
   /* Now core deallocation behavior.  */
   Py_TYPE (self)->tp_free (self);
@@ -354,7 +354,7 @@ make_disasm_text_part (std::string &&str, enum disassembler_style style)
   text_part->string = new std::string (str);
   text_part->style = style;
 
-  return gdbpy_ref<> ((PyObject *) text_part);
+  return gdbpy_ref<> (text_part);
 }
 
 /* Create a new DisassemblerAddressPart and return a gdbpy_ref wrapper for
@@ -370,7 +370,7 @@ make_disasm_addr_part (struct gdbarch *gdbarch, CORE_ADDR address)
   addr_part->address = address;
   addr_part->gdbarch = gdbarch;
 
-  return gdbpy_ref<> ((PyObject *) addr_part);
+  return gdbpy_ref<> (addr_part);
 }
 
 /* Ensure that a gdb.disassembler.DisassembleInfo is valid.  */
@@ -837,8 +837,7 @@ gdbpy_disassembler::read_memory_func (bfd_vma memaddr, gdb_byte *buff,
 
   /* Now call the DisassembleInfo.read_memory method.  This might have been
      overridden by the user.  */
-  gdbpy_ref<> result_obj = gdbpy_call_method ((PyObject *) obj, "read_memory",
-					      len, offset);
+  gdbpy_ref<> result_obj = gdbpy_call_method (obj, "read_memory", len, offset);
 
   /* Handle any exceptions.  */
   if (result_obj == nullptr)
@@ -1236,7 +1235,7 @@ gdbpy_print_insn (struct gdbarch *gdbarch, CORE_ADDR memaddr,
      disassembly.  */
   gdbpy_ref<> result
     (PyObject_CallFunctionObjArgs (hook.get (),
-				   (PyObject *) disasm_info.get (),
+				   disasm_info.get (),
 				   nullptr));
 
   if (result == nullptr)
diff --git a/gdb/python/py-evts.c b/gdb/python/py-evts.c
index 67d6caff478..adb747025fd 100644
--- a/gdb/python/py-evts.c
+++ b/gdb/python/py-evts.c
@@ -43,9 +43,7 @@ add_new_registry (eventregistry_object **registryp, const char *name)
   if (*registryp == NULL)
     return -1;
 
-  return gdb_pymodule_addobject (gdb_py_events.mod,
-				 name,
-				 (PyObject *)(*registryp));
+  return gdb_pymodule_addobject (gdb_py_events.mod, name, *registryp);
 }
 
 /* Create and populate the _gdbevents module.  Note that this is
diff --git a/gdb/python/py-finishbreakpoint.c b/gdb/python/py-finishbreakpoint.c
index 49e12c00054..9f3b90acdec 100644
--- a/gdb/python/py-finishbreakpoint.c
+++ b/gdb/python/py-finishbreakpoint.c
@@ -343,12 +343,11 @@ static void
 bpfinishpy_out_of_scope (struct finish_breakpoint_object *bpfinish_obj)
 {
   gdbpy_breakpoint_object *bp_obj = (gdbpy_breakpoint_object *) bpfinish_obj;
-  PyObject *py_obj = (PyObject *) bp_obj;
 
   if (bpfinish_obj->py_bp.bp->enable_state == bp_enabled
-      && PyObject_HasAttrString (py_obj, outofscope_func))
+      && PyObject_HasAttrString (bp_obj, outofscope_func))
     {
-      gdbpy_ref<> meth_result = gdbpy_call_method (py_obj, outofscope_func);
+      gdbpy_ref<> meth_result = gdbpy_call_method (bp_obj, outofscope_func);
       if (meth_result == NULL)
 	gdbpy_print_stack ();
     }
@@ -366,7 +365,7 @@ bpfinishpy_detect_out_scope_cb (struct breakpoint *b,
 				struct breakpoint *bp_stopped,
 				bool delete_bp)
 {
-  PyObject *py_bp = (PyObject *) b->py_bp_object;
+  PyObject *py_bp = b->py_bp_object;
 
   /* Trigger out_of_scope if this is a FinishBreakpoint and its frame is
      not anymore in the current callstack.  */
diff --git a/gdb/python/py-inferior.c b/gdb/python/py-inferior.c
index dd2a3a0da24..4386489a8e7 100644
--- a/gdb/python/py-inferior.c
+++ b/gdb/python/py-inferior.c
@@ -296,8 +296,7 @@ thread_to_thread_object (thread_info *thr)
 
   auto thread_it = inf_obj->threads->find (thr);
   if (thread_it != inf_obj->threads->end ())
-    return gdbpy_ref<>::new_reference
-      ((PyObject *) (thread_it->second.get ()));
+    return gdbpy_ref<>::new_reference (thread_it->second.get ());
 
   PyErr_SetString (PyExc_SystemError,
 		   _("could not find gdb thread object"));
@@ -493,7 +492,7 @@ gdbpy_inferiors (PyObject *unused, PyObject *unused2)
       if (inferior == NULL)
 	continue;
 
-      if (PyList_Append (list.get (), (PyObject *) inferior.get ()) != 0)
+      if (PyList_Append (list.get (), inferior.get ()) != 0)
 	return NULL;
     }
 
@@ -985,8 +984,7 @@ infpy_dealloc (PyObject *obj)
 PyObject *
 gdbpy_selected_inferior (PyObject *self, PyObject *args)
 {
-  return ((PyObject *)
-	  inferior_to_inferior_object (current_inferior ()).release ());
+  return (inferior_to_inferior_object (current_inferior ()).release ());
 }
 
 /* Implement the selected_context event handler.  This is called when some
diff --git a/gdb/python/py-infthread.c b/gdb/python/py-infthread.c
index 96c736495a8..a5ea749cba9 100644
--- a/gdb/python/py-infthread.c
+++ b/gdb/python/py-infthread.c
@@ -48,7 +48,7 @@ create_thread_object (struct thread_info *tp)
     return nullptr;
 
   thread_obj->thread = tp;
-  thread_obj->inf_obj = (PyObject *) inf_obj.release ();
+  thread_obj->inf_obj = inf_obj.release ();
   if (!thread_obj->allocate_dict ())
     return nullptr;
 
diff --git a/gdb/python/py-lazy-string.c b/gdb/python/py-lazy-string.c
index c9d06338b0a..1ea14395a73 100644
--- a/gdb/python/py-lazy-string.c
+++ b/gdb/python/py-lazy-string.c
@@ -236,7 +236,7 @@ gdbpy_create_lazy_string_object (CORE_ADDR address, long length,
     str_obj->encoding = xstrdup (encoding);
   str_obj->type = type_to_type_object (type).release ();
 
-  return (PyObject *) str_obj;
+  return str_obj;
 }
 
 static int
diff --git a/gdb/python/py-linetable.c b/gdb/python/py-linetable.c
index faaedc5e9e8..e5683b1f60a 100644
--- a/gdb/python/py-linetable.c
+++ b/gdb/python/py-linetable.c
@@ -113,7 +113,7 @@ build_linetable_entry (int line, CORE_ADDR address)
       obj->pc = address;
     }
 
-  return (PyObject *) obj;
+  return obj;
 }
 
 /* Internal helper function to build a Python Tuple from a vector.
@@ -350,7 +350,7 @@ ltpy_iter (PyObject *self)
   ltpy_iter_obj->source = self;
 
   Py_INCREF (self);
-  return (PyObject *) ltpy_iter_obj;
+  return ltpy_iter_obj;
 }
 
 static void
diff --git a/gdb/python/py-membuf.c b/gdb/python/py-membuf.c
index fa5156b885e..7951e9a92ac 100644
--- a/gdb/python/py-membuf.c
+++ b/gdb/python/py-membuf.c
@@ -53,7 +53,7 @@ gdbpy_buffer_to_membuf (gdb::unique_xmalloc_ptr<gdb_byte> buffer,
   membuf_obj->addr = address;
   membuf_obj->length = length;
 
-  return PyMemoryView_FromObject ((PyObject *) membuf_obj.get ());
+  return PyMemoryView_FromObject (membuf_obj.get ());
 }
 
 /* Destructor for gdb.Membuf objects.  */
diff --git a/gdb/python/py-micmd.c b/gdb/python/py-micmd.c
index 9f6e664a5f2..ecdf4b72018 100644
--- a/gdb/python/py-micmd.c
+++ b/gdb/python/py-micmd.c
@@ -207,7 +207,7 @@ mi_command_py::invoke (struct mi_parse *parse) const
   gdb_assert (this->m_pyobj != nullptr);
   gdb_assert (PyErr_Occurred () == nullptr);
   gdbpy_ref<> results
-    (PyObject_CallMethodObjArgs ((PyObject *) this->m_pyobj.get (), invoke_cst,
+    (PyObject_CallMethodObjArgs (this->m_pyobj.get (), invoke_cst,
 				 argobj.get (), nullptr));
   if (results == nullptr)
     gdbpy_handle_exception ();
diff --git a/gdb/python/py-objfile.c b/gdb/python/py-objfile.c
index ec8b82fbe13..dcd326b696c 100644
--- a/gdb/python/py-objfile.c
+++ b/gdb/python/py-objfile.c
@@ -237,7 +237,7 @@ objfpy_new (PyTypeObject *type, PyObject *args, PyObject *keywords)
   if (self != nullptr && !objfpy_initialize (self))
     return nullptr;
 
-  return (PyObject *) self.release ();
+  return self.release ();
 }
 
 PyObject *
@@ -670,8 +670,7 @@ gdbpy_lookup_objfile (PyObject *self, PyObject *args, PyObject *kw)
 gdbpy_ref<>
 objfile_to_objfile_object (struct objfile *objfile)
 {
-  PyObject *result
-    = (PyObject *) objfpy_objfile_data_key.get (objfile);
+  PyObject *result = objfpy_objfile_data_key.get (objfile);
   if (result == NULL)
     {
       gdbpy_ref<objfile_object> object
@@ -683,7 +682,7 @@ objfile_to_objfile_object (struct objfile *objfile)
 
       object->objfile = objfile;
       objfpy_objfile_data_key.set (objfile, object.get ());
-      result = (PyObject *) object.release ();
+      result = object.release ();
     }
 
   return gdbpy_ref<>::new_reference (result);
diff --git a/gdb/python/py-progspace.c b/gdb/python/py-progspace.c
index a88535bdca9..de6bfc65346 100644
--- a/gdb/python/py-progspace.c
+++ b/gdb/python/py-progspace.c
@@ -583,7 +583,7 @@ pspy_is_valid (PyObject *o, PyObject *args)
 gdbpy_ref<>
 pspace_to_pspace_object (struct program_space *pspace)
 {
-  PyObject *result = (PyObject *) pspy_pspace_data_key.get (pspace);
+  PyObject *result = pspy_pspace_data_key.get (pspace);
   if (result != nullptr)
     return gdbpy_ref<>::new_reference (result);
 
diff --git a/gdb/python/py-record-btrace.c b/gdb/python/py-record-btrace.c
index e60bc44e81f..a73167a5bdd 100644
--- a/gdb/python/py-record-btrace.c
+++ b/gdb/python/py-record-btrace.c
@@ -197,7 +197,7 @@ btpy_list_new (thread_info *thread, Py_ssize_t first, Py_ssize_t last,
   obj->step = step;
   obj->element_type = element_type;
 
-  return (PyObject *) obj;
+  return obj;
 }
 
 /* Implementation of RecordInstruction.sal [gdb.Symtab_and_line] for btrace.
diff --git a/gdb/python/py-record.c b/gdb/python/py-record.c
index 15e1b9f3316..c3ac53336eb 100644
--- a/gdb/python/py-record.c
+++ b/gdb/python/py-record.c
@@ -208,7 +208,7 @@ recpy_insn_new (thread_info *thread, enum record_method method,
   obj->method = method;
   obj->number = number;
 
-  return (PyObject *) obj;
+  return obj;
 }
 
 /* Implementation of RecordInstruction.sal [gdb.Symtab_and_line].  */
@@ -305,7 +305,7 @@ recpy_func_new (thread_info *thread, enum record_method method,
   obj->method = method;
   obj->number = number;
 
-  return (PyObject *) obj;
+  return obj;
 }
 
 /* Implementation of RecordFunctionSegment.level [int].  */
@@ -460,7 +460,7 @@ recpy_gap_new (int reason_code, const char *reason_string, Py_ssize_t number)
   obj->reason_string = reason_string;
   obj->number = number;
 
-  return (PyObject *) obj;
+  return obj;
 }
 
 /* Implementation of RecordGap.number [int].  */
@@ -509,7 +509,7 @@ recpy_aux_new (thread_info *thread, enum record_method method,
   obj->method = method;
   obj->number = number;
 
-  return (PyObject *) obj;
+  return obj;
 }
 
 /* Implementation of Auxiliary.data [buffer].  */
@@ -698,7 +698,7 @@ gdbpy_current_recording (PyObject *self, PyObject *args)
   ret->thread = inferior_thread ();
   ret->method = target_record_method (ret->thread->ptid);
 
-  return (PyObject *) ret;
+  return ret;
 }
 
 /* Implementation of gdb.stop_recording (self) -> None.  */
diff --git a/gdb/python/py-registers.c b/gdb/python/py-registers.c
index e0180660715..348acbfd4d0 100644
--- a/gdb/python/py-registers.c
+++ b/gdb/python/py-registers.c
@@ -244,7 +244,7 @@ gdbpy_new_reggroup_iterator (struct gdbarch *gdbarch)
     return NULL;
   iter->index = 0;
   iter->gdbarch = gdbarch;
-  return (PyObject *) iter;
+  return iter;
 }
 
 /* Create and return a new gdb.RegisterDescriptorIterator object which
@@ -286,7 +286,7 @@ gdbpy_new_register_descriptor_iterator (struct gdbarch *gdbarch,
   gdb_assert (grp != NULL);
   iter->reggroup = grp;
 
-  return (PyObject *) iter;
+  return iter;
 }
 
 /* Return a reference to the gdb.RegisterDescriptorIterator object.  */
diff --git a/gdb/python/py-stopevent.c b/gdb/python/py-stopevent.c
index cdb1ad3fc50..01c95b66e9d 100644
--- a/gdb/python/py-stopevent.c
+++ b/gdb/python/py-stopevent.c
@@ -123,8 +123,7 @@ emit_stop_event (struct bpstat *bs, enum gdb_signal stop_signal)
       if (current_bs->breakpoint_at
 	  && current_bs->breakpoint_at->py_bp_object)
 	{
-	  PyObject *current_py_bp =
-	      (PyObject *) current_bs->breakpoint_at->py_bp_object;
+	  PyObject *current_py_bp = current_bs->breakpoint_at->py_bp_object;
 
 	  if (list == NULL)
 	    {
diff --git a/gdb/python/py-tui.c b/gdb/python/py-tui.c
index 625de3bf87b..465fbd2fe6d 100644
--- a/gdb/python/py-tui.c
+++ b/gdb/python/py-tui.c
@@ -420,7 +420,7 @@ gdbpy_tui_window_maker::operator() (const char *win_name)
 
   gdbpy_ref<> user_window
     (PyObject_CallFunctionObjArgs (m_constr.get (),
-				   (PyObject *) wrapper.get (),
+				   wrapper.get (),
 				   nullptr));
   if (user_window == nullptr)
     {
diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c
index 9dd0fe2ab37..996fe54bb84 100644
--- a/gdb/python/py-type.c
+++ b/gdb/python/py-type.c
@@ -91,7 +91,7 @@ field_dealloc (PyObject *obj)
   Py_TYPE (obj)->tp_free (obj);
 }
 
-static PyObject *
+static gdbpy_ref<>
 field_new (void)
 {
   gdbpy_ref<field_object> result (PyObject_New (field_object,
@@ -100,7 +100,7 @@ field_new (void)
   if (result != nullptr && !result->allocate_dict ())
     return nullptr;
 
-  return (PyObject *) result.release ();
+  return result;
 }
 
 
@@ -1347,7 +1347,7 @@ typy_make_iter (PyObject *self, enum gdbpy_iter_kind kind)
   Py_INCREF (self);
   typy_iter_obj->source = (type_object *) self;
 
-  return (PyObject *) typy_iter_obj;
+  return typy_iter_obj;
 }
 
 /* iteritems() method.  */
diff --git a/gdb/python/py-unwind.c b/gdb/python/py-unwind.c
index 13eced4cecb..feeba40fe84 100644
--- a/gdb/python/py-unwind.c
+++ b/gdb/python/py-unwind.c
@@ -294,7 +294,7 @@ pyuw_create_unwind_info (PyObject *pyo_pending_frame,
   Py_INCREF (pyo_pending_frame);
   unwind_info->pending_frame = pyo_pending_frame;
   unwind_info->saved_regs = new std::vector<saved_reg>;
-  return (PyObject *) unwind_info;
+  return unwind_info;
 }
 
 /* The implementation of
@@ -864,10 +864,9 @@ frame_unwind_python::sniff (const frame_info_ptr &this_frame,
 		     paddress (gdbarch, get_frame_pc (this_frame)));
 
   /* Create PendingFrame instance to pass to sniffers.  */
-  pending_frame_object *pfo = PyObject_New (pending_frame_object,
-					    &pending_frame_object_type);
-  gdbpy_ref<> pyo_pending_frame ((PyObject *) pfo);
-  if (pyo_pending_frame == NULL)
+  gdbpy_ref<pending_frame_object> pfo
+    (PyObject_New (pending_frame_object, &pending_frame_object_type));
+  if (pfo == NULL)
     {
       gdbpy_print_stack ();
       return 0;
@@ -900,8 +899,7 @@ frame_unwind_python::sniff (const frame_info_ptr &this_frame,
 
   /* A (gdb.UnwindInfo, str) tuple, or None.  */
   gdbpy_ref<> pyo_execute_ret
-    (PyObject_CallFunctionObjArgs (pyo_execute.get (),
-				   pyo_pending_frame.get (), NULL));
+    (PyObject_CallFunctionObjArgs (pyo_execute.get (), pfo.get (), nullptr));
   if (pyo_execute_ret == nullptr)
     {
       /* If the unwinder is cancelled due to a Ctrl-C, then propagate

-- 
2.49.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.