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>
This commit is contained in:

committed by
Junio C Hamano

parent
e1104a5ee5
commit
892e723afd
5
cache.h
5
cache.h
@ -1674,7 +1674,10 @@ extern struct packed_git *find_sha1_pack(const unsigned char *sha1,
|
||||
extern void pack_report(void);
|
||||
|
||||
/*
|
||||
* Create a temporary file rooted in the object database directory.
|
||||
* Create a temporary file rooted in the object database directory, or
|
||||
* die on failure. The filename is taken from "pattern", which should have the
|
||||
* usual "XXXXXX" trailer, and the resulting filename is written into the
|
||||
* "template" buffer. Returns the open descriptor.
|
||||
*/
|
||||
extern int odb_mkstemp(char *template, size_t limit, const char *pattern);
|
||||
|
||||
|
Reference in New Issue
Block a user