progress: call trace2_region_leave() only after calling _enter()
A user of progress API calls start_progress() conditionally and depends on the display_progress() and stop_progress() functions to become no-op when start_progress() hasn't been called. As we added a call to trace2_region_enter() to start_progress(), the calls to other trace2 API calls from the progress API functions must make sure that these trace2 calls are skipped when start_progress() hasn't been called on the progress struct. Specifically, do not call trace2_region_leave() from stop_progress() when we haven't called start_progress(), which would have called the matching trace2_region_enter(). Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Derrick Stolee committed
May 15, 2020 at 09:09 UTC
3af029c484fc72f546078966af538db55933e83d
1 file changed
+2
-6
progress.c
+2
-6
@@ -329,13 +329,9 @@ void stop_progress(struct progress **p_progress)
329
trace2_data_intmax("progress", the_repository,
330
"total_bytes",
331
(*p_progress)->throughput->curr_total);
332
- }
332
334
- trace2_region_leave("progress",
335
- p_progress && *p_progress
336
- ? (*p_progress)->title
337
- : NULL,
338
- the_repository);
333
+ trace2_region_leave("progress", (*p_progress)->title, the_repository);
334
+ }
335
336
stop_progress_msg(p_progress, _("done"));
337
}