lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:	Wed, 18 Nov 2015 21:07:31 +0800
From:	Geliang Tang <geliangtang@....com>
To:	Jens Axboe <axboe@...nel.dk>
Cc:	Geliang Tang <geliangtang@....com>, linux-block@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: [PATCH] blk-throttle: use list_first_entry_or_null()

Simplify the code with list_first_entry_or_null().

Signed-off-by: Geliang Tang <geliangtang@....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


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ