diff options
author | Jeff King <peff@peff.net> | 2017-02-16 16:31:40 -0500 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-02-16 14:15:55 -0800 |
commit | 0838cbc22fc9567ede7a60e800d876e733820060 (patch) | |
tree | a2a90069273587574ef65ae6287b54431f4b0468 /builtin/unpack-objects.c | |
parent | preparing for 2.10.3 (diff) | |
download | tgif-0838cbc22fc9567ede7a60e800d876e733820060.tar.xz |
tempfile: avoid "ferror | fclose" trick
The current code wants to record an error condition from
either ferror() or fclose(), but makes sure that we always
call both functions. So it can't use logical-OR "||", which
would short-circuit when ferror() is true. Instead, it uses
bitwise-OR "|" to evaluate both functions and set one or
more bits in the "err" flag if they reported a failure.
Unlike logical-OR, though, bitwise-OR does not introduce a
sequence point, and the order of evaluation for its operands
is unspecified. So a compiler would be free to generate code
which calls fclose() first, and then ferror() on the
now-freed filehandle.
There's no indication that this has happened in practice,
but let's write it out in a way that follows the standard.
Noticed-by: Andreas Schwab <schwab@linux-m68k.org>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/unpack-objects.c')
0 files changed, 0 insertions, 0 deletions