From patchwork Fri Nov 15 04:33:56 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "jeff.liu" X-Patchwork-Id: 291452 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from casper.infradead.org (unknown [IPv6:2001:770:15f::2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 74DCF2C00CA for ; Fri, 15 Nov 2013 15:34:34 +1100 (EST) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VhB6z-0001is-Ff; Fri, 15 Nov 2013 04:34:29 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VhB6x-00054z-Sn; Fri, 15 Nov 2013 04:34:27 +0000 Received: from aserp1040.oracle.com ([141.146.126.69]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VhB6v-00053t-Q0 for linux-mtd@lists.infradead.org; Fri, 15 Nov 2013 04:34:26 +0000 Received: from acsinet22.oracle.com (acsinet22.oracle.com [141.146.126.238]) by aserp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id rAF4Y3aP013862 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 15 Nov 2013 04:34:03 GMT Received: from userz7021.oracle.com (userz7021.oracle.com [156.151.31.85]) by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id rAF4Y2NS013192 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 15 Nov 2013 04:34:03 GMT Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by userz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id rAF4Y1EA004107; Fri, 15 Nov 2013 04:34:01 GMT Received: from [192.168.1.103] (/123.119.103.122) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 14 Nov 2013 20:34:01 -0800 Message-ID: <5285A434.2080608@oracle.com> Date: Fri, 15 Nov 2013 12:33:56 +0800 From: Jeff Liu User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.0 MIME-Version: 1.0 To: linux-kernel@vger.kernel.org Subject: [PATCH 4/6] ubifs: simplify drop_last_node() via list_last_entry_or_null() X-Source-IP: acsinet22.oracle.com [141.146.126.238] X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131114_233425_937252_92D5F2B9 X-CRM114-Status: GOOD ( 10.90 ) X-Spam-Score: -4.2 (----) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-4.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [141.146.126.69 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: jfs-discussion@lists.sourceforge.net, jiri@resnulli.us, gregkh@linuxfoundation.org, oleg@redhat.com, "xfs@oss.sgi.com" , cluster-devel@redhat.com, linux-mtd@lists.infradead.org, akpm@linux-foundation.org X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Jie Liu Simplify the code in drop_last_node() via list_last_entry_or_null(). Signed-off-by: Jie Liu --- fs/ubifs/recovery.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/fs/ubifs/recovery.c b/fs/ubifs/recovery.c index 065096e..e46c394 100644 --- a/fs/ubifs/recovery.c +++ b/fs/ubifs/recovery.c @@ -603,12 +603,10 @@ static void drop_last_group(struct ubifs_scan_leb *sleb, int *offs) */ static void drop_last_node(struct ubifs_scan_leb *sleb, int *offs) { - struct ubifs_scan_node *snod; - - if (!list_empty(&sleb->nodes)) { - snod = list_entry(sleb->nodes.prev, struct ubifs_scan_node, - list); + struct ubifs_scan_node *snod = list_last_entry_or_null(&sleb->nodes, + struct ubifs_scan_node, list); + if (snod) { dbg_rcvry("dropping last node at %d:%d", sleb->lnum, snod->offs); *offs = snod->offs;