Skip to contentSkip to conversation

llist: Use for conditional in llist_del_first()

PATCH New Pranith Kumar 1 participant 1 message Oct 29, 2015 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 llist: Use for conditional in llist_del_first()

Simplify the code a bit by using the initializer and conditional check in for() instead of a separate if() statement in the loop.

---
 lib/llist.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
lib/llist.c +1 -4
index 0b0e977..03d7aad 100644
@@ -66,10 +66,7 @@ struct llist_node *llist_del_first(struct llist_head *head)
 {
 	struct llist_node *entry, *old_entry, *next;
 
-	entry = head->first;
-	for (;;) {
-		if (entry == NULL)
-			return NULL;
+	for (entry = head->first; entry ;) {
 		old_entry = entry;
 		next = entry->next;
 		entry = cmpxchg(&head->first, old_entry, next);
Signature · 1 line
2.6.2