mirror of
https://github.com/git/git.git
synced 2025-12-12 20:36:24 +01:00
builtins + test helpers: use return instead of exit() in cmd_*
Change various cmd_* functions that claim to return an "int" to use
"return" instead of exit() to indicate an exit code. These were not
marked with NORETURN, and by directly exit()-ing we'll skip the
cleanup git.c would otherwise do (e.g. closing fd's, erroring if we
can't). See run_builtin() in git.c.
In the case of shell.c and sh-i18n--envsubst.c this was the result of
an incomplete migration to using a cmd_main() in 3f2e2297b9 (add an
extra level of indirection to main(), 2016-07-01).
This was spotted by SunCC 12.5 on Solaris 10 (gcc210 on the gccfarm).
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
48bf2fa8ba
commit
338abb0f04
@@ -104,12 +104,12 @@ cmd_main (int argc, const char *argv[])
|
||||
if (ferror (stderr) || fflush (stderr))
|
||||
{
|
||||
fclose (stderr);
|
||||
exit (EXIT_FAILURE);
|
||||
return (EXIT_FAILURE);
|
||||
}
|
||||
if (fclose (stderr) && errno != EBADF)
|
||||
exit (EXIT_FAILURE);
|
||||
return (EXIT_FAILURE);
|
||||
|
||||
exit (EXIT_SUCCESS);
|
||||
return (EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
/* Parse the string and invoke the callback each time a $VARIABLE or
|
||||
|
||||
Reference in New Issue
Block a user