Skip to content

Commit

Permalink
fast-import: Don't use a maybe-clobbered errno value
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
  • Loading branch information
meyering authored and gitster committed Jan 18, 2008
1 parent 1812564 commit 5a7b1b5
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions fast-import.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;
}
}
Expand Down

0 comments on commit 5a7b1b5

Please sign in to comment.