Skip to content

Commit 1ccad6a

Browse files
avargitster
authored andcommitted
progress.c: use dereferenced "progress" variable, not "(*p_progress)"
Since 98a1364 (trace2: log progress time and throughput, 2020-05-12) stop_progress() dereferences a "struct progress **" parameter in several places. Extract a dereferenced variable to reduce clutter and make it clearer who needs to write to this parameter. Now instead of using "*p_progress" several times in stop_progress() we check it once for NULL and then use a dereferenced "progress" variable thereafter. This uses the same pattern as the adjacent stop_progress_msg() function, see ac900fd (progress: don't dereference before checking for NULL, 2020-08-10). Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a02014b commit 1ccad6a

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

progress.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -319,21 +319,24 @@ static void finish_if_sparse(struct progress *progress)
319319

320320
void stop_progress(struct progress **p_progress)
321321
{
322+
struct progress *progress;
323+
322324
if (!p_progress)
323325
BUG("don't provide NULL to stop_progress");
326+
progress = *p_progress;
324327

325-
finish_if_sparse(*p_progress);
328+
finish_if_sparse(progress);
326329

327-
if (*p_progress) {
330+
if (progress) {
328331
trace2_data_intmax("progress", the_repository, "total_objects",
329-
(*p_progress)->total);
332+
progress->total);
330333

331-
if ((*p_progress)->throughput)
334+
if (progress->throughput)
332335
trace2_data_intmax("progress", the_repository,
333336
"total_bytes",
334-
(*p_progress)->throughput->curr_total);
337+
progress->throughput->curr_total);
335338

336-
trace2_region_leave("progress", (*p_progress)->title, the_repository);
339+
trace2_region_leave("progress", progress->title, the_repository);
337340
}
338341

339342
stop_progress_msg(p_progress, _("done"));

0 commit comments

Comments
 (0)