Output "UNKNOWN" if starttime or endtime is -1.
authorWayne Davison <wayned@samba.org>
Sun, 17 Apr 2016 23:07:25 +0000 (16:07 -0700)
committerWayne Davison <wayned@samba.org>
Sun, 17 Apr 2016 23:11:04 +0000 (16:11 -0700)
Fixes bug 11382.

main.c

diff --git a/main.c b/main.c
index e2b93c6e6ed53ab9d9d28aadd8773dc2006b2c5e..3132aa9a762e7fa82248f5a20848a6cb2c66a0cd 100644 (file)
--- a/main.c
+++ b/main.c
@@ -302,6 +302,13 @@ static void output_itemized_counts(const char *prefix, int *counts)
        rprintf(FINFO, "%s: %s%s\n", prefix, comma_num(total), buf);
 }
 
+static const char *bytes_per_sec_human_dnum(void)
+{
+       if (starttime == (time_t)-1 || endtime == (time_t)-1)
+               return "UNKNOWN";
+       return human_dnum((total_written + total_read) / (0.5 + (endtime - starttime)), 2);
+}
+
 static void output_summary(void)
 {
        if (INFO_GTE(STATS, 2)) {
@@ -342,7 +349,7 @@ static void output_summary(void)
                rprintf(FINFO,
                        "sent %s bytes  received %s bytes  %s bytes/sec\n",
                        human_num(total_written), human_num(total_read),
-                       human_dnum((total_written + total_read)/(0.5 + (endtime - starttime)), 2));
+                       bytes_per_sec_human_dnum());
                rprintf(FINFO, "total size is %s  speedup is %s%s\n",
                        human_num(stats.total_size),
                        comma_dnum((double)stats.total_size / (total_written+total_read), 2),