From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25690 invoked by alias); 19 Apr 2013 14:43:59 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 25681 invoked by uid 89); 19 Apr 2013 14:43:59 -0000 X-Spam-SWARE-Status: No, score=-6.8 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.1 Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Fri, 19 Apr 2013 14:43:58 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r3JEhvKG017682 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 19 Apr 2013 10:43:57 -0400 Received: from barimba (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r3JEhu5o030949 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Fri, 19 Apr 2013 10:43:57 -0400 From: Tom Tromey To: gdb-patches@sourceware.org Subject: [PATCH 27/28] rearrange for some clarity in valpy_get_dynamic_type References: <87ehe638ww.fsf@fleche.redhat.com> Date: Fri, 19 Apr 2013 17:52:00 -0000 In-Reply-To: <87ehe638ww.fsf@fleche.redhat.com> (Tom Tromey's message of "Fri, 19 Apr 2013 08:13:51 -0600") Message-ID: <87sj2mwpg3.fsf@fleche.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SW-Source: 2013-04/txt/msg00611.txt.bz2 The checker noticed some funny code in valpy_get_dynamic_type. This simplifies the code a little and also changes an incref to an xincref; the current code could crash if type_to_type_object failed. * python/py-value.c (valpy_get_dynamic_type): Simplify dynamic_type assignment. Use Py_XINCREF. --- gdb/python/py-value.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c index e4f4263..df4bf77 100644 --- a/gdb/python/py-value.c +++ b/gdb/python/py-value.c @@ -334,18 +334,11 @@ valpy_get_dynamic_type (PyObject *self, void *closure) GDB_PY_HANDLE_EXCEPTION (except); if (type == NULL) - { - /* Ensure that the TYPE field is ready. */ - if (!valpy_get_type (self, NULL)) - return NULL; - /* We don't need to incref here, because valpy_get_type already - did it for us. */ - obj->dynamic_type = obj->type; - } + obj->dynamic_type = valpy_get_type (self, NULL); else obj->dynamic_type = type_to_type_object (type); - Py_INCREF (obj->dynamic_type); + Py_XINCREF (obj->dynamic_type); return obj->dynamic_type; } -- 1.8.1.4