From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16380 invoked by alias); 19 Apr 2013 14:39:22 -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 16367 invoked by uid 89); 19 Apr 2013 14:39:21 -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:39:21 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r3JEdK4U015960 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 19 Apr 2013 10:39:20 -0400 Received: from barimba (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r3JEdIac006215 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Fri, 19 Apr 2013 10:39:19 -0400 From: Tom Tromey To: gdb-patches@sourceware.org Subject: [PATCH 20/28] make set_sal follow negative result convention References: <87ehe638ww.fsf@fleche.redhat.com> Date: Fri, 19 Apr 2013 16:34: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: <87mwsuy489.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/msg00603.txt.bz2 This changes set_sal to follow the "negative means error" convention. This lets the checker understand it. * python/py-symtab.c (set_sal): Use CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION. Return -1 on error. (symtab_and_line_to_sal_object): Update. --- gdb/python/py-symtab.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/gdb/python/py-symtab.c b/gdb/python/py-symtab.c index 80a2282..fe26b4c 100644 --- a/gdb/python/py-symtab.c +++ b/gdb/python/py-symtab.c @@ -315,9 +315,8 @@ salpy_dealloc (PyObject *self) and initialized, populate the sal_object with the struct sal data. Also, register the sal_object life-cycle with the life-cycle of the object file associated with this sal, if needed. If a failure - occurs during the sal population, this function will return - NULL. */ -static int + occurs during the sal population, this function will return -1. */ +static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION set_sal (sal_object *sal_obj, struct symtab_and_line sal) { symtab_object *symtab_obj; @@ -328,7 +327,7 @@ set_sal (sal_object *sal_obj, struct symtab_and_line sal) /* If a symtab existed in the sal, but it cannot be duplicated, we exit. */ if (symtab_obj == NULL) - return 0; + return -1; } else { @@ -356,7 +355,7 @@ set_sal (sal_object *sal_obj, struct symtab_and_line sal) else sal_obj->next = NULL; - return 1; + return 0; } /* Given a symtab, and a symtab_object that has previously been @@ -398,7 +397,6 @@ symtab_to_symtab_object (struct symtab *symtab) that encapsulates the symtab_and_line structure from GDB. */ PyObject * symtab_and_line_to_sal_object (struct symtab_and_line sal) - { sal_object *sal_obj; int success = 0; @@ -406,8 +404,7 @@ symtab_and_line_to_sal_object (struct symtab_and_line sal) sal_obj = PyObject_New (sal_object, &sal_object_type); if (sal_obj) { - success = set_sal (sal_obj, sal); - if (!success) + if (set_sal (sal_obj, sal) < 0) { Py_DECREF (sal_obj); return NULL; -- 1.8.1.4