From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41746) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vm1EF-0003hp-CI for qemu-devel@nongnu.org; Thu, 28 Nov 2013 08:02:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vm1E9-0003g9-CZ for qemu-devel@nongnu.org; Thu, 28 Nov 2013 08:01:59 -0500 Received: from mx1.redhat.com ([209.132.183.28]:25058) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vm1E9-0003g5-3z for qemu-devel@nongnu.org; Thu, 28 Nov 2013 08:01:53 -0500 Date: Thu, 28 Nov 2013 14:01:45 +0100 From: Igor Mammedov Message-ID: <20131128140145.0fcc8b43@nial.usersys.redhat.com> In-Reply-To: <5296CD6A.1060008@redhat.com> References: <1385601858-8065-1-git-send-email-imammedo@redhat.com> <5296CD6A.1060008@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] qom: abort on error in property setter if caller passed errp == NULL List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: peter.crosthwaite@xilinx.com, mst@redhat.com, qemu-devel@nongnu.org, anthony@codemonkey.ws, pbonzini@redhat.com, afaerber@suse.de On Wed, 27 Nov 2013 21:58:18 -0700 Eric Blake wrote: > On 11/27/2013 06:24 PM, Igor Mammedov wrote: > > in case if caller setting property doesn't care about error and > > passes in NULL as errp argument but error occurs in property setter, > > it is silently discarded leaving object in undefined state. > > > > As result it leads to hard to find bugs, so if caller doesn't > > care about error it must be sure that property exists and > > accepts provided value, otherwise it's better to abort early > > since error case couldn't be handled gracefully and find > > invalid usecase early. > > > > In addition multitude of property setters will be always > > guarantied to have error object present and won't be required > > s/guarantied/guaranteed/ thanks, I'll fix it. > > > to handle this condition individually. > > > > Signed-off-by: Igor Mammedov > > --- > > > +out: > > + if (local_error) { > > This says local_error was set... > > > + if (!errp) { > > + assert_no_error(local_error); > > so this assert_no_error() is dead code in its current position. To be > useful, you probably want: it is not, retested it again and it still fails when errp == NULL but there is a error in local_error. > > if (!errp) { > assert_no_error(local_error); > } else if (local_error) { > error_propagate(errp, local_error); > } this's just another way to do the same thing.