From: Junio C Hamano <junkio@cox.net>
To: "Björn Engelmann" <BjEngelmann@gmx.de>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 1/2] removes the artificial restriction tagsize < 8kb from git-mktag
Date: Mon, 22 May 2006 12:19:33 -0700 [thread overview]
Message-ID: <7v1wulc1fe.fsf@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: 4471CF5A.702@gmx.de
Björn Engelmann <BjEngelmann@gmx.de> writes:
> @@ -154,6 +154,7 @@ extern int ce_match_stat(struct cache_en
> extern int ce_modified(struct cache_entry *ce, struct stat *st, int);
> extern int ce_path_match(const struct cache_entry *ce, const char
> **pathspec);
> extern int index_fd(unsigned char *sha1, int fd, struct stat *st, int
> write_object, const char *type);
> +extern int read_pipe(int fd, char** return_buf, unsigned long*
> return_size);
> extern int index_pipe(unsigned char *sha1, int fd, const char *type,
> int write_object);
I smell whitespace breakage around here...
> diff --git a/mktag.c b/mktag.c
> index 2328878..79c466c 100644
> --- a/mktag.c
> +++ b/mktag.c
>...
> @@ -114,21 +114,24 @@ int main(int argc, char **argv)
>
> setup_git_directory();
>
> - // Read the signature
> - size = 0;
> - for (;;) {
> - int ret = xread(0, buffer + size, MAXSIZE - size);
> - if (ret <= 0)
> - break;
> - size += ret;
> + if (read_pipe(0, &buffer, &size)) {
> + free(buffer);
> + die("could not read from stdin");
> }
> -
> +
Please do not introduce lines with trailing whitespaces.
> // Verify it for some basic sanity: it needs to start with "object
> <sha1>\ntype\ntagger "
> - if (verify_tag(buffer, size) < 0)
> + if (verify_tag(buffer, size) < 0) {
> + free(buffer);
> die("invalid tag signature file");
> + }
You seem to be striving for extra cleanliness, but I personally
consider it is not worth calling free() immediately before you
call die().
>
> - if (write_sha1_file(buffer, size, tag_type, result_sha1) < 0)
> + if (write_sha1_file(buffer, size, tag_type, result_sha1) < 0) {
> + free(buffer);
> die("unable to write tag file");
> + }
> +
> + free(buffer);
> +
> printf("%s\n", sha1_to_hex(result_sha1));
> return 0;
> }
A call to free() immediately before returning from main() might
look similar to the die() issue I mentioned above, but we might
extend it to do a lot more after writing the tag in the future,
so this one is very good to keep.
prev parent reply other threads:[~2006-05-22 19:19 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-05-22 14:48 [PATCH 1/2] removes the artificial restriction tagsize < 8kb from git-mktag Björn Engelmann
2006-05-22 19:19 ` Junio C Hamano [this message]
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=7v1wulc1fe.fsf@assigned-by-dhcp.cox.net \
--to=junkio@cox.net \
--cc=BjEngelmann@gmx.de \
--cc=git@vger.kernel.org \
/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