{"thread":{"id":"11670","subject":"[PATCH] fast-import: Don't use a maybe-clobbered errno value","startedAt":"2008-01-18T18:35:49Z","lastAt":"2008-01-18T18:35:49Z","messageCount":1,"participants":["Jim Meyering"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"65905","messageId":"8763xrgewq.fsf@rho.meyering.net","threadId":"11670","inReplyTo":null,"subject":"[PATCH] fast-import: Don't use a maybe-clobbered errno value","fromName":"Jim Meyering","fromEmail":"jim@meyering.net","sentAt":"2008-01-18T18:35:49Z","receivedAt":"2008-01-18T18:35:49Z","isPatch":true,"sender":{"key":"jim@meyering.net","avatar":"https://avatars.githubusercontent.com/u/710630?v=4"},"body":"\nWithout this change, each diagnostic could use an errno value\nclobbered by the close or unlink in rollback_lock_file.\n\nSigned-off-by: Jim Meyering <meyering@redhat.com>\n---\n fast-import.c |    9 ++++++---\n 1 files changed, 6 insertions(+), 3 deletions(-)\n\ndiff --git a/fast-import.c b/fast-import.c\nindex 5e89eef..45b4edf 100644\n--- a/fast-import.c\n+++ b/fast-import.c\n@@ -1541,9 +1541,10 @@ static void dump_marks(void)\n\n \tf = fdopen(mark_fd, \"w\");\n \tif (!f) {\n+\t\tint saved_errno = errno;\n \t\trollback_lock_file(&mark_lock);\n \t\tfailure |= error(\"Unable to write marks file %s: %s\",\n-\t\t\tmark_file, strerror(errno));\n+\t\t\tmark_file, strerror(saved_errno));\n \t\treturn;\n \t}\n\n@@ -1556,16 +1557,18 @@ static void dump_marks(void)\n\n \tdump_marks_helper(f, 0, marks);\n \tif (ferror(f) || fclose(f)) {\n+\t\tint saved_errno = errno;\n \t\trollback_lock_file(&mark_lock);\n \t\tfailure |= error(\"Unable to write marks file %s: %s\",\n-\t\t\tmark_file, strerror(errno));\n+\t\t\tmark_file, strerror(saved_errno));\n \t\treturn;\n \t}\n\n \tif (commit_lock_file(&mark_lock)) {\n+\t\tint saved_errno = errno;\n \t\trollback_lock_file(&mark_lock);\n \t\tfailure |= error(\"Unable to commit marks file %s: %s\",\n-\t\t\tmark_file, strerror(errno));\n+\t\t\tmark_file, strerror(saved_errno));\n \t\treturn;\n \t}\n }\n--\n1.5.4.rc3.31.g669237\n"}]}