diff mbox series

[RFC,07/21] common-main.c: call exit(), don't return

Message ID RFC-patch-07.21-3f897bf6b0e-20211115T220831Z-avarab@gmail.com (mailing list archive)
State New, archived
Headers show
Series C99: show meaningful <file>:<line> in trace2 via macros | expand

Commit Message

Ævar Arnfjörð Bjarmason Nov. 15, 2021, 10:18 p.m. UTC
Refactor the main() function so that we always take the same path
towards trace2_cmd_exit() whether exit() is invoked, or we end up in
the "return" in the pre-image. This contains no functional change, and
is only intended for the benefit of readers of the code, who'll now be
pointed to our exit() wrapper.

Since ee4512ed481 (trace2: create new combined trace facility,
2019-02-22) we've defined "exit" with a macro to call
trace2_cmd_exit() for us in "git-compat-util.h". So in cases where an
exit() is invoked (such as in several places in "git.c") we don't
reach the trace2_cmd_exit() in the pre-image. This makes it so that
we'll always take that same exit() path.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 common-main.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/common-main.c b/common-main.c
index 71e21dd20a3..eafc70718a5 100644
--- a/common-main.c
+++ b/common-main.c
@@ -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);
 }