On Mon, Mar 08, 2010 at 11:50:23AM +0530, Amit Shah wrote:
> On (Sat) Mar 06 2010 [21:06:35], Michael S. Tsirkin wrote:
> > 
> > > > +    r = vhost_virtqueue_set_addr(dev, vq, idx, dev->log_enabled);
> > > > +    if (r < 0) {
> > > > +        r = -errno;
> > > > +        goto fail_alloc;
> > > > +    }
> > > > +    if (!vdev->binding->guest_notifier || 
> > > > !vdev->binding->host_notifier) {
> > > > +        fprintf(stderr, "binding does not support irqfd/queuefd\n");
> > > > +        r = -ENOSYS;
> > > > +        goto fail_alloc;
> > > > +    }
> > > 
> > > This could be checked much earlier on in the function; so that we avoid
> > > doing all that stuff above and the cleanup.
> > 
> > Whatever order we put checks in, we'll have to undo stuff
> > done beforehand on error.
> 
> Not if you do this check before any ioctls or allocations.
> !vdev->binding->guest_notifier is not dependent on anything you do above
> it in this function, so just checking for this first thing in the
> function will not need any cleanup.
> 
> 
>               Amit

Yes, but I think it's clearer to do check function just before
calling it. No?



Reply via email to