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

[PATCH] sha1_file: link() returns -1 on failure, not errno

From
Thomas Rast <trast@student.ethz.ch>
Date
Sep 18, 2008, 22:24 UTC
Message-ID
<1221776686-13284-1-git-send-email-trast@student.ethz.ch>

5723fe7 changed the call to use link() directly instead of through a custom wrapper, but forgot that it returns 0 or -1, not 0 or errno.

Signed-off-by: Thomas Rast <trast@student.ethz.ch>
---
 sha1_file.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/sha1_file.c b/sha1_file.c
index 9ee1ed1..aec81bb 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -2136,7 +2136,9 @@ static void write_sha1_file_prepare(const void *buf, unsigned long len,
  */
 int move_temp_to_file(const char *tmpfile, const char *filename)
 {
-	int ret = link(tmpfile, filename);
+	int ret = 0;
+	if (link(tmpfile, filename))
+		ret = errno;
 
 	/*
 	 * Coda hack - coda doesn't like cross-directory links,
-- 
tg: (97d7fee..) t/link-returns-minus1 (depends on: origin/master)
Message 1 of 1 in “sha1_file: link() returns -1 on failure, not errno”
  1. sha1_file: link() returns -1 on failure, not errnoThomas Rast, Sep 18, 2008

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.