Re: [PATCH 2/2] added more informative error messages to git-mktag

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Björn Engelmann <BjEngelmann@xxxxxx> writes:

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

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


-
: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]