progress: make display_progress() return void

Ever since the progress infrastructure was introduced in 96a02f8f6d (common progress display support, 2007-04-18), display_progress() has returned an int, telling callers whether it updated the progress bar or not. However, this is: - useless, because over the last dozen years there has never been a single caller that cared about that return value. - not quite true, because it doesn't print a progress bar when running in the background, yet it returns 1; see 85cb8906f0 (progress: no progress in background, 2015-04-13). The related display_throughput() function returned void already upon its introduction in cf84d51c43 (add throughput to progress display, 2007-10-30). Let's make display_progress() return void, too. While doing so several return statements in display() become unnecessary, remove them. Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

SZEDER Gábor committed Apr 5, 2019 at 02:45 UTC 9219d12777baf67e001329cad98fa21c55d46b2e
2 files changed +6 -9
progress.c
+5 -8
@@ -78,12 +78,12 @@ static int is_foreground_fd(int fd)
78 return tpgrp < 0 || tpgrp == getpgid(0);
79 }
80
81 -static int display(struct progress *progress, uint64_t n, const char *done)
81 +static void display(struct progress *progress, uint64_t n, const char *done)
82 {
83 const char *eol, *tp;
84
85 if (progress->delay && (!progress_update || --progress->delay))
86 - return 0;
86 + return;
87
88 progress->last_value = n;
89 tp = (progress->throughput) ? progress->throughput->display.buf : "";
@@ -100,7 +100,6 @@ static int display(struct progress *progress, uint64_t n, const char *done)
100 fflush(stderr);
101 }
102 progress_update = 0;
103 - return 1;
103 }
104 } else if (progress_update) {
105 if (is_foreground_fd(fileno(stderr)) || done) {
@@ -109,10 +108,7 @@ static int display(struct progress *progress, uint64_t n, const char *done)
108 fflush(stderr);
109 }
110 progress_update = 0;
112 - return 1;
111 }
114 -
115 - return 0;
112 }
113
114 static void throughput_string(struct strbuf *buf, uint64_t total,
@@ -188,9 +184,10 @@ void display_throughput(struct progress *progress, uint64_t total)
184 display(progress, progress->last_value, NULL);
185 }
186
191 -int display_progress(struct progress *progress, uint64_t n)
187 +void display_progress(struct progress *progress, uint64_t n)
188 {
193 - return progress ? display(progress, n, NULL) : 0;
189 + if (progress)
190 + display(progress, n, NULL);
191 }
192
193 static struct progress *start_progress_delay(const char *title, uint64_t total,
progress.h
+1 -1
@@ -4,7 +4,7 @@
4 struct progress;
5
6 void display_throughput(struct progress *progress, uint64_t total);
7 -int display_progress(struct progress *progress, uint64_t n);
7 +void display_progress(struct progress *progress, uint64_t n);
8 struct progress *start_progress(const char *title, uint64_t total);
9 struct progress *start_delayed_progress(const char *title, uint64_t total);
10 void stop_progress(struct progress **progress);