Re: [PATCH 2/2] added more informative error messages to git-mktag
- From
Junio C Hamano <junkio@cox.net>
- Date
- May 22, 2006, 19:22 UTC
- Message-ID
- <7vu07hamph.fsf@assigned-by-dhcp.cox.net>
- In-Reply-To
- <4471CF91.9010202@gmx.de>
Björn Engelmann <BjEngelmann@gmx.de> writes:
Show 5 quoted lines
> - if (size < 64)
> + if (size < 64) {
> + printf("wanna fool me ? you obviously got the size wrong !\n");
> return -1;
> + }Please do this instead:
return error("wanna ...");you can lose the braces and the message goes to the stderr.
> - if (memcmp(object, "object ", 7))
> + if (memcmp(object, "object ", 7)) {
> + printf("char%i: does not start with \"object \"\n", 0);
> return -1;Although they may be synonyms, we tend to use %d for ints and it is more conventional.
Show 6 quoted lines
> tag_line++;
> - if (memcmp(tag_line, "tag ", 4) || tag_line[4] == '\n')
> + if (memcmp(tag_line, "tag ", 4) || tag_line[4] == '\n') {
> + printf("char%i: no \"tag \" found\n", (int)tag_line - (int)buffer);
> return -1;
> + }If you have to cast, please do not cast pointers to ints and take their difference, but take the difference and cast the resulting ptrdiff_t to int, like this:
(int)(tag_line - buffer)
Or use "%td" instead of "%i" and lose the cast.