Skip to contentSkip to conversation

btrfs: remove redundant NULL check

PATCH In review Yang Li 3 participants 3 messages Jan 21, 2021 Btrfs file system

lore
Share & tools
lore

Yang Li

author
#0 lore raw

PATCH 1/1 btrfs: remove redundant NULL check

Fix below warnings reported by coccicheck:
./fs/btrfs/raid56.c:237:2-8: WARNING: NULL check before some freeing functions is not needed.

---
 fs/btrfs/raid56.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
fs/btrfs/raid56.c +1 -2
index 93fbf87..5394641 100644
@@ -233,8 +233,7 @@ int btrfs_alloc_stripe_hash_table(struct btrfs_fs_info *info)
 	}
 
 	x = cmpxchg(&info->stripe_hash_table, NULL, table);
-	if (x)
-		kvfree(x);
+	kvfree(x);
 	return 0;
 }
 
Signature · 1 line
1.8.3.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 15 lines · Yang Li

Fix below warnings reported by coccicheck:
./fs/btrfs/raid56.c:237:2-8: WARNING: NULL check before some freeing functions is not needed.

---
  fs/btrfs/raid56.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)
fs/btrfs/raid56.c +0 -0
index 93fbf87..5394641 100644

fs/btrfs/raid56.c int btrfs_alloc_stripe_hash_table(struct btrfs_fs_info *info) · line 236

Quoted 6 lines
fs/btrfs/raid56.c +1 -2
@@ -233,8 +233,7 @@ int btrfs_alloc_stripe_hash_table(struct btrfs_fs_info *info)
  	}
 
  	x = cmpxchg(&info->stripe_hash_table, NULL, table);
-	if (x)
-		kvfree(x);
+	kvfree(x);

Thanks, Anand

Quoted 4 lines
fs/btrfs/raid56.c +0 -0
  	return 0;
  }