From: Al Viro <viro@ZenIV.linux.org.uk>
To: Alex Williamson <alex.williamson@redhat.com>
Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org
Subject: Re: [PATCH] vfio-pci: Use fdget() rather than eventfd_fget()
Date: Tue, 20 Aug 2013 22:18:14 +0100 [thread overview]
Message-ID: <20130820211814.GM27005@ZenIV.linux.org.uk> (raw)
In-Reply-To: <20130820191712.9006.4890.stgit@bling.home>
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"...
prev parent reply other threads:[~2013-08-20 21:18 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-20 19:18 Alex Williamson
2013-08-20 21:18 ` Al Viro [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130820211814.GM27005@ZenIV.linux.org.uk \
--to=viro@zeniv.linux.org.uk \
--cc=alex.williamson@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome