Skip to content

Commit

Permalink
Merge branch 'ab/common-main-cleanup'
Browse files Browse the repository at this point in the history
Code clean-up.

* ab/common-main-cleanup:
  common-main.c: call exit(), don't return
  • Loading branch information
gitster committed Dec 23, 2021
2 parents dcaf17c + 368b584 commit 67b7017
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
9 changes: 6 additions & 3 deletions common-main.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ int main(int argc, const char **argv)

result = cmd_main(argc, argv);

trace2_cmd_exit(result);

return result;
/*
* We define exit() to call trace2_cmd_exit_fl() in
* git-compat-util.h. Whether we reach this or exit()
* elsewhere we'll always run our trace2 exit handler.
*/
exit(result);
}
5 changes: 3 additions & 2 deletions t/helper/test-trace2.c
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,9 @@ static int print_usage(void)
* [] the "cmd_name" event has been generated.
* [] this writes various "def_param" events for interesting config values.
*
* We further assume that if we return (rather than exit()), trace2_cmd_exit()
* will be called by test-tool.c:cmd_main().
* We return from here and let test-tool.c::cmd_main() pass the exit
* code to common-main.c::main(), which will use it to call
* trace2_cmd_exit().
*/
int cmd__trace2(int argc, const char **argv)
{
Expand Down

0 comments on commit 67b7017

Please sign in to comment.