summaryrefslogtreecommitdiff
path: root/contrib/git-shell-commands/help
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2025-07-23 20:03:08 -0400
committerJunio C Hamano <gitster@pobox.com>2025-07-24 11:28:10 -0700
commit0f1b33815b553dd457f8e38e3768b73cf9227082 (patch)
tree4dd12617050543c07776b42fbfd37dac3748d15c /contrib/git-shell-commands/help
parent760dd804bb40b613396d25a0905db7fe4a52b00f (diff)
test-delta: close output descriptor after use
After we write to the output file, the program exits. This naturally closes the descriptor. But we should do an explicit close for two reasons: 1. It's possible to hit an error on close(), which we should detect and report via our exit code. 2. Leaking descriptors is a bad practice in general. Even if it isn't meaningful here, it sets a bad example. It is tempting to write: if (write_in_full(fd, ...) < 0 || close(fd) < 0) die_errno(...); But that pattern contains a subtle problem that has resulted in descriptor leaks before. If write_in_full() fails, we'll short-circuit and never call close(), leaking the descriptor. That's not a problem here, since our error path dies instead of returning up the stack. But since we're trying to set a good example, let's write it out as two separate conditions. As a bonus, that lets us produce a slightly more specific error message. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'contrib/git-shell-commands/help')
0 files changed, 0 insertions, 0 deletions