From: Jeff King <peff@peff.net>
To: Jim Meyering <jim@meyering.net>
Cc: git list <git@vger.kernel.org>
Subject: Re: [PATCH] remove unnecessary test and dead diagnostic
Date: Thu, 26 May 2011 12:28:44 -0400 [thread overview]
Message-ID: <20110526162844.GB4049@sigill.intra.peff.net> (raw)
In-Reply-To: <87mxi95y4z.fsf@rho.meyering.net>
On Thu, May 26, 2011 at 04:34:20PM +0200, Jim Meyering wrote:
> Argh. I went in with blinders on, thinking that the caller was
> right in using a type of size_t, and then read this "xread" name and
> assumed that it would exit upon failure.
I've made the same mistake, as many of our x* functions are designed to
die on error.
> Subject: [PATCH] use the correct type (ssize_t, not size_t) for read-style function
>
> * sha1_file.c (index_stream): Using an unsigned type,
> we would fail to detect a read error and then proceed to
> try to write (size_t)-1 bytes.
This version looks right to me.
There's another one, too:
-- >8 --
Subject: [PATCH] read_gitfile_gently: use ssize_t to hold read result
Otherwise, a negative error return becomes a very large read
value. We catch this in practice because we compare the
expected and actual numbers of bytes (and you are not likely
to be reading (size_t)-1 bytes), but this makes the
correctness a little more obvious.
Signed-off-by: Jeff King <peff@peff.net>
---
setup.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/setup.c b/setup.c
index 013ad11..ce87900 100644
--- a/setup.c
+++ b/setup.c
@@ -382,7 +382,7 @@ const char *read_gitfile_gently(const char *path)
const char *slash;
struct stat st;
int fd;
- size_t len;
+ ssize_t len;
if (stat(path, &st))
return NULL;
--
1.7.4.5.13.gd3ff5
next prev parent reply other threads:[~2011-05-26 16:28 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-26 13:59 [PATCH] remove unnecessary test and dead diagnostic Jim Meyering
2011-05-26 14:11 ` Jeff King
2011-05-26 14:34 ` Jim Meyering
2011-05-26 16:28 ` Jeff King [this message]
2011-05-26 14:37 ` Jim Meyering
2011-05-26 16:30 ` [PATCH] read_in_full: always report errors Jeff King
2011-05-26 18:35 ` Junio C Hamano
2011-05-26 18:48 ` Jeff King
2011-05-26 20:53 ` Junio C Hamano
2011-05-26 21:04 ` Jeff King
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=20110526162844.GB4049@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=jim@meyering.net \
/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).