mingw: do not set errno to 0 on success
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> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Erik Faye-Lund committed
Nov 23, 2010 at 20:53 UTC
e93368d26ebcf69698b8454afb85c9c84bd54363
1 file changed
+3
-1
compat/mingw.c
+3
-1
@@ -195,9 +195,10 @@ static inline time_t filetime_to_time_t(const FILETIME *ft)
195
*/
196
static int do_lstat(const char *file_name, struct stat *buf)
197
{
198
+ int err;
199
WIN32_FILE_ATTRIBUTE_DATA fdata;
200
200
- if (!(errno = get_file_attr(file_name, &fdata))) {
201
+ if (!(err = get_file_attr(file_name, &fdata))) {
202
buf->st_ino = 0;
203
buf->st_gid = 0;
204
buf->st_uid = 0;
@@ -211,6 +212,7 @@ static int do_lstat(const char *file_name, struct stat *buf)
212
buf->st_ctime = filetime_to_time_t(&(fdata.ftCreationTime));
213
return 0;
214
}
215
+ errno = err;
216
return -1;
217
}
218