* [PATCH] llist: Use for() initializer and conditional
@ 2015-10-29 19:19 Pranith Kumar
0 siblings, 0 replies; only message in thread
From: Pranith Kumar @ 2015-10-29 19:19 UTC (permalink / raw)
To: Andrew Morton, Rasmus Villemoes, Dmitry Vyukov, open list
Simplify the code a bit by using the initializer and conditional
check in for() instead of a separate if() statement in the loop.
Signed-off-by: Pranith Kumar <bobby.prani@gmail.com>
---
lib/llist.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/lib/llist.c b/lib/llist.c
index ae5872b..ddbeebb 100644
--- a/lib/llist.c
+++ b/lib/llist.c
@@ -66,10 +66,7 @@ struct llist_node *llist_del_first(struct llist_head *head)
{
struct llist_node *entry, *old_entry, *next;
- entry = smp_load_acquire(&head->first);
- for (;;) {
- if (entry == NULL)
- return NULL;
+ for (entry = smp_load_acquire(&head->first); entry ; ) {
old_entry = entry;
next = READ_ONCE(entry->next);
entry = cmpxchg(&head->first, old_entry, next);
--
2.6.1
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2015-10-29 19:18 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-29 19:19 [PATCH] llist: Use for() initializer and conditional Pranith Kumar
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®