Skip to content

Commit 9219d12

Browse files
szedergitster
authored andcommitted
progress: make display_progress() return void
Ever since the progress infrastructure was introduced in 96a02f8 (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 85cb890 (progress: no progress in background, 2015-04-13). The related display_throughput() function returned void already upon its introduction in cf84d51 (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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent aeb582a commit 9219d12

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

progress.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,12 @@ static int is_foreground_fd(int fd)
7878
return tpgrp < 0 || tpgrp == getpgid(0);
7979
}
8080

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)
8282
{
8383
const char *eol, *tp;
8484

8585
if (progress->delay && (!progress_update || --progress->delay))
86-
return 0;
86+
return;
8787

8888
progress->last_value = n;
8989
tp = (progress->throughput) ? progress->throughput->display.buf : "";
@@ -100,7 +100,6 @@ static int display(struct progress *progress, uint64_t n, const char *done)
100100
fflush(stderr);
101101
}
102102
progress_update = 0;
103-
return 1;
104103
}
105104
} else if (progress_update) {
106105
if (is_foreground_fd(fileno(stderr)) || done) {
@@ -109,10 +108,7 @@ static int display(struct progress *progress, uint64_t n, const char *done)
109108
fflush(stderr);
110109
}
111110
progress_update = 0;
112-
return 1;
113111
}
114-
115-
return 0;
116112
}
117113

118114
static void throughput_string(struct strbuf *buf, uint64_t total,
@@ -188,9 +184,10 @@ void display_throughput(struct progress *progress, uint64_t total)
188184
display(progress, progress->last_value, NULL);
189185
}
190186

191-
int display_progress(struct progress *progress, uint64_t n)
187+
void display_progress(struct progress *progress, uint64_t n)
192188
{
193-
return progress ? display(progress, n, NULL) : 0;
189+
if (progress)
190+
display(progress, n, NULL);
194191
}
195192

196193
static struct progress *start_progress_delay(const char *title, uint64_t total,

progress.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
struct progress;
55

66
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);
88
struct progress *start_progress(const char *title, uint64_t total);
99
struct progress *start_delayed_progress(const char *title, uint64_t total);
1010
void stop_progress(struct progress **progress);

0 commit comments

Comments
 (0)