From: Jie Liu <[email protected]>

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

Signed-off-by: Jie Liu <[email protected]>
---
 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

------------------------------------------------------------------------------
DreamFactory - Open Source REST & JSON Services for HTML5 & Native Apps
OAuth, Users, Roles, SQL, NoSQL, BLOB Storage and External API Access
Free app hosting. Or install the open source package on any LAMP server.
Sign up and see examples for AngularJS, jQuery, Sencha Touch and Native!
http://pubads.g.doubleclick.net/gampad/clk?id=63469471&iu=/4140/ostg.clktrk
_______________________________________________
Jfs-discussion mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jfs-discussion

Reply via email to