From: Geliang Tang <geliangtang@gmail.com>
To: Miklos Szeredi <miklos@szeredi.hu>
Cc: Geliang Tang <geliangtang@gmail.com>,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 1/2] fuse: use list_first_entry_or_null
Date: Wed, 8 Jun 2016 18:48:01 +0800 [thread overview]
Message-ID: <dc8eb439b88e8eacd8cfceaf63eee2a0f558829a.1465382702.git.geliangtang@gmail.com> (raw)
Use list_first_entry_or_null() instead of list_empty() and list_entry()
to simplify the code.
Signed-off-by: Geliang Tang <geliangtang@gmail.com>
---
fs/fuse/dev.c | 7 +++----
fs/fuse/file.c | 9 ++++-----
2 files changed, 7 insertions(+), 9 deletions(-)
diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index cbece12..1432cf7 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -1259,11 +1259,10 @@ static ssize_t fuse_dev_do_read(struct fuse_dev *fud, struct file *file,
if (!fiq->connected)
goto err_unlock;
- if (!list_empty(&fiq->interrupts)) {
- req = list_entry(fiq->interrupts.next, struct fuse_req,
- intr_entry);
+ req = list_first_entry_or_null(&fiq->interrupts, struct fuse_req,
+ intr_entry);
+ if (req)
return fuse_read_interrupt(fiq, cs, nbytes, req);
- }
if (forget_pending(fiq)) {
if (list_empty(&fiq->pending) || fiq->forget_batch-- > 0)
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index 9154f86..c1d97a1 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -1565,14 +1565,13 @@ static void fuse_writepage_end(struct fuse_conn *fc, struct fuse_req *req)
static struct fuse_file *__fuse_write_file_get(struct fuse_conn *fc,
struct fuse_inode *fi)
{
- struct fuse_file *ff = NULL;
+ struct fuse_file *ff;
spin_lock(&fc->lock);
- if (!list_empty(&fi->write_files)) {
- ff = list_entry(fi->write_files.next, struct fuse_file,
- write_entry);
+ ff = list_first_entry_or_null(&fi->write_files, struct fuse_file,
+ write_entry);
+ if (ff)
fuse_file_get(ff);
- }
spin_unlock(&fc->lock);
return ff;
--
1.9.1
next reply other threads:[~2016-06-08 10:48 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-08 10:48 Geliang Tang [this message]
2016-06-08 10:48 ` [PATCH 2/2] fuse: use list_first_entry Geliang Tang
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=dc8eb439b88e8eacd8cfceaf63eee2a0f558829a.1465382702.git.geliangtang@gmail.com \
--to=geliangtang@gmail.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=miklos@szeredi.hu \
/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
all inboxes | Powered by JetHome®