mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] ntfs: remove unreachable code in load_and_init_attrdef/upcase
@ 2026-09-07 10:16 Jiangshan Yi
  2026-09-08  5:58 ` liubaolin
  2026-09-08  9:41 ` Namjae Jeon
  0 siblings, 2 replies; 3+ messages in thread
From: Jiangshan Yi @ 2026-09-07 10:16 UTC (permalink / raw)
  To: linkinjeon, hyc.lee; +Cc: ntfs, linux-kernel, 13667453960, Jiangshan Yi

Both load_and_init_attrdef() and load_and_init_upcase() open a system
inode with ntfs_iget() and, on error, run:

	if (IS_ERR(ino)) {
		if (!IS_ERR(ino))
			iput(ino);
		goto failed;
	}

The inner guard is the exact negation of the outer one, so
iput(ino) is dead code.  Drop the unreachable branch and collapse
the error check to a single statement.

No functional change.

Signed-off-by: Jiangshan Yi <yijiangshan@kylinos.cn>
---
 fs/ntfs/super.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
index 60d43339c590..1b916deb7acc 100644
--- a/fs/ntfs/super.c
+++ b/fs/ntfs/super.c
@@ -1235,11 +1235,8 @@ static bool load_and_init_attrdef(struct ntfs_volume *vol)
 	ntfs_debug("Entering.");
 	/* Read attrdef table and setup vol->attrdef and vol->attrdef_size. */
 	ino = ntfs_iget(sb, FILE_AttrDef);
-	if (IS_ERR(ino)) {
-		if (!IS_ERR(ino))
-			iput(ino);
+	if (IS_ERR(ino))
 		goto failed;
-	}
 	NInoSetSparseDisabled(NTFS_I(ino));
 	/* FILE_AttrDef must hold at least one entry and fit inside 31 bits. */
 	i_size = i_size_read(ino);
@@ -1301,11 +1298,8 @@ static bool load_and_init_upcase(struct ntfs_volume *vol)
 	ntfs_debug("Entering.");
 	/* Read upcase table and setup vol->upcase and vol->upcase_len. */
 	ino = ntfs_iget(sb, FILE_UpCase);
-	if (IS_ERR(ino)) {
-		if (!IS_ERR(ino))
-			iput(ino);
+	if (IS_ERR(ino))
 		goto upcase_failed;
-	}
 	/*
 	 * The upcase size must not be above 64k Unicode characters, must not
 	 * be zero and must be a multiple of sizeof(__le16).
-- 
2.25.1


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

* Re: [PATCH] ntfs: remove unreachable code in load_and_init_attrdef/upcase
  2026-09-07 10:16 [PATCH] ntfs: remove unreachable code in load_and_init_attrdef/upcase Jiangshan Yi
@ 2026-09-08  5:58 ` liubaolin
  2026-09-08  9:41 ` Namjae Jeon
  1 sibling, 0 replies; 3+ messages in thread
From: liubaolin @ 2026-09-08  5:58 UTC (permalink / raw)
  To: Jiangshan Yi, linkinjeon, hyc.lee; +Cc: ntfs, linux-kernel, 13667453960



在 2026/9/7 18:16, Jiangshan Yi 写道:
> Both load_and_init_attrdef() and load_and_init_upcase() open a system
> inode with ntfs_iget() and, on error, run:
> 
> 	if (IS_ERR(ino)) {
> 		if (!IS_ERR(ino))
> 			iput(ino);
> 		goto failed;
> 	}
> 
> The inner guard is the exact negation of the outer one, so
> iput(ino) is dead code.  Drop the unreachable branch and collapse
> the error check to a single statement.
> 
> No functional change.
> 
> Signed-off-by: Jiangshan Yi <yijiangshan@kylinos.cn>
> ---
>   fs/ntfs/super.c | 10 ++--------
>   1 file changed, 2 insertions(+), 8 deletions(-)
> 
> diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
> index 60d43339c590..1b916deb7acc 100644
> --- a/fs/ntfs/super.c
> +++ b/fs/ntfs/super.c
> @@ -1235,11 +1235,8 @@ static bool load_and_init_attrdef(struct ntfs_volume *vol)
>   	ntfs_debug("Entering.");
>   	/* Read attrdef table and setup vol->attrdef and vol->attrdef_size. */
>   	ino = ntfs_iget(sb, FILE_AttrDef);
> -	if (IS_ERR(ino)) {
> -		if (!IS_ERR(ino))
> -			iput(ino);
> +	if (IS_ERR(ino))
>   		goto failed;
> -	}
>   	NInoSetSparseDisabled(NTFS_I(ino));
>   	/* FILE_AttrDef must hold at least one entry and fit inside 31 bits. */
>   	i_size = i_size_read(ino);
> @@ -1301,11 +1298,8 @@ static bool load_and_init_upcase(struct ntfs_volume *vol)
>   	ntfs_debug("Entering.");
>   	/* Read upcase table and setup vol->upcase and vol->upcase_len. */
>   	ino = ntfs_iget(sb, FILE_UpCase);
> -	if (IS_ERR(ino)) {
> -		if (!IS_ERR(ino))
> -			iput(ino);
> +	if (IS_ERR(ino))
>   		goto upcase_failed;
> -	}
>   	/*
>   	 * The upcase size must not be above 64k Unicode characters, must not
>   	 * be zero and must be a multiple of sizeof(__le16).



Looks good to me.

Reviewed-by: Baolin Liu <liubaolin@kylinos.cn>


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

* Re: [PATCH] ntfs: remove unreachable code in load_and_init_attrdef/upcase
  2026-09-07 10:16 [PATCH] ntfs: remove unreachable code in load_and_init_attrdef/upcase Jiangshan Yi
  2026-09-08  5:58 ` liubaolin
@ 2026-09-08  9:41 ` Namjae Jeon
  1 sibling, 0 replies; 3+ messages in thread
From: Namjae Jeon @ 2026-09-08  9:41 UTC (permalink / raw)
  To: Jiangshan Yi; +Cc: hyc.lee, ntfs, linux-kernel, 13667453960

On Mon, Sep 7, 2026 at 7:17 PM Jiangshan Yi <yijiangshan@kylinos.cn> wrote:
>
> Both load_and_init_attrdef() and load_and_init_upcase() open a system
> inode with ntfs_iget() and, on error, run:
>
>         if (IS_ERR(ino)) {
>                 if (!IS_ERR(ino))
>                         iput(ino);
>                 goto failed;
>         }
>
> The inner guard is the exact negation of the outer one, so
> iput(ino) is dead code.  Drop the unreachable branch and collapse
> the error check to a single statement.
>
> No functional change.
>
> Signed-off-by: Jiangshan Yi <yijiangshan@kylinos.cn>
Applied it to #ntfs-next.
Thanks!

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

end of thread, other threads:[~2026-09-08  9:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-07 10:16 [PATCH] ntfs: remove unreachable code in load_and_init_attrdef/upcase Jiangshan Yi
2026-09-08  5:58 ` liubaolin
2026-09-08  9:41 ` Namjae Jeon

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

all inboxes | Powered by JetHome®