Skip to contentSkip to conversation

btrfs: remove redundant inode null check

PATCH In review Colin King 2 participants 2 messages Dec 20, 2016 Btrfs file system

lore
Share & tools
lore

Colin King

author
#0 lore raw

PATCH v2 1/1 btrfs: remove redundant inode null check

From: Colin Ian King <[email protected]>

The check for a null inode is redundant since the function is a callback for exportfs, which will itself crash if dentry->d_inode or parent->d_inode is NULL. Removing the null check makes this consistent with other file systems.

Also remove the redundant null dir check too.

Found with static analysis by CoverityScan, CID 1389472

Kudos to Jeff Mahoney for reviewing and explaining the error in my original patch (most of this explanation went into the above commit message) and David Sterba for pointing out that the dir check is also redundant.

---
 fs/btrfs/export.c | 3 ---
 1 file changed, 3 deletions(-)
fs/btrfs/export.c +0 -3
index 340d907..4f77431 100644
@@ -235,9 +235,6 @@ static int btrfs_get_name(struct dentry *parent, char *name,
 	int ret;
 	u64 ino;
 
-	if (!dir || !inode)
-		return -EINVAL;
-
 	if (!S_ISDIR(dir->i_mode))
 		return -EINVAL;
 
Signature · 1 line
2.10.2
Reviewed-by on v2 1/1
#1 lore raw
Quoted 9 lines · Colin King

From: Colin Ian King <[email protected]>

The check for a null inode is redundant since the function is a callback for exportfs, which will itself crash if dentry->d_inode or parent->d_inode is NULL. Removing the null check makes this consistent with other file systems.

Also remove the redundant null dir check too.

Quoted 8 lines

Found with static analysis by CoverityScan, CID 1389472

Kudos to Jeff Mahoney for reviewing and explaining the error in my original patch (most of this explanation went into the above commit message) and David Sterba for pointing out that the dir check is also redundant.

Added to cleanups queue, thanks.