core: Removing duplicated code
authorErwan Velu <erwan@enovance.com>
Mon, 22 Jul 2013 21:39:18 +0000 (23:39 +0200)
committerErwan Velu <erwan@enovance.com>
Mon, 22 Jul 2013 21:39:18 +0000 (23:39 +0200)
Some variable are assigned during initialization and another time with
the same value a very few later.

That's clearly useless and could lead to an error if only one is changed.

init.c
stat.c

diff --git a/init.c b/init.c
index 70b56e38f21b5dab4c1789234d3ee226acabaed5..d808eb679a5c31eb1c89897c21fa894216f6ab01 100644 (file)
--- a/init.c
+++ b/init.c
@@ -1755,8 +1755,6 @@ int parse_cmd_line(int argc, char *argv[], int client_type)
                case FIO_GETOPT_IOENGINE: {
                        const char *opt = l_opts[lidx].name;
                        char *val = optarg;
                case FIO_GETOPT_IOENGINE: {
                        const char *opt = l_opts[lidx].name;
                        char *val = optarg;
-                       opt = l_opts[lidx].name;
-                       val = optarg;
                        ret = fio_cmd_ioengine_option_parse(td, opt, val);
                        break;
                }
                        ret = fio_cmd_ioengine_option_parse(td, opt, val);
                        break;
                }
diff --git a/stat.c b/stat.c
index 332ccd0f55c3072e1d9732546e055e1ecbed5f0e..442caa0cd1973400d5323a7202b6350155a6ae1d 100644 (file)
--- a/stat.c
+++ b/stat.c
@@ -243,15 +243,13 @@ out:
 int calc_lat(struct io_stat *is, unsigned long *min, unsigned long *max,
             double *mean, double *dev)
 {
 int calc_lat(struct io_stat *is, unsigned long *min, unsigned long *max,
             double *mean, double *dev)
 {
-       double n = is->samples;
+       double n = (double) is->samples;
 
 
-       if (is->samples == 0)
+       if (n == 0)
                return 0;
 
        *min = is->min_val;
        *max = is->max_val;
                return 0;
 
        *min = is->min_val;
        *max = is->max_val;
-
-       n = (double) is->samples;
        *mean = is->mean.u.f;
 
        if (n > 1.0)
        *mean = is->mean.u.f;
 
        if (n > 1.0)