* [PATCH] btrfs: send: Simplify send_create_inode_if_needed
@ 2021-08-01 23:35 Marcos Paulo de Souza
2021-08-01 23:55 ` Su Yue
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Marcos Paulo de Souza @ 2021-08-01 23:35 UTC (permalink / raw)
To: linux-btrfs; +Cc: dsterba, fdmanana, Marcos Paulo de Souza
The out label is being overused, we can simply return if the condition
permits.
No functional changes.
Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
---
fs/btrfs/send.c | 15 ++++-----------
1 file changed, 4 insertions(+), 11 deletions(-)
diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
index 75cff564dedf..17cd67e41d3a 100644
--- a/fs/btrfs/send.c
+++ b/fs/btrfs/send.c
@@ -2727,19 +2727,12 @@ static int send_create_inode_if_needed(struct send_ctx *sctx)
if (S_ISDIR(sctx->cur_inode_mode)) {
ret = did_create_dir(sctx, sctx->cur_ino);
if (ret < 0)
- goto out;
- if (ret) {
- ret = 0;
- goto out;
- }
+ return ret;
+ if (ret > 0)
+ return 0;
}
- ret = send_create_inode(sctx, sctx->cur_ino);
- if (ret < 0)
- goto out;
-
-out:
- return ret;
+ return send_create_inode(sctx, sctx->cur_ino);
}
struct recorded_ref {
--
2.26.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] btrfs: send: Simplify send_create_inode_if_needed
2021-08-01 23:35 [PATCH] btrfs: send: Simplify send_create_inode_if_needed Marcos Paulo de Souza
@ 2021-08-01 23:55 ` Su Yue
2021-08-02 7:39 ` Nikolay Borisov
2021-08-19 12:38 ` David Sterba
2 siblings, 0 replies; 5+ messages in thread
From: Su Yue @ 2021-08-01 23:55 UTC (permalink / raw)
To: Marcos Paulo de Souza; +Cc: linux-btrfs, dsterba, fdmanana
On Mon 02 Aug 2021 at 07:35, Marcos Paulo de Souza
<mpdesouza@suse.com> wrote:
> The out label is being overused, we can simply return if the
> condition
> permits.
>
> No functional changes.
>
> Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
>
Reviewed-by: Su Yue <l@damenly.su>
--
Su
> ---
> fs/btrfs/send.c | 15 ++++-----------
> 1 file changed, 4 insertions(+), 11 deletions(-)
>
> diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
> index 75cff564dedf..17cd67e41d3a 100644
> --- a/fs/btrfs/send.c
> +++ b/fs/btrfs/send.c
> @@ -2727,19 +2727,12 @@ static int
> send_create_inode_if_needed(struct send_ctx *sctx)
> if (S_ISDIR(sctx->cur_inode_mode)) {
> ret = did_create_dir(sctx, sctx->cur_ino);
> if (ret < 0)
> - goto out;
> - if (ret) {
> - ret = 0;
> - goto out;
> - }
> + return ret;
> + if (ret > 0)
> + return 0;
> }
>
> - ret = send_create_inode(sctx, sctx->cur_ino);
> - if (ret < 0)
> - goto out;
> -
> -out:
> - return ret;
> + return send_create_inode(sctx, sctx->cur_ino);
> }
>
> struct recorded_ref {
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] btrfs: send: Simplify send_create_inode_if_needed
2021-08-01 23:35 [PATCH] btrfs: send: Simplify send_create_inode_if_needed Marcos Paulo de Souza
2021-08-01 23:55 ` Su Yue
@ 2021-08-02 7:39 ` Nikolay Borisov
2021-08-02 11:59 ` Marcos Paulo de Souza
2021-08-19 12:38 ` David Sterba
2 siblings, 1 reply; 5+ messages in thread
From: Nikolay Borisov @ 2021-08-02 7:39 UTC (permalink / raw)
To: Marcos Paulo de Souza, linux-btrfs; +Cc: dsterba, fdmanana
On 2.08.21 г. 2:35, Marcos Paulo de Souza wrote:
> The out label is being overused, we can simply return if the condition
> permits.
>
> No functional changes.
>
> Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
> ---
> fs/btrfs/send.c | 15 ++++-----------
> 1 file changed, 4 insertions(+), 11 deletions(-)
>
> diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
> index 75cff564dedf..17cd67e41d3a 100644
> --- a/fs/btrfs/send.c
> +++ b/fs/btrfs/send.c
> @@ -2727,19 +2727,12 @@ static int send_create_inode_if_needed(struct send_ctx *sctx)
> if (S_ISDIR(sctx->cur_inode_mode)) {
> ret = did_create_dir(sctx, sctx->cur_ino);
> if (ret < 0)
> - goto out;
> - if (ret) {
> - ret = 0;
> - goto out;
> - }
> + return ret;
> + if (ret > 0)
> + return 0;
nit: Personally I'd prefer in such cases to use an if/else if construct
since which branch is taken is dependent on the same value. To me using
an if/else if is a more explicit way to say "those 2 branches are
directly related). However it's not a big deal.
> }
>
> - ret = send_create_inode(sctx, sctx->cur_ino);
> - if (ret < 0)
> - goto out;
> -
> -out:
> - return ret;
> + return send_create_inode(sctx, sctx->cur_ino);
> }
>
> struct recorded_ref {
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] btrfs: send: Simplify send_create_inode_if_needed
2021-08-02 7:39 ` Nikolay Borisov
@ 2021-08-02 11:59 ` Marcos Paulo de Souza
0 siblings, 0 replies; 5+ messages in thread
From: Marcos Paulo de Souza @ 2021-08-02 11:59 UTC (permalink / raw)
To: Nikolay Borisov, Marcos Paulo de Souza, linux-btrfs; +Cc: dsterba, fdmanana
On Mon, 2021-08-02 at 10:39 +0300, Nikolay Borisov wrote:
>
> On 2.08.21 г. 2:35, Marcos Paulo de Souza wrote:
> > The out label is being overused, we can simply return if the
> > condition
> > permits.
> >
> > No functional changes.
> >
> > Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
>
> Reviewed-by: Nikolay Borisov <nborisov@suse.com>
> > ---
> > fs/btrfs/send.c | 15 ++++-----------
> > 1 file changed, 4 insertions(+), 11 deletions(-)
> >
> > diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
> > index 75cff564dedf..17cd67e41d3a 100644
> > --- a/fs/btrfs/send.c
> > +++ b/fs/btrfs/send.c
> > @@ -2727,19 +2727,12 @@ static int
> > send_create_inode_if_needed(struct send_ctx *sctx)
> > if (S_ISDIR(sctx->cur_inode_mode)) {
> > ret = did_create_dir(sctx, sctx->cur_ino);
> > if (ret < 0)
> > - goto out;
> > - if (ret) {
> > - ret = 0;
> > - goto out;
> > - }
> > + return ret;
> > + if (ret > 0)
> > + return 0;
>
> nit: Personally I'd prefer in such cases to use an if/else if
> construct
> since which branch is taken is dependent on the same value. To me
> using
> an if/else if is a more explicit way to say "those 2 branches are
> directly related). However it's not a big deal.
Indeed, it's better. Should I send a v2 in this case or david can just
add an 'else' to the last if clause?
Thanks
>
> > }
> >
> > - ret = send_create_inode(sctx, sctx->cur_ino);
> > - if (ret < 0)
> > - goto out;
> > -
> > -out:
> > - return ret;
> > + return send_create_inode(sctx, sctx->cur_ino);
> > }
> >
> > struct recorded_ref {
> >
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] btrfs: send: Simplify send_create_inode_if_needed
2021-08-01 23:35 [PATCH] btrfs: send: Simplify send_create_inode_if_needed Marcos Paulo de Souza
2021-08-01 23:55 ` Su Yue
2021-08-02 7:39 ` Nikolay Borisov
@ 2021-08-19 12:38 ` David Sterba
2 siblings, 0 replies; 5+ messages in thread
From: David Sterba @ 2021-08-19 12:38 UTC (permalink / raw)
To: Marcos Paulo de Souza; +Cc: linux-btrfs, dsterba, fdmanana
On Sun, Aug 01, 2021 at 08:35:49PM -0300, Marcos Paulo de Souza wrote:
> The out label is being overused, we can simply return if the condition
> permits.
>
> No functional changes.
>
> Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
Added to misc-next, with the if-else update, thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-08-19 12:41 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-01 23:35 [PATCH] btrfs: send: Simplify send_create_inode_if_needed Marcos Paulo de Souza
2021-08-01 23:55 ` Su Yue
2021-08-02 7:39 ` Nikolay Borisov
2021-08-02 11:59 ` Marcos Paulo de Souza
2021-08-19 12:38 ` David Sterba
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.