xfs
[Top] [All Lists]

[PATCH 4/6] ubifs: simplify drop_last_node() via list_last_entry_or_null

To: linux-kernel@xxxxxxxxxxxxxxx
Subject: [PATCH 4/6] ubifs: simplify drop_last_node() via list_last_entry_or_null()
From: Jeff Liu <jeff.liu@xxxxxxxxxx>
Date: Fri, 15 Nov 2013 12:33:56 +0800
Cc: akpm@xxxxxxxxxxxxxxxxxxxx, "xfs@xxxxxxxxxxx" <xfs@xxxxxxxxxxx>, cluster-devel@xxxxxxxxxx, linux-mtd@xxxxxxxxxxxxxxxxxxx, jfs-discussion@xxxxxxxxxxxxxxxxxxxxx, oleg@xxxxxxxxxx, jiri@xxxxxxxxxxx, gregkh@xxxxxxxxxxxxxxxxxxx
Delivered-to: xfs@xxxxxxxxxxx
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.0
From: Jie Liu <jeff.liu@xxxxxxxxxx>

Simplify the code in drop_last_node() via list_last_entry_or_null().

Signed-off-by: Jie Liu <jeff.liu@xxxxxxxxxx>
---
 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;
-- 
1.8.3.2

<Prev in Thread] Current Thread [Next in Thread>
  • [PATCH 4/6] ubifs: simplify drop_last_node() via list_last_entry_or_null(), Jeff Liu <=