From: Alex Riesen <raa.lkml@gmail.com>
To: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Cc: Junio C Hamano <gitster@pobox.com>,
Clemens Buchacher <drizzd@aon.at>,
Finn Arne Gangstad <finnag@pvv.org>,
Tim Olsen <tim@brooklynpenguin.com>,
git@vger.kernel.org
Subject: Re: [PATCH v2] diff -c -p: do not die on submodules
Date: Thu, 30 Apr 2009 00:19:58 +0200 [thread overview]
Message-ID: <81b0412b0904291519m41035200n408b6ab409eed127@mail.gmail.com> (raw)
In-Reply-To: <alpine.DEB.1.00.0904300011140.10279@pacific.mpi-cbg.de>
2009/4/30 Johannes Schindelin <Johannes.Schindelin@gmx.de>:
> Hi,
>
> On Wed, 29 Apr 2009, Alex Riesen wrote:
>
>> 2009/4/29 Junio C Hamano <gitster@pobox.com>:
>> > +
>> > + if (S_ISGITLINK(mode)) {
>> > + blob = xmalloc(100);
>> > + *size = snprintf(blob, 100,
>> > + "Subproject commit %s\n", sha1_to_hex(sha1));
>>
>> snprintf returns a signed value. It also has a bad record of returning
>> negative values for obscure reasons (on obscure platforms, admittedly).
>>
>> For this particular case,
>>
>> strcpy(blob, "Subproject commit ");
>> strcat(blob, sha1_to_hex(sha1));
>> strcat(blob, "\n");
>> *size = strlen(blob); /* that's a constant */
>>
>> could be considered.
>
> Actually, we know _exactly_ the size of the thing. It is 18+40+1. But I
> think that *size wants to have the size, not the length. So add 1.
>
> In any case, I don't think that we have to jump through hoops here:
> snprintf() is _most_ unlikely to return something negative here. So I'd
> say that readability trumps paranoia here.
>
http://www.google.com/search?q=snprintf+negative+return+value
First link: http://bytes.com/groups/c/590845-snprintf-return-value
Look for "(Windows, mingw)"
next prev parent reply other threads:[~2009-04-29 22:20 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-28 17:36 different git-merge behavior with regard to submodules in 1.6.2.4 vs. 1.6.2.1 Tim Olsen
2009-04-28 18:29 ` Junio C Hamano
2009-04-28 21:12 ` Finn Arne Gangstad
2009-04-29 8:42 ` Clemens Buchacher
2009-04-29 12:15 ` Finn Arne Gangstad
2009-04-29 18:53 ` [PATCH] Teach gitlinks to combine-diff Junio C Hamano
2009-04-29 20:26 ` [PATCH v2] diff -c -p: do not die on submodules Junio C Hamano
2009-04-29 21:50 ` Alex Riesen
2009-04-29 22:13 ` Johannes Schindelin
2009-04-29 22:19 ` Alex Riesen [this message]
2009-04-29 22:39 ` Johannes Schindelin
2009-04-30 5:47 ` Alex Riesen
2009-04-30 6:07 ` Finn Arne Gangstad
2009-04-29 23:09 ` Junio C Hamano
2009-04-29 18:54 ` different git-merge behavior with regard to submodules in 1.6.2.4 vs. 1.6.2.1 Junio C Hamano
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=81b0412b0904291519m41035200n408b6ab409eed127@mail.gmail.com \
--to=raa.lkml@gmail.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=drizzd@aon.at \
--cc=finnag@pvv.org \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=tim@brooklynpenguin.com \
/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;
as well as URLs for NNTP newsgroup(s).