diff options
author | Jeff King <peff@peff.net> | 2017-03-28 22:45:25 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-03-29 01:28:04 +0300 |
commit | 892e723afd2b5696e4d75280e730bf9f1ea92329 (patch) | |
tree | 072a0e33a4353dffa1e54bcdc58b9f80658cc2c1 /builtin/index-pack.c | |
parent | e1104a5ee539408b81566066aaa6963cb87d5cd6 (diff) |
do not check odb_mkstemp return value for errors
The odb_mkstemp function does not return an error; it dies
on failure instead. But many of its callers compare the
resulting descriptor against -1 and die themselves.
Mostly this is just pointless, but it does raise a question
when looking at the callers: if they show the results of the
"template" buffer after a failure, what's in it? The answer
is: it doesn't matter, because it cannot happen.
So let's make that clear by removing the bogus error checks.
In bitmap_writer_finish(), we can drop the error-handling
code entirely. In the other two cases, it's shared with the
open() in another code path; we can just move the
error-check next to that open() call.
And while we're at it, let's flesh out the function's
docstring a bit to make the error behavior clear.
Signed-off-by: Jeff King <peff@peff.net>
Diffstat (limited to 'builtin/index-pack.c')
-rw-r--r-- | builtin/index-pack.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/builtin/index-pack.c b/builtin/index-pack.c index 88d205f858..49e7175d9a 100644 --- a/builtin/index-pack.c +++ b/builtin/index-pack.c @@ -311,10 +311,11 @@ static const char *open_pack_file(const char *pack_name) output_fd = odb_mkstemp(tmp_file, sizeof(tmp_file), "pack/tmp_pack_XXXXXX"); pack_name = xstrdup(tmp_file); - } else + } else { output_fd = open(pack_name, O_CREAT|O_EXCL|O_RDWR, 0600); - if (output_fd < 0) - die_errno(_("unable to create '%s'"), pack_name); + if (output_fd < 0) + die_errno(_("unable to create '%s'"), pack_name); + } nothread_data.pack_fd = output_fd; } else { input_fd = open(pack_name, O_RDONLY); |