qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] block: mirror - insure that errp is not NULL


From: Stefan Hajnoczi
Subject: Re: [Qemu-devel] [PATCH] block: mirror - insure that errp is not NULL
Date: Fri, 14 Feb 2014 16:14:49 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

On Thu, Feb 13, 2014 at 09:41:45AM +0100, Kevin Wolf wrote:
> Am 12.02.2014 um 20:46 hat Jeff Cody geschrieben:
> > When starting a block job, commit_active_start() relies on whether *errp
> > is set by mirror_start_job.  This allows it to determine if the mirror
> > job start failed, so that it can clean up any changes to open flags from
> > the bdrv_reopen().  If errp is NULL, then it will not be able to
> > determine if mirror_start_job failed or not.
> > 
> > Reported-by: Markus Armbruster <address@hidden>
> > Signed-off-by: Jeff Cody <address@hidden>
> > ---
> >  block/mirror.c | 2 ++
> >  1 file changed, 2 insertions(+)
> > 
> > diff --git a/block/mirror.c b/block/mirror.c
> > index 2a43334..41bb83c 100644
> > --- a/block/mirror.c
> > +++ b/block/mirror.c
> > @@ -634,6 +634,8 @@ void commit_active_start(BlockDriverState *bs, 
> > BlockDriverState *base,
> >      int64_t length, base_length;
> >      int orig_base_flags;
> >  
> > +    assert(errp != NULL);
> > +
> >      orig_base_flags = bdrv_get_flags(base);
> >  
> >      if (bdrv_reopen(base, bs->open_flags, errp)) {
> 
> This is surprising behaviour. Without looking at the function
> implementation, I expect that errp == NULL works and means the same as
> everywhere else: The caller doesn't care about errors.
> 
> I wouldn't mind if violators were detected at compile time, but this is
> merely a run-time error (and strictly speaking only an error at all
> without NDEBUG), so I would prefer to use the normal local_err pattern.

Agreed.  Please use local_err.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]