git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] commit: Remove backward goto in read_craft_line()
@ 2010-12-01 19:15 Ralf Thielow
  2010-12-01 19:44 ` Jonathan Nieder
  0 siblings, 1 reply; 8+ messages in thread
From: Ralf Thielow @ 2010-12-01 19:15 UTC (permalink / raw)
  To: git; +Cc: Ralf Thielow

In case of bad graft data which is determine on many
places we go back to the first place of detection,
so move it to the end of the function.

Signed-off-by: Ralf Thielow <ralf.thielow@googlemail.com>
---
 commit.c |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/commit.c b/commit.c
index 0094ec1..d86159a 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)
-- 
1.7.1

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

end of thread, other threads:[~2010-12-01 21:41 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-01 19:15 [PATCH] commit: Remove backward goto in read_craft_line() Ralf Thielow
2010-12-01 19:44 ` Jonathan Nieder
2010-12-01 20:19   ` Junio C Hamano
2010-12-01 20:31     ` Jonathan Nieder
2010-12-01 20:44       ` Ralf Thielow
2010-12-01 21:07         ` Trivial patches (Re: [PATCH] commit: Remove backward goto in read_craft_line()) Jonathan Nieder
2010-12-01 21:19         ` [PATCH] commit: Remove backward goto in read_craft_line() Junio C Hamano
2010-12-01 21:40           ` Ralf Thielow

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).