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 <redacted>
---
common-main.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
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);
}
--
2.34.0.rc2.809.g11e21d44b24