From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:37889) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SpmC3-0003y4-3o for qemu-devel@nongnu.org; Fri, 13 Jul 2012 16:10:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SpmC2-0001jO-0C for qemu-devel@nongnu.org; Fri, 13 Jul 2012 16:10:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49734) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SpmC1-0001h0-Nt for qemu-devel@nongnu.org; Fri, 13 Jul 2012 16:10:25 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q6DKAOZV025913 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 13 Jul 2012 16:10:24 -0400 Message-ID: <500080F7.2050000@redhat.com> Date: Fri, 13 Jul 2012 22:11:35 +0200 From: Laszlo Ersek MIME-Version: 1.0 References: <1339575768-2557-1-git-send-email-lersek@redhat.com> <1339575768-2557-2-git-send-email-lersek@redhat.com> <20120713133852.3a446672@doriath.home> <50005B3D.2070009@redhat.com> <500072D3.2060901@redhat.com> In-Reply-To: <500072D3.2060901@redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v2 01/17] qapi: fix error propagation List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: qemu-devel@nongnu.org, Luiz Capitulino On 07/13/12 21:11, Paolo Bonzini wrote: > Il 13/07/2012 19:30, Laszlo Ersek ha scritto: >>>>>> - if (errp == NULL) { >>>>>> + if (errp == NULL || *errp != NULL) { >>>> >>>> I think we should use assert() here. >>>> >>>> If the error is already set, that most probably indicates a bug in the caller, as >>>> it's the caller's responsibility to decide which error to return. >> I believe we had a good argument against this, but I can't precisely >> recall (or find) it now. Paolo, do you remember? Can you please both >> search your respective mailboxen for Message-ID >> <4FB21B71.7030804@redhat.com>? That's where we started to discuss this. >> >> I believe I saw some paths in the code that tripped on this leak, and >> generally keeping the first error seemed like a good idea. >> opts_end_struct() originally checked for any pre-existent error >> explicitly, but then the check was moved to the common code. > > The reason to do this for error_propagate was to allow this idiom: > > /* Always call end_struct if start_struct succeeded. */ > error_propagate(errp, err); > err = NULL; > visit_end_struct(v, &err); > error_propagate(errp, err); Right! > I think doing it for error_set was just for symmetry and to avoid > introducing excessive complexity. Correct again. IIRC it was even yours truly who humbly suggested that. Thanks! Laszlo