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

[PATCH] mingw: do not set errno to 0 on success

From
Erik Faye-Lund <kusmabite@gmail.com>
Date
Nov 23, 2010, 19:53 UTC
Message-ID
<1290541988-4608-1-git-send-email-kusmabite@gmail.com>

Currently do_lstat always sets errno to 0 on success. This incorrectly overwrites previous errors.

Fetch the error-code into a temporary variable instead, and assign that to errno on failure.

Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
---
A bug I found while hunting down another regression. maint-worthy, perhaps?
 compat/mingw.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/compat/mingw.c b/compat/mingw.c
index f2d9e1f..b98e600 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -195,9 +195,10 @@ static inline time_t filetime_to_time_t(const FILETIME *ft)
  */
 static int do_lstat(const char *file_name, struct stat *buf)
 {
+	int err;
 	WIN32_FILE_ATTRIBUTE_DATA fdata;
 
-	if (!(errno = get_file_attr(file_name, &fdata))) {
+	if (!(err = get_file_attr(file_name, &fdata))) {
 		buf->st_ino = 0;
 		buf->st_gid = 0;
 		buf->st_uid = 0;
@@ -211,6 +212,7 @@ static int do_lstat(const char *file_name, struct stat *buf)
 		buf->st_ctime = filetime_to_time_t(&(fdata.ftCreationTime));
 		return 0;
 	}
+	errno = err;
 	return -1;
 }
 
-- 
1.7.3.2
Next: Junio C Hamano
Message 1 of 3 in “mingw: do not set errno to 0 on success”
  1. mingw: do not set errno to 0 on successErik Faye-Lund, Nov 23, 2010
  2. Junio C HamanoNov 24, 2010
  3. Erik Faye-LundNov 24, 2010

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.