filehash: check for NULL ->file_name in hash lookup
[fio.git] / eta.c
diff --git a/eta.c b/eta.c
index bac3ddfdd05c287e814fbf789cbc49e6d80edcc5..766f6509dfe2e3254c97d602e37c5119694a7878 100644 (file)
--- a/eta.c
+++ b/eta.c
@@ -66,13 +66,11 @@ static void check_str_update(struct thread_data *td)
 /*
  * Convert seconds to a printable string.
  */
-static void eta_to_str(char *str, int eta_sec)
+static void eta_to_str(char *str, unsigned long eta_sec)
 {
        unsigned int d, h, m, s;
        int disp_hour = 0;
 
-       d = h = m = s = 0;
-
        s = eta_sec % 60;
        eta_sec /= 60;
        m = eta_sec % 60;
@@ -199,6 +197,7 @@ void print_thread_status(void)
        static struct timeval rate_prev_time, disp_prev_time;
        static unsigned int rate[2];
        static int linelen_last;
+       static int eta_good;
 
        if (temp_stall_ts || terse_output || eta_print == FIO_ETA_NEVER)
                return;
@@ -285,11 +284,19 @@ void print_thread_status(void)
        else if (m_iops || t_iops)
                printf(", CR=%d/%d IOPS", t_iops, m_iops);
        if (eta_sec != INT_MAX && nr_running) {
+               char perc_str[32];
                int ll;
 
-               perc *= 100.0;
-               ll = printf(": [%s] [%3.1f%% done] [%6u/%6u kb/s] [eta %s]",
-                                run_str, perc, rate[0], rate[1], eta_str);
+               if (!eta_sec && !eta_good)
+                       strcpy(perc_str, "-.-% done");
+               else {
+                       eta_good = 1;
+                       perc *= 100.0;
+                       sprintf(perc_str, "%3.1f%% done", perc);
+               }
+
+               ll = printf(": [%s] [%s] [%6u/%6u kb/s] [eta %s]",
+                                run_str, perc_str, rate[0], rate[1], eta_str);
                if (ll >= 0 && ll < linelen_last)
                        printf("%*s", linelen_last - ll, "");
                linelen_last = ll;