From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id ScrECi6kd2rfFhUAWB0awg (envelope-from ) for ; Sat, 08 Aug 2026 17:48:30 -0400 Authentication-Results: simark.ca; dkim=fail reason="signature verification failed" (768-bit key; unprotected) header.d=tromey.com header.i=@tromey.com header.a=rsa-sha256 header.s=default header.b=MREjlcpt; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 2606A1E166; Sat, 08 Aug 2026 17:48:30 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.1 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_INVALID,DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id DE1801E09B for ; Sat, 08 Aug 2026 17:48:28 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 718EE4BA9012 for ; Sat, 8 Aug 2026 21:48:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 718EE4BA9012 Authentication-Results: sourceware.org; dkim=fail reason="signature verification failed" (768-bit key, unprotected) header.d=tromey.com header.i=@tromey.com header.a=rsa-sha256 header.s=default header.b=MREjlcpt Received: from omta038.useast.a.cloudfilter.net (omta038.useast.a.cloudfilter.net [44.202.169.37]) by sourceware.org (Postfix) with ESMTPS id C4A614BA79AD for ; Sat, 8 Aug 2026 21:47:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C4A614BA79AD Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C4A614BA79AD Authentication-Results: sourceware.org; arc=none smtp.remote-ip=44.202.169.37 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1786225650; cv=none; b=OwTwkqEezmY4zIq+rVbvDclCK8vciJ94VRerNakEhkFBVURFc7Njg7BMUx9Bumaq2rWKDjWcnxOI7/Q4K/ds8+7EzoHNS6wuhtFzyAOocZ/lNaHymmO+Zz4vzD7y5UmsCcy1olI+mVtsS4DpaztzZ883y5+ez1/eX9qAD2Vpb90= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1786225650; c=relaxed/simple; bh=R/3IBC7gWkxpyfc7i33TfAXu1R/dvpSQLGEJr0nie+A=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=XijfSuH7/+1OD0rS+60uT2Q33wJtlpYXAhBOsj8rb3UIAxCf02QtxM0KeHWibTWTgCRqLYpcXcvanngPVHabxhX5clwQBJj4W8HJh6qx8d8vBFRuJ7Vw3slwKu/ybLRu/IlGXs1UCv9TvSLk26dxG5OdjSOCVBQ83PDoOsCS/sM= ARC-Authentication-Results: i=1; sourceware.org; dkim=policy (768-bit key, unprotected) header.d=tromey.com header.i=@tromey.com header.a=rsa-sha256 header.s=default header.b=MREjlcpt reason="signing key too small" DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C4A614BA79AD Received: from eig-obgw-5003b.ext.cloudfilter.net ([10.0.29.155]) by cmsmtp with ESMTPS id snE9wqv67JFmFsot8wsgOz; Sat, 08 Aug 2026 21:47:30 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id sot7wtoaDR2Qysot7wWWtH; Sat, 08 Aug 2026 21:47:29 +0000 X-Authority-Analysis: v=2.4 cv=fI053Yae c=1 sm=1 tr=0 ts=6a77a3f1 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=IkcTkHD0fZMA:10 a=Sv0fKeRqtYgA:10 a=ItBw4LHWJt0A:10 a=NnOtQkUPE0lCE3VKbn8A:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=O8hF6Hzn-FEA:10 a=DCx65vhANUyCzuf5D8fC:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From:Sender: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=MF0yZ/UVUj8LozqZpeSrsY9paVRAzyedzveTdao9588=; b=MREjlcptMlVbyYWrsW8khnHN3B HnyLxE6M1ZNyioVVYSVWfWL01JqNDlHT5esBc/SPmx8unz8agQB+pUFXwFrQKj6fyKdG1auwo56vA 2On9rMS/yQQeBXEFibXpcuiAR; Received: from 75-166-225-82.hlrn.qwest.net ([75.166.225.82]:34168 helo=[192.168.122.1]) by box5379.bluehost.com with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.99.5) (envelope-from ) id 1wsot7-00000001wX6-08Rb; Sat, 08 Aug 2026 15:47:29 -0600 From: Tom Tromey Date: Sat, 08 Aug 2026 15:47:28 -0600 Subject: [PATCH 4/4] Remove unneeded casts to PyObject* MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260808-python-safety-events-simple-v1-4-132aea40c801@tromey.com> References: <20260808-python-safety-events-simple-v1-0-132aea40c801@tromey.com> In-Reply-To: <20260808-python-safety-events-simple-v1-0-132aea40c801@tromey.com> To: gdb-patches@sourceware.org Cc: Tom Tromey X-Mailer: b4 0.14.3 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 75.166.225.82 X-Source-L: No X-Exim-ID: 1wsot7-00000001wX6-08Rb X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 75-166-225-82.hlrn.qwest.net ([192.168.122.1]) [75.166.225.82]:34168 X-Source-Auth: tom+tromey.com X-Email-Count: 5 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfCcdUvie4dNCNCBJzoFCIKxVxE0e0mpC0l7+cbWR9xdvYgItMa9kBgbpfROXvsTs4rW4Vv9aLxf9LkIvIT1epV1TsV7y0xHgUKO6iOMGwtV8mBax27V+ r47oy2WavNVV9t/xGyzBltEoPy1szCYFQqKYEFUg9dLj5294ncwmuROWmWNDUNyQF1AvSjThdK11fKcaiBhTOB5mXkJqf/uF384= X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org 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 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 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 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; - 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 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