]> git.ipfire.org Git - thirdparty/git.git/commitdiff
progress: make display_progress() return void
authorSZEDER Gábor <szeder.dev@gmail.com>
Fri, 5 Apr 2019 00:45:36 +0000 (02:45 +0200)
committerJunio C Hamano <gitster@pobox.com>
Fri, 5 Apr 2019 06:02:06 +0000 (15:02 +0900)
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>
progress.c
progress.h

index 5a99c9fbf00bfb98d3a51cc7a7948b4e963b3517..901003244674f7b1b34c6cd9eeb76cbc0d06cf28 100644 (file)
@@ -78,12 +78,12 @@ static int is_foreground_fd(int fd)
        return tpgrp < 0 || tpgrp == getpgid(0);
 }
 
-static int display(struct progress *progress, uint64_t n, const char *done)
+static void display(struct progress *progress, uint64_t n, const char *done)
 {
        const char *eol, *tp;
 
        if (progress->delay && (!progress_update || --progress->delay))
-               return 0;
+               return;
 
        progress->last_value = n;
        tp = (progress->throughput) ? progress->throughput->display.buf : "";
@@ -100,7 +100,6 @@ static int display(struct progress *progress, uint64_t n, const char *done)
                                fflush(stderr);
                        }
                        progress_update = 0;
-                       return 1;
                }
        } else if (progress_update) {
                if (is_foreground_fd(fileno(stderr)) || done) {
@@ -109,10 +108,7 @@ static int display(struct progress *progress, uint64_t n, const char *done)
                        fflush(stderr);
                }
                progress_update = 0;
-               return 1;
        }
-
-       return 0;
 }
 
 static void throughput_string(struct strbuf *buf, uint64_t total,
@@ -188,9 +184,10 @@ void display_throughput(struct progress *progress, uint64_t total)
                display(progress, progress->last_value, NULL);
 }
 
-int display_progress(struct progress *progress, uint64_t n)
+void display_progress(struct progress *progress, uint64_t n)
 {
-       return progress ? display(progress, n, NULL) : 0;
+       if (progress)
+               display(progress, n, NULL);
 }
 
 static struct progress *start_progress_delay(const char *title, uint64_t total,
index 70a4d4a0d66ebda2423acf4b5dc84ba485a874b8..59e40cc4fd003ec6037ef11e5f2270bfd28054f0 100644 (file)
@@ -4,7 +4,7 @@
 struct progress;
 
 void display_throughput(struct progress *progress, uint64_t total);
-int display_progress(struct progress *progress, uint64_t n);
+void display_progress(struct progress *progress, uint64_t n);
 struct progress *start_progress(const char *title, uint64_t total);
 struct progress *start_delayed_progress(const char *title, uint64_t total);
 void stop_progress(struct progress **progress);