diff options
author | Jeff King <peff@peff.net> | 2025-03-17 16:53:27 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2025-03-17 16:54:41 -0700 |
commit | 7e1bec1eddff2f0b0cb577881921c18a9bc31650 (patch) | |
tree | 41addfc7aa83a265dbf8328fcac05bd5e745df01 /builtin/commit.c | |
parent | f93ff170b93a1782659637824b25923245ac9dd1 (diff) |
run-command: use errno to check for sigfillset() error
Since enabling -Wunreachable-code, builds with clang on macOS now fail,
complaining that the die_errno() call in:
if (sigfillset(&all))
die_errno("sigfillset");
is unreachable. On that platform the manpage documents that sigfillset()
always returns success, and presumably the implementation is a macro or
inline function that does so in a way that is transparent to the
compiler.
But we should continue to check on other platforms, since POSIX says it
may return an error.
We could solve this with a compile-time knob to split the two cases
(assuming success on macOS and checking for the error elsewhere). But we
can also work around it more directly by relying on errno to check the
outcome (since POSIX dictates that errno will be set on error). And that
works around the compiler's cleverness, since it doesn't know the
semantics of errno (though I suppose if sigfillset() is simple enough,
it could perhaps realize that no writes to errno are possible; however
this does seem to work in practice).
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/commit.c')
0 files changed, 0 insertions, 0 deletions