git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Fix signedness on return value from xread()

From
Johan Herland <johan@herland.net>
Date
May 15, 2007, 12:39 UTC
Message-ID
<200705151439.25871.johan@herland.net>
In-Reply-To
<34a7ae040705150447k2e770b5ag3629632f61b813a0@mail.gmail.com>

The return value from xread() is ssize_t. Paolo Teti <paolo.teti@gmail.com> pointed out that in this case, the signed return value was assigned to an unsigned type (size_t). This patch fixes that.

Signed-off-by: Johan Herland <johan@herland.net>
---
Using this as an opportunity to get used to sending patches... :)
Is this what you were looking for, Paolo?
 pack-write.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/pack-write.c b/pack-write.c
index de72f44..ae2e481 100644
--- a/pack-write.c
+++ b/pack-write.c
@@ -25,7 +25,7 @@ void fixup_pack_header_footer(int pack_fd,
 
 	buf = xmalloc(buf_sz);
 	for (;;) {
-		size_t n = xread(pack_fd, buf, buf_sz);
+		ssize_t n = xread(pack_fd, buf, buf_sz);
 		if (!n)
 			break;
 		if (n < 0)
-- 
1.5.1.4
Previous: Paolo TetiNext: Paolo Teti
Message 2 of 7 in “BUG in fixup_pack_header_footer(...) / pack-write.c checksum error never raised”
  1. Paolo TetiMay 15, 2007
  2. Fix signedness on return value from xread()Johan Herland, May 15, 2007
  3. Paolo TetiMay 15, 2007
  4. Ensure return value from xread() is always stored into an ssize_tJohan Herland, May 15, 2007
  5. Dana HowMay 15, 2007
  6. Johan HerlandMay 15, 2007
  7. Shawn O. PearceMay 15, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.