aboutsummaryrefslogtreecommitdiff
path: root/commit.c
diff options
context:
space:
mode:
authorRalf Thielow <ralf.thielow@googlemail.com>2010-12-01 20:15:59 +0100
committerJunio C Hamano <gitster@pobox.com>2010-12-01 13:16:39 -0800
commitdf5d43be1f721b0ede37097b815463ceb43b0449 (patch)
treefaa4802ac818d0f0dc307dbea1fc01e08e27a251 /commit.c
parent208247adb9fc3702f87c6ec3fc26bd85d10d73e6 (diff)
downloadgit-df5d43be1f721b0ede37097b815463ceb43b0449.tar.gz
git-df5d43be1f721b0ede37097b815463ceb43b0449.tar.xz
commit.c: Remove backward goto in read_craft_line()
Bad graft data is noticed in several places in read_graft_line(), and in each case we go back to the first site of detection. It in general is a better style to have an exception handling out of line from the main codepath and make error codepath jump forward. Signed-off-by: Ralf Thielow <ralf.thielow@googlemail.com> Reviewed-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'commit.c')
-rw-r--r--commit.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/commit.c b/commit.c
index 0094ec1c9..2d9265d9f 100644
--- a/commit.c
+++ b/commit.c
@@ -137,12 +137,8 @@ struct commit_graft *read_graft_line(char *buf, int len)
buf[--len] = '\0';
if (buf[0] == '#' || buf[0] == '\0')
return NULL;
- if ((len + 1) % 41) {
- bad_graft_data:
- error("bad graft data: %s", buf);
- free(graft);
- return NULL;
- }
+ if ((len + 1) % 41)
+ goto bad_graft_data;
i = (len + 1) / 41 - 1;
graft = xmalloc(sizeof(*graft) + 20 * i);
graft->nr_parent = i;
@@ -155,6 +151,11 @@ struct commit_graft *read_graft_line(char *buf, int len)
goto bad_graft_data;
}
return graft;
+
+bad_graft_data:
+ error("bad graft data: %s", buf);
+ free(graft);
+ return NULL;
}
static int read_graft_file(const char *graft_file)