Skip to contentSkip to conversation

fs/ext4: Remove unnecessary zero-initialization via memset

PATCH Applied Donglin Peng 4 participants 4 messages Dec 11, 2025 – Jan 28 ext4 file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fs/ext4: Remove unnecessary zero-initialization via memset

From: pengdonglin <[email protected]>

The d_path function does not require the caller to pre-zero the buffer.

---
 fs/ext4/file.c | 1 -
 1 file changed, 1 deletion(-)
fs/ext4/file.c +0 -1
index 7a8b30932189..484cb7388802 100644
@@ -858,7 +858,6 @@ static int ext4_sample_last_mounted(struct super_block *sb,
 	 * when trying to sort through large numbers of block
 	 * devices or filesystem images.
 	 */
-	memset(buf, 0, sizeof(buf));
 	path.mnt = mnt;
 	path.dentry = mnt->mnt_root;
 	cp = d_path(&path, buf, sizeof(buf));
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Donglin Peng

From: pengdonglin <[email protected]>

The d_path function does not require the caller to pre-zero the buffer.

Looks good. Feel free to add:

Quoted 16 lines
---
 fs/ext4/file.c | 1 -
 1 file changed, 1 deletion(-)
fs/ext4/file.c +0 -1
index 7a8b30932189..484cb7388802 100644
@@ -858,7 +858,6 @@ static int ext4_sample_last_mounted(struct super_block *sb,
 	 * when trying to sort through large numbers of block
 	 * devices or filesystem images.
 	 */
-	memset(buf, 0, sizeof(buf));
 	path.mnt = mnt;
 	path.dentry = mnt->mnt_root;
 	cp = d_path(&path, buf, sizeof(buf));
Reviewed-by on v1 1/1
#2 lore raw
In reply to Donglin Peng
Quoted 6 lines · Donglin Peng

From: pengdonglin <[email protected]>

The d_path function does not require the caller to pre-zero the buffer.

This should just be a cleanup.

Quoted 16 lines
---
 fs/ext4/file.c | 1 -
 1 file changed, 1 deletion(-)
fs/ext4/file.c +0 -1
index 7a8b30932189..484cb7388802 100644
@@ -858,7 +858,6 @@ static int ext4_sample_last_mounted(struct super_block *sb,
 	 * when trying to sort through large numbers of block
 	 * devices or filesystem images.
 	 */
-	memset(buf, 0, sizeof(buf));
 	path.mnt = mnt;
 	path.dentry = mnt->mnt_root;
 	cp = d_path(&path, buf, sizeof(buf));
maintainer Applied
#3 lore raw
In reply to Donglin Peng
Quoted 4 lines · Donglin Peng

The d_path function does not require the caller to pre-zero the buffer.

Applied, thanks!

[1/1] fs/ext4: Remove unnecessary zero-initialization via memset

      commit: 26f260ce5828fc7897a70629884916301f5825d0

Best regards,

Signature · 1 line
Theodore Ts'o <[email protected]>