lkml.org 
[lkml]   [2015]   [Nov]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] blk-throttle: use list_first_entry_or_null()
Date
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



\
 
 \ /
  Last update: 2015-11-18 14:21    [W:0.029 / U:0.788 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site