Skip to contentSkip to conversation

ubifs: simplify drop_last_node() via list_last_entry_or_null()

PATCH In review Jeff Liu 1 participant 1 message Nov 15, 2013

Subsystems (2)
lore
Share & tools
lore

Jeff Liu

author
#0 lore raw

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

From: Jie Liu <[email protected]>

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

---
 fs/ubifs/recovery.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
fs/ubifs/recovery.c +3 -5
index 065096e..e46c394 100644
@@ -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;
Signature · 1 line
1.8.3.2