From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id GV33JMpIqGoruQwAWB0awg (envelope-from ) for ; Mon, 14 Sep 2026 15:19:38 -0400 Received: by simark.ca (Postfix, from userid 112) id 9378B1E051; Mon, 14 Sep 2026 15:19:38 -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.3 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [IPv6:2620:52:6:3111::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 14E6E1E051 for ; Mon, 14 Sep 2026 15:19:38 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2672A4BB1C29 for ; Mon, 14 Sep 2026 19:19:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2672A4BB1C29 Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id A44E24B9DB4D for ; Mon, 14 Sep 2026 19:19:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A44E24B9DB4D Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=efficios.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=efficios.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A44E24B9DB4D Authentication-Results: sourceware.org; arc=none smtp.remote-ip=158.69.221.121 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1789413552; cv=none; b=O5vZFYBEsmyX69BIPiEdhoILsiXwTKCoKx4BzQuWkxFNOrEjts7IHOHdf8OC0rioGTrrbtcSYlQflQNN/7um85mHvd4WeEFk0Gv8hJH5a8cfHZPe2wTIjcb+4S9NtT2izmTpZwh2kISK1om2Nj0f9H9EvUU1mDK7/Gpw/ldZoog= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1789413552; c=relaxed/simple; bh=VwYd4bZLf0Qi0WdY/zX3+NK2m9xrVxU/JxEsyg/jhxM=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=NKR54zZSrAmmMYpcOwmuvSzGG2IVEHY6gBW6mqs44UDZHPOSXhV7RfHsuDGnPl1OC+IFoFGrVTeZAh8HwIIzwG5uQtV1tzb+upbXb/Z28dc69WIQ8rOd4XwI6ACDHWUzmbYt9DUKfA9xrEEXYfoS5EyvyMftM2pj9NMF6H7b2Iw= ARC-Authentication-Results: i=1; sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A44E24B9DB4D Received: by simark.ca (Postfix) id C6A961E06B; Mon, 14 Sep 2026 15:19:11 -0400 (EDT) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 4/4] gdb/python: remove more useless casts Date: Mon, 14 Sep 2026 15:19:04 -0400 Message-ID: <20260914191908.557014-4-simon.marchi@efficios.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260914191908.557014-1-simon.marchi@efficios.com> References: <20260914191908.557014-1-simon.marchi@efficios.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Remove a few (more) casts made unnecessary now that the GDB Python objects inherit from PyObject. A bunch of them were removed already by commit 45e21c702fb ("Remove unneeded casts to PyObject*"). In one spot, I remove some now unnecessary parentheses where a cast was removed by that previous patch. Change-Id: I04e09497560b484c82d2bf29bdde34d3ffc31aec --- gdb/python/py-disasm.c | 5 ++--- gdb/python/py-finishbreakpoint.c | 6 ++---- gdb/python/py-inferior.c | 2 +- gdb/python/py-objfile.c | 2 +- gdb/python/python-internal.h | 2 +- 5 files changed, 7 insertions(+), 10 deletions(-) diff --git a/gdb/python/py-disasm.c b/gdb/python/py-disasm.c index 48a2a4f6f8b8..c9dfd1f4571a 100644 --- a/gdb/python/py-disasm.c +++ b/gdb/python/py-disasm.c @@ -608,7 +608,7 @@ disasmpy_builtin_disassemble (PyObject *self, PyObject *args, PyObject *kw) ((disasm_result_object *) type->tp_alloc (type, 0)); auto content = disassembler.release (); disasmpy_init_disassembler_result (res.get (), length, std::move (content)); - return reinterpret_cast (res.release ()); + return res.release (); } /* Implement gdb._set_enabled function. Takes a boolean parameter, and @@ -1215,8 +1215,7 @@ gdbpy_print_insn (struct gdbarch *gdbarch, CORE_ADDR memaddr, /* Create the new DisassembleInfo object we will pass into Python. */ gdbpy_ref disasm_info - ((disasm_info_object *) PyObject_New (disasm_info_object, - &disasm_info_object_type)); + (PyObject_New (disasm_info_object, &disasm_info_object_type)); if (disasm_info == nullptr) { gdbpy_print_stack (); diff --git a/gdb/python/py-finishbreakpoint.c b/gdb/python/py-finishbreakpoint.c index ec7399af4842..e81a9156ae6d 100644 --- a/gdb/python/py-finishbreakpoint.c +++ b/gdb/python/py-finishbreakpoint.c @@ -363,14 +363,12 @@ bpfinishpy_detect_out_scope_cb (struct breakpoint *b, struct breakpoint *bp_stopped, bool delete_bp) { - 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. */ - if (py_bp != NULL && b->py_bp_object->is_finish_bp) + if (b->py_bp_object != nullptr && b->py_bp_object->is_finish_bp) { struct finish_breakpoint_object *finish_bp = - (struct finish_breakpoint_object *) py_bp; + (struct finish_breakpoint_object *) b->py_bp_object; /* Check scope if not currently stopped at the FinishBreakpoint. */ if (b != bp_stopped) diff --git a/gdb/python/py-inferior.c b/gdb/python/py-inferior.c index 4c32a99e3ce7..82c0717d68f5 100644 --- a/gdb/python/py-inferior.c +++ b/gdb/python/py-inferior.c @@ -984,7 +984,7 @@ infpy_dealloc (PyObject *obj) PyObject * gdbpy_selected_inferior (PyObject *self, PyObject *args) { - return (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-objfile.c b/gdb/python/py-objfile.c index dcd326b696cf..414965c89aed 100644 --- a/gdb/python/py-objfile.c +++ b/gdb/python/py-objfile.c @@ -674,7 +674,7 @@ objfile_to_objfile_object (struct objfile *objfile) if (result == NULL) { gdbpy_ref object - ((objfile_object *) PyObject_New (objfile_object, &objfile_object_type)); + (PyObject_New (objfile_object, &objfile_object_type)); if (object == NULL) return NULL; if (!objfpy_initialize (object)) diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h index 2e8f35729cd6..acec6b346eff 100644 --- a/gdb/python/python-internal.h +++ b/gdb/python/python-internal.h @@ -1214,7 +1214,7 @@ class gdbpy_registry gdbpy_ref<> lookup (O *owner, val_type *val) const { obj_type *obj = get_storage (owner)->lookup (val); - Py_XINCREF (static_cast (obj)); + Py_XINCREF (obj); return gdbpy_ref<> (obj); } -- 2.55.0