public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ext4: extents: Remove unnecessary ‘NULL’ values from path
@ 2024-04-02  2:41 Li zeming
  2024-04-02  3:55 ` Theodore Ts'o
  0 siblings, 1 reply; 2+ messages in thread
From: Li zeming @ 2024-04-02  2:41 UTC (permalink / raw)
  To: tytso, adilger.kernel; +Cc: linux-ext4, linux-kernel, Li zeming

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

Signed-off-by: Li zeming <zeming@nfschina.com>
---
 fs/ext4/extents.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 7669d154c05e0..4ab96f01a6f31 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -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;
 
-- 
2.18.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ext4: extents: Remove unnecessary ‘NULL’ values from path
  2024-04-02  2:41 [PATCH] ext4: extents: Remove unnecessary ‘NULL’ values from path Li zeming
@ 2024-04-02  3:55 ` Theodore Ts'o
  0 siblings, 0 replies; 2+ messages in thread
From: Theodore Ts'o @ 2024-04-02  3:55 UTC (permalink / raw)
  To: Li zeming; +Cc: adilger.kernel, linux-ext4, linux-kernel

On Tue, Apr 02, 2024 at 10:41:40AM +0800, Li zeming wrote:
> 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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-04-02  3:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-02  2:41 [PATCH] ext4: extents: Remove unnecessary ‘NULL’ values from path Li zeming
2024-04-02  3:55 ` Theodore Ts'o

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox