From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757375AbbJ2TSi (ORCPT ); Thu, 29 Oct 2015 15:18:38 -0400 Received: from mail-yk0-f181.google.com ([209.85.160.181]:36469 "EHLO mail-yk0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757294AbbJ2TSh (ORCPT ); Thu, 29 Oct 2015 15:18:37 -0400 From: Pranith Kumar To: Andrew Morton , Rasmus Villemoes , Dmitry Vyukov , linux-kernel@vger.kernel.org (open list) Subject: [PATCH] llist: Use for() initializer and conditional Date: Thu, 29 Oct 2015 15:19:29 -0400 Message-Id: <1446146370-19111-1-git-send-email-bobby.prani@gmail.com> X-Mailer: git-send-email 2.6.1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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