Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1716502

[PATCH v2] btrfs: Use common error handling code in update_ref_path()

From SF Markus Elfring <elfring@users.sourceforge.net>
Newsgroups linux.kernel
Subject [PATCH v2] btrfs: Use common error handling code in update_ref_path()
Date 2017-08-21 16:00 +0200
Message-ID <ugVpg-54m-21@gated-at.bofh.it> (permalink)
References <ugU9P-4ml-11@gated-at.bofh.it> <ugUjw-4pR-15@gated-at.bofh.it> <ugUCS-4Nm-13@gated-at.bofh.it> <ugVfA-50U-17@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 21 Aug 2017 15:45:23 +0200

Add a jump target so that a bit of exception handling can be better reused
at the end of this function.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---

v2:
Do you find this refactoring acceptable instead?

 fs/btrfs/send.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
index 59fb1ed6ca20..527a9a735664 100644
--- a/fs/btrfs/send.c
+++ b/fs/btrfs/send.c
@@ -3697,20 +3697,20 @@ static int update_ref_path(struct send_ctx *sctx, struct recorded_ref *ref)
 		return -ENOMEM;
 
 	ret = get_cur_path(sctx, ref->dir, ref->dir_gen, new_path);
-	if (ret < 0) {
-		fs_path_free(new_path);
-		return ret;
-	}
+	if (ret < 0)
+		goto free_path;
+
 	ret = fs_path_add(new_path, ref->name, ref->name_len);
-	if (ret < 0) {
-		fs_path_free(new_path);
-		return ret;
-	}
+	if (ret < 0)
+		goto free_path;
 
 	fs_path_free(ref->full_path);
 	set_ref_path(ref, new_path);
 
 	return 0;
+free_path:
+	fs_path_free(new_path);
+	return ret;
 }
 
 /*
-- 
2.14.0

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/5] BTRFS: Fine-tuning for five function implementations SF Markus Elfring <elfring@users.sourceforge.net> - 2017-08-21 14:40 +0200
  [PATCH 2/5] btrfs: Use common error handling code in  __btrfs_free_extent() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-08-21 14:40 +0200
    Re: [PATCH 2/5] btrfs: Use common error handling code in  __btrfs_free_extent() Jeff Mahoney <jeffm@suse.com> - 2017-08-21 15:10 +0200
      Re: [PATCH 2/5] btrfs: Use common error handling code in  __btrfs_free_extent() Dan Carpenter <dan.carpenter@oracle.com> - 2017-08-21 15:20 +0200
  [PATCH 4/5] btrfs: Use common error handling code in  update_ref_path() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-08-21 14:50 +0200
    Re: [PATCH 4/5] btrfs: Use common error handling code in  update_ref_path() Jeff Mahoney <jeffm@suse.com> - 2017-08-21 15:10 +0200
      Re: [PATCH 4/5] btrfs: Use common error handling code in  update_ref_path() Dan Carpenter <dan.carpenter@oracle.com> - 2017-08-21 15:50 +0200
        [PATCH v2] btrfs: Use common error handling code in update_ref_path() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-08-21 16:00 +0200
  [PATCH 5/5] btrfs: Use common error handling code in  btrfs_mark_extent_written() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-08-21 14:50 +0200
    Re: [PATCH 5/5] btrfs: Use common error handling code in  btrfs_mark_extent_written() Jeff Mahoney <jeffm@suse.com> - 2017-08-21 15:10 +0200
  [PATCH 3/5] btrfs: Use common error handling code in  btrfs_update_root() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-08-21 14:50 +0200
    Re: [PATCH 3/5] btrfs: Use common error handling code in  btrfs_update_root() Jeff Mahoney <jeffm@suse.com> - 2017-08-21 15:10 +0200
  Re: [PATCH 0/5] BTRFS: Fine-tuning for five function implementations David Sterba <dsterba@suse.cz> - 2017-08-21 15:30 +0200

csiph-web