Skip to contentSkip to conversation

ext4: extents: Remove unnecessary ‘NULL’ values from path

PATCH In review Li zeming 2 participants 2 messages Apr 2, 2024 ext4 file system

lore
Share & tools
lore

Li zeming

author
#0 lore raw

PATCH 1/1 ext4: extents: Remove unnecessary ‘NULL’ values from path

path is assigned first, so it does not need to initialize the assignment.

---
 fs/ext4/extents.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ext4/extents.c +1 -1
index 7669d154c05e0..4ab96f01a6f31 100644
@@ -600,7 +600,7 @@ __read_extent_tree_block(const char *function, unsigned int line,
 int ext4_ext_precache(struct inode *inode)
 {
 	struct ext4_inode_info *ei = EXT4_I(inode);
-	struct ext4_ext_path *path = NULL;
+	struct ext4_ext_path *path;
 	struct buffer_head *bh;
 	int i = 0, depth, ret = 0;
 
Signature · 1 line
2.18.2
maintainer
#1 lore raw
Quoted 2 lines · Li zeming

path is assigned first, so it does not need to initialize the assignment.

That's technically true, but the compiler is perfectly capable of optimizing it out. So it's harmless, and removing it does make the code a bit more fragile, since it needs to be set so that the cleanup code doesn't accidentally dereference an uninitialized pointer:

out:

	up_read(&ei->i_data_sem);
	ext4_free_ext_path(path);
	return ret;

So if later on, we add code which does a "goto out" on an error, before path gets initialized, that would be bad. So removing the "unnecessary" set has no upside, and it has a potential disadvantage.

- Ted