Cleanup the percentile output formatting
authorJens Axboe <axboe@kernel.dk>
Wed, 6 Feb 2013 07:46:55 +0000 (08:46 +0100)
committerJens Axboe <axboe@kernel.dk>
Wed, 6 Feb 2013 07:46:55 +0000 (08:46 +0100)
Signed-off-by: Jens Axboe <axboe@kernel.dk>
parse.c
stat.c

diff --git a/parse.c b/parse.c
index 15aeb0acd3a5a96741360a0560dd2c630819871f..12a35bdc0ef57f550adf8f208a1c542572aaccf6 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -521,7 +521,7 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data,
                                        o->maxlen);
                        return 1;
                }
-               if (!str_to_float(ptr, &uf)){
+               if (!str_to_float(ptr, &uf)) {
                        log_err("not a floating point value: %s\n", ptr);
                        return 1;
                }
diff --git a/stat.c b/stat.c
index c523f5c25a605759b055868e07d07d52a5a118fe..8bcd566e0b93c6b162b3ed0020f3ecaead4e18ea 100644 (file)
--- a/stat.c
+++ b/stat.c
@@ -187,7 +187,7 @@ static void show_clat_percentiles(unsigned int *io_u_plat, unsigned long nr,
        unsigned int len, j = 0, minv, maxv;
        unsigned int *ovals;
        int is_last, scale_down;
-       char buf1[32], buf2[32];
+       char buf[32];
 
        len = calc_clat_percentiles(io_u_plat, nr, plist, &ovals, &maxv, &minv);
        if (!len)
@@ -205,10 +205,10 @@ static void show_clat_percentiles(unsigned int *io_u_plat, unsigned long nr,
                log_info("    clat percentiles (usec):\n     |");
        }
 
-       snprintf(buf1, sizeof(buf1), " %%1.%luf", precision);
-       snprintf(buf2, sizeof(buf1), "%%1.%luf", precision);
+       snprintf(buf, sizeof(buf), "%%1.%luf", precision);
+
        for (j = 0; j < len; j++) {
-               char fbuf[16];
+               char fbuf[16], *ptr = fbuf;
 
                /* for formatting */
                if (j != 0 && (j % 4) == 0)
@@ -218,9 +218,9 @@ static void show_clat_percentiles(unsigned int *io_u_plat, unsigned long nr,
                is_last = (j == len - 1);
 
                if (plist[j].u.f < 10.0)
-                       snprintf(fbuf, sizeof(fbuf), buf1, plist[j].u.f);
-               else
-                       snprintf(fbuf, sizeof(fbuf), buf2, plist[j].u.f);
+                       ptr += sprintf(fbuf, " ");
+
+               snprintf(ptr, sizeof(fbuf), buf, plist[j].u.f);
 
                if (scale_down)
                        ovals[j] = (ovals[j] + 999) / 1000;