Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1270235

[PATCH 1/2] crypto: api - use list_first_entry_or_null and list_next_entry

From Geliang Tang <geliangtang@163.com>
Newsgroups linux.kernel
Subject [PATCH 1/2] crypto: api - use list_first_entry_or_null and list_next_entry
Date 2015-11-16 15:40 +0100
Message-ID <qvt6O-8uH-31@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


Simplify crypto_more_spawns() with list_first_entry_or_null()
and list_next_entry().

Signed-off-by: Geliang Tang <geliangtang@163.com>
---
 crypto/algapi.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/crypto/algapi.c b/crypto/algapi.c
index 59bf491..7be76aa 100644
--- a/crypto/algapi.c
+++ b/crypto/algapi.c
@@ -93,16 +93,15 @@ static struct list_head *crypto_more_spawns(struct crypto_alg *alg,
 {
 	struct crypto_spawn *spawn, *n;
 
-	if (list_empty(stack))
+	spawn = list_first_entry_or_null(stack, struct crypto_spawn, list);
+	if (!spawn)
 		return NULL;
 
-	spawn = list_first_entry(stack, struct crypto_spawn, list);
-	n = list_entry(spawn->list.next, struct crypto_spawn, list);
+	n = list_next_entry(spawn, list);
 
 	if (spawn->alg && &n->list != stack && !n->alg)
 		n->alg = (n->list.next == stack) ? alg :
-			 &list_entry(n->list.next, struct crypto_spawn,
-				     list)->inst->alg;
+			 &list_next_entry(n, list)->inst->alg;
 
 	list_move(&spawn->list, secondary_spawns);
 
-- 
2.5.0


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

Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

[PATCH 1/2] crypto: api - use list_first_entry_or_null and list_next_entry Geliang Tang <geliangtang@163.com> - 2015-11-16 15:40 +0100
  [PATCH 2/2] crypto: mcryptd - use list_first_entry_or_null() Geliang Tang <geliangtang@163.com> - 2015-11-16 15:40 +0100
    Re: [PATCH 2/2] crypto: mcryptd - use list_first_entry_or_null() Herbert Xu <herbert@gondor.apana.org.au> - 2015-11-23 14:10 +0100
  Re: [PATCH 1/2] crypto: api - use list_first_entry_or_null and  list_next_entry Herbert Xu <herbert@gondor.apana.org.au> - 2015-11-23 14:10 +0100

csiph-web