On Tue, Aug 20, 2013 at 01:18:07PM -0600, Alex Williamson wrote:
> eventfd_fget() tests to see whether the file is an eventfd file, which
> we then immediately pass to eventfd_ctx_fileget(), which again tests
> whether the file is an eventfd file.  Simplify slightly by using
> fdget() so that we only test that we're looking at an eventfd once.
> fget() could also be used, but fdget() makes use of fget_light() for
> another slight optimization.

Umm...

> @@ -210,8 +210,8 @@ fail:
>       if (ctx && !IS_ERR(ctx))
>               eventfd_ctx_put(ctx);
>  
> -     if (file && !IS_ERR(file))
> -             fput(file);
> +     if (irqfd.file)
> +             fdput(irqfd);
>  
>       kfree(virqfd);

IMO it's a bad style; you have three failure exits leading here, and those
ifs are nothing but "how far did we get before we'd failed".

fail3:
        eventfd_ctx_put(ctx);
fail2:
        fdput(irqfd);
fail1:
        kfree(virqfd);

is much easier to analyse.  It's a very common pattern and IME it's more
robust than this kind of "flexibility"...
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to