[PATCH v2] fs: exfat: improve error code handling in exfat_find_empty_entry()

Haotian Zhang posted 1 patch 2 weeks ago
fs/exfat/namei.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
[PATCH v2] fs: exfat: improve error code handling in exfat_find_empty_entry()
Posted by Haotian Zhang 2 weeks ago
Change the type of 'ret' from unsigned int to int in
exfat_find_empty_entry(). Although the implicit type conversion
(int -> unsigned int -> int) does not cause actual bugs in
practice, using int directly is more appropriate for storing
error codes returned by exfat_alloc_cluster().

This improves code clarity and consistency with standard error
handling practices.

Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn>
---
 fs/exfat/namei.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/exfat/namei.c b/fs/exfat/namei.c
index f5f1c4e8a29f..f2a87ecd79f9 100644
--- a/fs/exfat/namei.c
+++ b/fs/exfat/namei.c
@@ -304,8 +304,8 @@ static int exfat_find_empty_entry(struct inode *inode,
 		struct exfat_chain *p_dir, int num_entries,
 		struct exfat_entry_set_cache *es)
 {
-	int dentry;
-	unsigned int ret, last_clu;
+	int dentry, ret;
+	unsigned int last_clu;
 	loff_t size = 0;
 	struct exfat_chain clu;
 	struct super_block *sb = inode->i_sb;
-- 
2.50.1.windows.1
Re: [PATCH v2] fs: exfat: improve error code handling in exfat_find_empty_entry()
Posted by Namjae Jeon 1 week, 6 days ago
On Fri, Dec 5, 2025 at 10:59 AM Haotian Zhang <vulab@iscas.ac.cn> wrote:
>
> Change the type of 'ret' from unsigned int to int in
> exfat_find_empty_entry(). Although the implicit type conversion
> (int -> unsigned int -> int) does not cause actual bugs in
> practice, using int directly is more appropriate for storing
> error codes returned by exfat_alloc_cluster().
>
> This improves code clarity and consistency with standard error
> handling practices.
>
> Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn>
Applied it to #dev.
Thanks!
Re: [PATCH v2] fs: exfat: improve error code handling in exfat_find_empty_entry()
Posted by Sungjong Seo 2 weeks ago

On 25. 12. 5. 10:59, Haotian Zhang wrote:
> Change the type of 'ret' from unsigned int to int in
> exfat_find_empty_entry(). Although the implicit type conversion
> (int -> unsigned int -> int) does not cause actual bugs in
> practice, using int directly is more appropriate for storing
> error codes returned by exfat_alloc_cluster().
> 
> This improves code clarity and consistency with standard error
> handling practices.
> 
> Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn>
> ---
>  fs/exfat/namei.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/exfat/namei.c b/fs/exfat/namei.c
> index f5f1c4e8a29f..f2a87ecd79f9 100644
> --- a/fs/exfat/namei.c
> +++ b/fs/exfat/namei.c
> @@ -304,8 +304,8 @@ static int exfat_find_empty_entry(struct inode *inode,
>  		struct exfat_chain *p_dir, int num_entries,
>  		struct exfat_entry_set_cache *es)
>  {
> -	int dentry;
> -	unsigned int ret, last_clu;
> +	int dentry, ret;
> +	unsigned int last_clu;

The patch looks good to me:

Reviewed-by: Sungjong Seo <sj1557.seo@samsung.com>

>  	loff_t size = 0;
>  	struct exfat_chain clu;
>  	struct super_block *sb = inode->i_sb;