git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Erik Faye-Lund <kusmabite@gmail.com>
To: git@vger.kernel.org
Cc: gitster@pobox.com, j6t@kdbg.org, msysgit@googlegroups.com,
	Erik Faye-Lund <kusmabite@gmail.com>
Subject: [PATCH] mingw: do not set errno to 0 on success
Date: Tue, 23 Nov 2010 20:53:08 +0100	[thread overview]
Message-ID: <1290541988-4608-1-git-send-email-kusmabite@gmail.com> (raw)

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

             reply	other threads:[~2010-11-23 19:54 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-23 19:53 Erik Faye-Lund [this message]
2010-11-24  0:07 ` [PATCH] mingw: do not set errno to 0 on success Junio C Hamano
2010-11-24  9:54   ` Erik Faye-Lund

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=1290541988-4608-1-git-send-email-kusmabite@gmail.com \
    --to=kusmabite@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=j6t@kdbg.org \
    --cc=msysgit@googlegroups.com \
    /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).