All of lore.kernel.org
 help / color / mirror / Atom feed
From: Geliang Tang <geliangtang@163.com>
To: Jens Axboe <axboe@kernel.dk>
Cc: Geliang Tang <geliangtang@163.com>,
	linux-block@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] blk-throttle: use list_first_entry_or_null()
Date: Wed, 18 Nov 2015 21:07:31 +0800	[thread overview]
Message-ID: <8e96d9ad3e820a9ac346c0d2924507e9d34465b1.1447851969.git.geliangtang@163.com> (raw)

Simplify the code with list_first_entry_or_null().

Signed-off-by: Geliang Tang <geliangtang@163.com>
---
 block/blk-throttle.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/block/blk-throttle.c b/block/blk-throttle.c
index 2149a1d..db2dbf1 100644
--- a/block/blk-throttle.c
+++ b/block/blk-throttle.c
@@ -263,10 +263,11 @@ static void throtl_qnode_add_bio(struct bio *bio, struct throtl_qnode *qn,
  */
 static struct bio *throtl_peek_queued(struct list_head *queued)
 {
-	struct throtl_qnode *qn = list_first_entry(queued, struct throtl_qnode, node);
+	struct throtl_qnode *qn;
 	struct bio *bio;
 
-	if (list_empty(queued))
+	qn = list_first_entry_or_null(queued, struct throtl_qnode, node);
+	if (!qn)
 		return NULL;
 
 	bio = bio_list_peek(&qn->bios);
@@ -291,10 +292,11 @@ static struct bio *throtl_peek_queued(struct list_head *queued)
 static struct bio *throtl_pop_queued(struct list_head *queued,
 				     struct throtl_grp **tg_to_put)
 {
-	struct throtl_qnode *qn = list_first_entry(queued, struct throtl_qnode, node);
+	struct throtl_qnode *qn;
 	struct bio *bio;
 
-	if (list_empty(queued))
+	qn = list_first_entry_or_null(queued, struct throtl_qnode, node);
+	if (!qn)
 		return NULL;
 
 	bio = bio_list_pop(&qn->bios);
-- 
2.5.0



                 reply	other threads:[~2015-11-18 13:08 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=8e96d9ad3e820a9ac346c0d2924507e9d34465b1.1447851969.git.geliangtang@163.com \
    --to=geliangtang@163.com \
    --cc=axboe@kernel.dk \
    --cc=linux-block@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.