From: Alex Riesen Date: Wed, 29 Apr 2009 21:50:20 GMT Subject: Re: [PATCH v2] diff -c -p: do not die on submodules Message-ID: <81b0412b0904291450w3d292ed5i3b2ab5164c0ae0f4@mail.gmail.com> In-Reply-To: <7vy6tj8aur.fsf_-_@gitster.siamese.dyndns.org> 2009/4/29 Junio C Hamano : > + > +       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.