Skip to content

Commit 67b7017

Browse files
committed
Merge branch 'ab/common-main-cleanup'
Code clean-up. * ab/common-main-cleanup: common-main.c: call exit(), don't return
2 parents dcaf17c + 368b584 commit 67b7017

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

common-main.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ int main(int argc, const char **argv)
5151

5252
result = cmd_main(argc, argv);
5353

54-
trace2_cmd_exit(result);
55-
56-
return result;
54+
/*
55+
* We define exit() to call trace2_cmd_exit_fl() in
56+
* git-compat-util.h. Whether we reach this or exit()
57+
* elsewhere we'll always run our trace2 exit handler.
58+
*/
59+
exit(result);
5760
}

t/helper/test-trace2.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,9 @@ static int print_usage(void)
262262
* [] the "cmd_name" event has been generated.
263263
* [] this writes various "def_param" events for interesting config values.
264264
*
265-
* We further assume that if we return (rather than exit()), trace2_cmd_exit()
266-
* will be called by test-tool.c:cmd_main().
265+
* We return from here and let test-tool.c::cmd_main() pass the exit
266+
* code to common-main.c::main(), which will use it to call
267+
* trace2_cmd_exit().
267268
*/
268269
int cmd__trace2(int argc, const char **argv)
269270
{

0 commit comments

Comments
 (0)