btrfs: send: Simplify send_create_inode_if_needed
PATCH 1/1 btrfs: send: Simplify send_create_inode_if_needed
The out label is being overused, we can simply return if the condition permits.
No functional changes.
--- fs/btrfs/send.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-)
fs/btrfs/send.c +4 -11
@@ -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 {
Signature · 1 line
2.26.2
Quoted 7 lines · 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 <[email protected]>
--
Su
Quoted 33 lines
--- fs/btrfs/send.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-)fs/btrfs/send.c +4
-11@@ -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{
Quoted 6 lines · 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 <[email protected]>
Quoted 10 lines
--- fs/btrfs/send.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-)fs/btrfs/send.c +0
-0@@ -2727,19 +2727,12 @@ static int send_create_inode_if_needed(struct send_ctx *sctx)if (S_ISDIR (sctx->cur_inode_mode)) {
fs/btrfs/send.c static int send_create_inode_if_needed(struct send_ctx *sctx) · line 2732
Quoted 10 lines
fs/btrfs/send.c +3
-5ret =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.
Quoted 13 lines
fs/btrfs/send.c +1
-6} - 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 {
Quoted 31 lines · Nikolay Borisov
Quoted 7 lines · 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 <[email protected]>Reviewed-by Nikolay Borisov <[email protected]>Quoted 20 lines
--- fs/btrfs/send.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-)fs/btrfs/send.c +2
-5@@ -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 )
Quoted 8 lines
fs/btrfs/send.c static int send_create_inode_if_needed(struct send_ctx *sctx) · line 2732
Quoted 1 line
fs/btrfs/send.c +1
-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
Quoted 14 lines
Quoted 14 lines
fs/btrfs/send.c +1
-6} - 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{
Quoted 6 lines · 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 <[email protected]>
Added to misc-next, with the if-else update, thanks.