git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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.
Previous: Björn Engelmann
Message 2 of 2 in “added more informative error messages to git-mktag”
  1. 2/2 added more informative error messages to git-mktagBjörn Engelmann, May 22, 2006
  2. Junio C HamanoMay 22, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.