Skip to contentSkip to conversation

jbd: Remove redundant NULL check upon kfree()

PATCH In review Davidlohr Bueso 2 participants 3 messages Aug 11, 2010 VFS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 jbd: Remove redundant NULL check upon kfree()

jbd: Remove redundant NULL check upon kfree().

---
 fs/jbd/transaction.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
fs/jbd/transaction.c +1 -2
index 5ae71e7..5e98130 100644
@@ -232,8 +232,7 @@ repeat_locked:
 
 	lock_map_acquire(&handle->h_lockdep_map);
 out:
-	if (unlikely(new_transaction))		/* It's usually NULL */
-		kfree(new_transaction);
+	kfree(new_transaction);
 	return ret;
 }
 
Signature · 1 line
1.7.0.4
#1 lore raw
Quoted 12 lines · Davidlohr Bueso

jbd: Remove redundant NULL check upon kfree().

---
 fs/jbd/transaction.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
fs/jbd/transaction.c +0 -0
index 5ae71e7..5e98130 100644

fs/jbd/transaction.c repeat_locked: · line 235

Quoted 6 lines
fs/jbd/transaction.c +1 -2
@@ -232,8 +232,7 @@ repeat_locked:
 
 	lock_map_acquire(&handle->h_lockdep_map);
 out:
-	if (unlikely(new_transaction))		/* It's usually NULL */
-		kfree(new_transaction);
+	kfree(new_transaction);

This doesn't seem entirely redundant, as it is optimized (via the unlikely() hint) for the opposite case than what kfree() is optimized for (kfree() assumes that the pointer is likely non-NULL, while the code above assumes that the pointer si likely NULL).

Signature · 2 lines
Jiri Kosina
SUSE Labs, Novell Inc.
#2 lore raw
Quoted 15 lines · Jiri Kosina
Quoted 13 lines · Davidlohr Bueso

jbd: Remove redundant NULL check upon kfree().

---
 fs/jbd/transaction.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
fs/jbd/transaction.c +0 -0
index 5ae71e7..5e98130 100644
@@ -232,8 +232,7 @@ repeat_locked:
 
Quoted 11 lines

fs/jbd/transaction.c repeat_locked: · line 235

Quoted 5 lines
fs/jbd/transaction.c +1 -2
 	lock_map_acquire(&handle->h_lockdep_map);
 out:
-	if (unlikely(new_transaction))		/* It's usually NULL */
-		kfree(new_transaction);
+	kfree(new_transaction);

This doesn't seem entirely redundant, as it is optimized (via the unlikely() hint) for the opposite case than what kfree() is optimized for (kfree() assumes that the pointer is likely non-NULL, while the code above assumes that the pointer si likely NULL).

Ok, makes sense. I was a bit doubtful about the unlikely(), thanks for the review.

Davidlohr