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

[PATCH 3/3] write_in_full: size_t is unsigned.

From
Junio C Hamano <junkio@cox.net>
Date
Jan 27, 2007, 01:49 UTC
Message-ID
<7vlkjpqlwp.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<7vbqkluzcm.fsf@assigned-by-dhcp.cox.net>

It received the return value from xwrite() in a size_t variable 'written' and expected comparison with 0 would catch an error from xwrite().

Signed-off-by: Junio C Hamano <junkio@cox.net>
---
 * and this is the third bug t7207-co.sh caught.  I haven't
   bothered to look at the assembly, but I suspect the error
   return path could have been totally optimized out X-<.
 write_or_die.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/write_or_die.c b/write_or_die.c
index 046e79d..5c4bc85 100644
--- a/write_or_die.c
+++ b/write_or_die.c
@@ -23,7 +23,7 @@ int write_in_full(int fd, const void *buf, size_t count)
 	ssize_t total = 0;
 
 	while (count > 0) {
-		size_t written = xwrite(fd, p, count);
+		ssize_t written = xwrite(fd, p, count);
 		if (written < 0)
 			return -1;
 		if (!written) {
-- 
1.5.0.rc2.g8ac6-dirty
Previous: Junio C Hamano
Message 4 of 4 in “reflog for HEAD (detached or between branches)”
  1. Nicolas PitreJan 26, 2007
  2. Junio C HamanoJan 26, 2007
  3. 1/3 create_symref: check error return from open().Junio C Hamano, Jan 27, 2007
  4. 3/3 write_in_full: size_t is unsigned.Junio C Hamano, Jan 27, 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.