All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <junkio@cox.net>
To: "Björn Engelmann" <BjEngelmann@gmx.de>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 2/2] added more informative error messages to git-mktag
Date: Mon, 22 May 2006 12:22:50 -0700	[thread overview]
Message-ID: <7vu07hamph.fsf@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: 4471CF91.9010202@gmx.de

Björn Engelmann <BjEngelmann@gmx.de> 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.

      reply	other threads:[~2006-05-22 19:22 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-05-22 14:49 [PATCH 2/2] added more informative error messages to git-mktag Björn Engelmann
2006-05-22 19:22 ` 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=7vu07hamph.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.