summaryrefslogtreecommitdiff
path: root/fast-import.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2008-01-18 18:35:49 (GMT)
committerJunio C Hamano <gitster@pobox.com>2008-01-18 21:19:37 (GMT)
commit5a7b1b571e2bf59c65f9e5333414d2e0f7df6952 (patch)
treeae9455651613ebb01ea00b7edfa53c7615ca3738 /fast-import.c
parent181256442ec1b09d0095e009922e109aa0a4af5e (diff)
downloadgit-5a7b1b571e2bf59c65f9e5333414d2e0f7df6952.zip
git-5a7b1b571e2bf59c65f9e5333414d2e0f7df6952.tar.gz
git-5a7b1b571e2bf59c65f9e5333414d2e0f7df6952.tar.bz2
fast-import: Don't use a maybe-clobbered errno value
Without this change, each diagnostic could use an errno value clobbered by the close or unlink in rollback_lock_file. Signed-off-by: Jim Meyering <meyering@redhat.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'fast-import.c')
-rw-r--r--fast-import.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/fast-import.c b/fast-import.c
index 5e89eef..45b4edf 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -1541,9 +1541,10 @@ static void dump_marks(void)
f = fdopen(mark_fd, "w");
if (!f) {
+ int saved_errno = errno;
rollback_lock_file(&mark_lock);
failure |= error("Unable to write marks file %s: %s",
- mark_file, strerror(errno));
+ mark_file, strerror(saved_errno));
return;
}
@@ -1556,16 +1557,18 @@ static void dump_marks(void)
dump_marks_helper(f, 0, marks);
if (ferror(f) || fclose(f)) {
+ int saved_errno = errno;
rollback_lock_file(&mark_lock);
failure |= error("Unable to write marks file %s: %s",
- mark_file, strerror(errno));
+ mark_file, strerror(saved_errno));
return;
}
if (commit_lock_file(&mark_lock)) {
+ int saved_errno = errno;
rollback_lock_file(&mark_lock);
failure |= error("Unable to commit marks file %s: %s",
- mark_file, strerror(errno));
+ mark_file, strerror(saved_errno));
return;
}
}