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

Donglin Peng posted 1 patch 1 month, 4 weeks ago
fs/ext4/file.c | 1 -
1 file changed, 1 deletion(-)
[PATCH] fs/ext4: Remove unnecessary zero-initialization via memset
Posted by Donglin Peng 1 month, 4 weeks ago
From: pengdonglin <pengdonglin@xiaomi.com>

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

Signed-off-by: pengdonglin <pengdonglin@xiaomi.com>
---
 fs/ext4/file.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/fs/ext4/file.c b/fs/ext4/file.c
index 7a8b30932189..484cb7388802 100644
--- a/fs/ext4/file.c
+++ b/fs/ext4/file.c
@@ -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));
-- 
2.34.1
Re: [PATCH] fs/ext4: Remove unnecessary zero-initialization via memset
Posted by Theodore Ts'o 1 week, 3 days ago
On Thu, 11 Dec 2025 20:38:29 +0800, Donglin Peng wrote:
> 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,
-- 
Theodore Ts'o <tytso@mit.edu>
Re: [PATCH] fs/ext4: Remove unnecessary zero-initialization via memset
Posted by Zhang Yi 1 month, 3 weeks ago
On 12/11/2025 8:38 PM, Donglin Peng wrote:
> From: pengdonglin <pengdonglin@xiaomi.com>
> 
> The d_path function does not require the caller to pre-zero the
> buffer.
> 
> Signed-off-by: pengdonglin <pengdonglin@xiaomi.com>

This should just be a cleanup.

Reviewed-by: Zhang Yi <yi.zhang@huawei.com>

> ---
>  fs/ext4/file.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/fs/ext4/file.c b/fs/ext4/file.c
> index 7a8b30932189..484cb7388802 100644
> --- a/fs/ext4/file.c
> +++ b/fs/ext4/file.c
> @@ -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));
Re: [PATCH] fs/ext4: Remove unnecessary zero-initialization via memset
Posted by Baokun Li 1 month, 3 weeks ago
On 2025-12-11 20:38, Donglin Peng wrote:
> From: pengdonglin <pengdonglin@xiaomi.com>
>
> The d_path function does not require the caller to pre-zero the
> buffer.
>
> Signed-off-by: pengdonglin <pengdonglin@xiaomi.com>

Looks good. Feel free to add:

Reviewed-by: Baokun Li <libaokun1@huawei.com>

> ---
>  fs/ext4/file.c | 1 -
>  1 file changed, 1 deletion(-)
>
> diff --git a/fs/ext4/file.c b/fs/ext4/file.c
> index 7a8b30932189..484cb7388802 100644
> --- a/fs/ext4/file.c
> +++ b/fs/ext4/file.c
> @@ -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));