Skip to contentSkip to conversation

jbd: start_this_handle(): remove kfree() redundant null check

PATCH In review Tim Gardner 2 participants 2 messages Feb 12, 2013 – Feb 14, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 jbd: start_this_handle(): remove kfree() redundant null check

smatch analysis:

fs/jbd/transaction.c:236 start_this_handle() info: redundant null
check on new_transaction calling kfree()

---
 fs/jbd/transaction.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
fs/jbd/transaction.c +1 -2
index 071d690..ee40b4e 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.9.5
#1 lore raw
Quoted 18 lines · Tim Gardner

smatch analysis:

fs/jbd/transaction.c:236 start_this_handle() info: redundant null
check on new_transaction calling kfree()

---
 fs/jbd/transaction.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
fs/jbd/transaction.c +0 -0
index 071d690..ee40b4e 100644

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

Quoted 7 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);
 	return ret;

Thanks for the patch but I actually think this is deliberate because
new_transaction is usually NULL while kfree() is optimized for passed pointer to be usually != NULL. Also we save a function call in the common case. So I'm for the code to stay as is.

Honza

Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR