linux-unionfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ovl: only assign err on error path
@ 2025-08-20  9:28 huhai
  2025-08-20  9:33 ` Amir Goldstein
  2025-08-20  9:43 ` Markus Elfring
  0 siblings, 2 replies; 3+ messages in thread
From: huhai @ 2025-08-20  9:28 UTC (permalink / raw)
  To: miklos, amir73il; +Cc: linux-unionfs, linux-kernel, huhai

In ovl_get_upper(), the result of clone_private_mount() was
unconditionally assigned to 'err' using PTR_ERR(), even when the
returned 'upper_mnt' was valid. This assignment is unnecessary in
the success path and can be avoided.

Move the 'err = PTR_ERR(upper_mnt)' assignment inside the
IS_ERR(upper_mnt) branch so that 'err' is only set when an
error actually occurred.

No functional change intended.

Signed-off-by: huhai <huhai@kylinos.cn>
---
 fs/overlayfs/super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
index df85a76597e9..a29ce0bce6a5 100644
--- a/fs/overlayfs/super.c
+++ b/fs/overlayfs/super.c
@@ -512,9 +512,9 @@ static int ovl_get_upper(struct super_block *sb, struct ovl_fs *ofs,
 		goto out;
 
 	upper_mnt = clone_private_mount(upperpath);
-	err = PTR_ERR(upper_mnt);
 	if (IS_ERR(upper_mnt)) {
 		pr_err("failed to clone upperpath\n");
+		err = PTR_ERR(upper_mnt);
 		goto out;
 	}
 
-- 
2.40.1


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

* Re: [PATCH] ovl: only assign err on error path
  2025-08-20  9:28 [PATCH] ovl: only assign err on error path huhai
@ 2025-08-20  9:33 ` Amir Goldstein
  2025-08-20  9:43 ` Markus Elfring
  1 sibling, 0 replies; 3+ messages in thread
From: Amir Goldstein @ 2025-08-20  9:33 UTC (permalink / raw)
  To: huhai; +Cc: miklos, linux-unionfs, linux-kernel, huhai

On Wed, Aug 20, 2025 at 11:29 AM huhai <hhtracer@gmail.com> wrote:
>
> In ovl_get_upper(), the result of clone_private_mount() was
> unconditionally assigned to 'err' using PTR_ERR(), even when the
> returned 'upper_mnt' was valid. This assignment is unnecessary in
> the success path and can be avoided.
>
> Move the 'err = PTR_ERR(upper_mnt)' assignment inside the
> IS_ERR(upper_mnt) branch so that 'err' is only set when an
> error actually occurred.
>
> No functional change intended.
>
> Signed-off-by: huhai <huhai@kylinos.cn>
> ---
>  fs/overlayfs/super.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
> index df85a76597e9..a29ce0bce6a5 100644
> --- a/fs/overlayfs/super.c
> +++ b/fs/overlayfs/super.c
> @@ -512,9 +512,9 @@ static int ovl_get_upper(struct super_block *sb, struct ovl_fs *ofs,
>                 goto out;
>
>         upper_mnt = clone_private_mount(upperpath);
> -       err = PTR_ERR(upper_mnt);
>         if (IS_ERR(upper_mnt)) {
>                 pr_err("failed to clone upperpath\n");
> +               err = PTR_ERR(upper_mnt);
>                 goto out;
>         }
>

NAK.

No good reason to make this change.
To be clear,
"This assignment is unnecessary in the success path and can be avoided"
is not a good enough reason.

Thanks,
Amir.

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

* Re: [PATCH] ovl: only assign err on error path
  2025-08-20  9:28 [PATCH] ovl: only assign err on error path huhai
  2025-08-20  9:33 ` Amir Goldstein
@ 2025-08-20  9:43 ` Markus Elfring
  1 sibling, 0 replies; 3+ messages in thread
From: Markus Elfring @ 2025-08-20  9:43 UTC (permalink / raw)
  To: huhai, linux-unionfs; +Cc: hhtracer, LKML, Amir Goldstein, Miklos Szeredi

…
> Signed-off-by: huhai <huhai@kylinos.cn>
> ---
>  fs/overlayfs/super.c | 2 +-
…

Should the personal name be usually different from an email identifier
according to requirements of the Developer's Certificate of Origin?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.17-rc2#n436

Regards,
Markus

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

end of thread, other threads:[~2025-08-20  9:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-20  9:28 [PATCH] ovl: only assign err on error path huhai
2025-08-20  9:33 ` Amir Goldstein
2025-08-20  9:43 ` Markus Elfring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).