From: Jonathan Nieder <jrnieder@gmail.com>
To: Ralf Thielow <ralf.thielow@googlemail.com>
Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH] commit: Remove backward goto in read_craft_line()
Date: Wed, 1 Dec 2010 13:44:42 -0600 [thread overview]
Message-ID: <20101201194441.GB27347@burratino> (raw)
In-Reply-To: <1291230959-3894-1-git-send-email-ralf.thielow@googlemail.com>
Ralf Thielow wrote:
> 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.
I like it. Three tiny nits.
Perhaps the log message could be clarified like so:
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. Move the
error handling to the end of the function for better readability.
> --- 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;
Trailing whitespace. (You can avoid this in the future with
"git diff --check".)
[...]
> @@ -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);
A space before the "bad_graft_data:" label would improve future
diff --show-c-function output.
Except as noted above,
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Thanks.
---
diff --git a/commit.c b/commit.c
index d86159a..d5144f6 100644
--- a/commit.c
+++ b/commit.c
@@ -137,7 +137,7 @@ 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)
+ if ((len + 1) % 41)
goto bad_graft_data;
i = (len + 1) / 41 - 1;
graft = xmalloc(sizeof(*graft) + 20 * i);
@@ -152,7 +152,7 @@ struct commit_graft *read_graft_line(char *buf, int len)
}
return graft;
-bad_graft_data:
+ bad_graft_data:
error("bad graft data: %s", buf);
free(graft);
return NULL;
next prev parent reply other threads:[~2010-12-01 19:44 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-01 19:15 [PATCH] commit: Remove backward goto in read_craft_line() Ralf Thielow
2010-12-01 19:44 ` Jonathan Nieder [this message]
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
-- strict thread matches above, loose matches on Subject: below --
2010-12-01 19:59 Ralf Thielow
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20101201194441.GB27347@burratino \
--to=jrnieder@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=ralf.thielow@googlemail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).