[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] qom: abort on error in property setter if calle
From: |
Igor Mammedov |
Subject: |
Re: [Qemu-devel] [PATCH] qom: abort on error in property setter if caller passed errp == NULL |
Date: |
Thu, 28 Nov 2013 14:01:45 +0100 |
On Wed, 27 Nov 2013 21:58:18 -0700
Eric Blake <address@hidden> 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 <address@hidden>
> > ---
>
> > +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.
Re: [Qemu-devel] [PATCH] qom: abort on error in property setter if caller passed errp == NULL, Andreas Färber, 2013/11/28