Received: from eggs.gnu.org ([208.118.235.92]:48307) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UDGl0-0001zt-Al for qemu-devel@nongnu.org; Wed, 06 Mar 2013 10:59:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UDGkx-0003Ff-PV for qemu-devel@nongnu.org; Wed, 06 Mar 2013 10:59:54 -0500 Received: from mx1.redhat.com ([209.132.183.28]:11018) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UDGkx-0003Eg-AC for qemu-devel@nongnu.org; Wed, 06 Mar 2013 10:59:51 -0500 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 r26FxomD031163 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 6 Mar 2013 10:59:50 -0500 From: Markus Armbruster References: <1362566886-14073-1-git-send-email-kwolf@redhat.com> <513722BD.6010503@redhat.com> <20130306111126.GA2285@dhcp-200-207.str.redhat.com> <513756D5.1020506@redhat.com> <51375B04.9020402@redhat.com> <20130306151905.GB2285@dhcp-200-207.str.redhat.com> Date: Wed, 06 Mar 2013 16:59:48 +0100 In-Reply-To: <20130306151905.GB2285@dhcp-200-207.str.redhat.com> (Kevin Wolf's message of "Wed, 6 Mar 2013 16:19:05 +0100") Message-ID: <87a9qg5xjf.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH] qemu-sockets: Fix assertion failure List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: Paolo Bonzini , Laszlo Ersek , qemu-devel@nongnu.org, Luiz Capitulino Kevin Wolf writes: > Am 06.03.2013 um 16:04 hat Paolo Bonzini geschrieben: >> Il 06/03/2013 15:46, Laszlo Ersek ha scritto: >> >> > We could assert(!error_is_set(errp)) if we wanted. As soon as you've got >> >> > an Error, you must return instead of calling more functions with the >> >> > same error pointer. >> > I think Luiz would suggest (*) to receive any error into a >> > NULL-initialized local_err pointer; do the logic above on local_err, and >> > just before returning, error_propagate() it to errp. >> > >> > (*) I hope you can see what I did there: if you disagree, you get to >> > take that to Luiz, even though he didn't say anything. I'm getting >> > better at working this list! :) >> >> I agree with Laszlo. > > I don't really understand the difference. As long as the function > doesn't depend on the Error object to be present (which it doesn't), > isn't it semantically exactly the same? I guess it is in this case (I didn't call your patch wrong). However, I figure that as soon as we go beyond utterly trivial with errors, it's advisable to put them in local variables, and error_propagate() to the parameter only at the end. Messing around with errp parameters directly feels error-prone, and I'm afraid even correct messing could easily lead to incorrect messing, when folks imitate it without really understanding what they're doing. Yes, extra local variables make the error propagation code even bulkier. No, I don't like it any more than you do. > Also, Markus' reply makes me think that I should restrict myself to code > areas where errors are reported as -errno. That one I understand at > least... I wish I could, but I stepped into the error swamp long ago, and the muck is still sticking to my heels. Whenever a simple error reporting mechanism such as non-null/null or non-negative/-errno suffices, I very much recommend to use it.