Make fio -Wshadow clean
authorJens Axboe <axboe@fb.com>
Thu, 6 Nov 2014 16:21:10 +0000 (09:21 -0700)
committerJens Axboe <axboe@fb.com>
Thu, 6 Nov 2014 16:21:10 +0000 (09:21 -0700)
Found a few issues, actually.

Signed-off-by: Jens Axboe <axboe@fb.com>
backend.c
client.c
engines/e4defrag.c
eta.c
gettime.c
io_u.c
iolog.c
lib/lfsr.c
parse.c
server.c
t/btrace2fio.c

index cae4e38de4b9fb3adc871863558dd1230bba32b2..c0b446ac8d98d706fdb042e64e51715343c79f73 100644 (file)
--- a/backend.c
+++ b/backend.c
@@ -1345,7 +1345,6 @@ static void *thread_main(void *data)
        /* numa node setup */
        if (o->numa_cpumask_set || o->numa_memmask_set) {
                struct bitmask *mask;
-               int ret;
 
                if (numa_available() < 0) {
                        td_verror(td, errno, "Does not support NUMA API\n");
@@ -1554,9 +1553,9 @@ err:
        cgroup_shutdown(td, &cgroup_mnt);
 
        if (o->cpumask_set) {
-               int ret = fio_cpuset_exit(&o->cpumask);
-
-               td_verror(td, ret, "fio_cpuset_exit");
+               ret = fio_cpuset_exit(&o->cpumask);
+               if (ret)
+                       td_verror(td, ret, "fio_cpuset_exit");
        }
 
        /*
@@ -2092,8 +2091,6 @@ int fio_backend(void)
        if (!fio_abort) {
                __show_run_stats();
                if (write_bw_log) {
-                       int i;
-
                        for (i = 0; i < DDIR_RWDIR_CNT; i++) {
                                struct io_log *log = agg_io_log[i];
 
index edc02a0a13416c04fbb546bf2c05799a440bbf84..e9eab8152ce4995adb8fe7d6932d0943d0295235 100644 (file)
--- a/client.c
+++ b/client.c
@@ -654,15 +654,13 @@ static int __fio_client_send_local_ini(struct fio_client *client,
 
        fd = open(filename, O_RDONLY);
        if (fd < 0) {
-               int ret = -errno;
-
+               ret = -errno;
                log_err("fio: job file <%s> open: %s\n", filename, strerror(errno));
                return ret;
        }
 
        if (fstat(fd, &sb) < 0) {
-               int ret = -errno;
-
+               ret = -errno;
                log_err("fio: job file stat: %s\n", strerror(errno));
                close(fd);
                return ret;
index 6854070932a4d065a3989840b9b758cd4a0a494f..d6113a97ee9b6565dbdf8e5dc0381491bf6b61a4 100644 (file)
@@ -98,8 +98,8 @@ static int fio_e4defrag_init(struct thread_data *td)
        }
 
        if (!o->inplace) {
-               long long len = td->o.file_size_high - td->o.start_offset;
-               r = fallocate(ed->donor_fd, 0, td->o.start_offset, len);
+               long long __len = td->o.file_size_high - td->o.start_offset;
+               r = fallocate(ed->donor_fd, 0, td->o.start_offset, __len);
                if (r)
                        goto err;
        }
diff --git a/eta.c b/eta.c
index baada7bc48ad51604978d7cffc6051115325239e..db08e2abe2e43e79b2da6447157e166b1041d29a 100644 (file)
--- a/eta.c
+++ b/eta.c
 static char __run_str[REAL_MAX_JOBS + 1];
 static char run_str[__THREAD_RUNSTR_SZ(REAL_MAX_JOBS)];
 
-static void update_condensed_str(char *run_str, char *run_str_condensed)
+static void update_condensed_str(char *rstr, char *run_str_condensed)
 {
-       if (*run_str) {
-               while (*run_str) {
+       if (*rstr) {
+               while (*rstr) {
                        int nr = 1;
 
-                       *run_str_condensed++ = *run_str++;
-                       while (*(run_str - 1) == *run_str) {
-                               run_str++;
+                       *run_str_condensed++ = *rstr++;
+                       while (*(rstr - 1) == *rstr) {
+                               rstr++;
                                nr++;
                        }
                        run_str_condensed += sprintf(run_str_condensed, "(%u),", nr);
@@ -234,11 +234,11 @@ static int thread_eta(struct thread_data *td)
                 * if given, otherwise assume it'll run at the specified rate.
                 */
                if (td->o.timeout) {
-                       uint64_t timeout = td->o.timeout;
+                       uint64_t __timeout = td->o.timeout;
                        uint64_t start_delay = td->o.start_delay;
                        uint64_t ramp_time = td->o.ramp_time;
 
-                       t_eta = timeout + start_delay + ramp_time;
+                       t_eta = __timeout + start_delay + ramp_time;
                        t_eta /= 1000000ULL;
 
                        if (in_ramp_time(td)) {
index 9f8362090095c2d679c2b568274649d931aa8942..6a7e35f87249905c044165bfe1869f4ac0605e99 100644 (file)
--- a/gettime.c
+++ b/gettime.c
@@ -531,7 +531,7 @@ static int clock_cmp(const void *p1, const void *p2)
 
 int fio_monotonic_clocktest(void)
 {
-       struct clock_thread *threads;
+       struct clock_thread *cthreads;
        unsigned int nr_cpus = cpus_online();
        struct clock_entry *entries;
        unsigned long tentries, failed = 0;
@@ -549,14 +549,14 @@ int fio_monotonic_clocktest(void)
        fio_debug &= ~(1U << FD_TIME);
 #endif
 
-       threads = malloc(nr_cpus * sizeof(struct clock_thread));
+       cthreads = malloc(nr_cpus * sizeof(struct clock_thread));
        tentries = CLOCK_ENTRIES * nr_cpus;
        entries = malloc(tentries * sizeof(struct clock_entry));
 
        log_info("cs: Testing %u CPUs\n", nr_cpus);
 
        for (i = 0; i < nr_cpus; i++) {
-               struct clock_thread *t = &threads[i];
+               struct clock_thread *t = &cthreads[i];
 
                t->cpu = i;
                t->seq = &seq;
@@ -572,26 +572,26 @@ int fio_monotonic_clocktest(void)
        }
 
        for (i = 0; i < nr_cpus; i++) {
-               struct clock_thread *t = &threads[i];
+               struct clock_thread *t = &cthreads[i];
 
                pthread_mutex_lock(&t->started);
        }
 
        for (i = 0; i < nr_cpus; i++) {
-               struct clock_thread *t = &threads[i];
+               struct clock_thread *t = &cthreads[i];
 
                pthread_mutex_unlock(&t->lock);
        }
 
        for (i = 0; i < nr_cpus; i++) {
-               struct clock_thread *t = &threads[i];
+               struct clock_thread *t = &cthreads[i];
                void *ret;
 
                pthread_join(t->thread, &ret);
                if (ret)
                        failed++;
        }
-       free(threads);
+       free(cthreads);
 
        if (failed) {
                log_err("Clocksource test: %lu threads failed\n", failed);
diff --git a/io_u.c b/io_u.c
index d815ad9a340a63aaee1c0de05c402adec129835e..438ad5df26dc32aa411202216172543a6208b4fc 100644 (file)
--- a/io_u.c
+++ b/io_u.c
@@ -206,7 +206,6 @@ static int get_next_rand_offset(struct thread_data *td, struct fio_file *f,
                return get_off_from_method(td, f, ddir, b);
 
        if (!flist_empty(&td->next_rand_list)) {
-               struct rand_off *r;
 fetch:
                r = flist_first_entry(&td->next_rand_list, struct rand_off, list);
                flist_del(&r->list);
diff --git a/iolog.c b/iolog.c
index 4a7d939af251c77ae2de82d2ad57b15a9f04d4b4..1ff64e6384c1accb6a3abf538734dfff85e5733e 100644 (file)
--- a/iolog.c
+++ b/iolog.c
@@ -871,18 +871,18 @@ int iolog_file_inflate(const char *file)
         */
        total = ic.len;
        do {
-               size_t ret;
+               size_t iret;
 
-               ret = inflate_chunk(&ic,  1, stdout, &stream, &iter);
-               total -= ret;
+               iret = inflate_chunk(&ic,  1, stdout, &stream, &iter);
+               total -= iret;
                if (!total)
                        break;
                if (iter.err)
                        break;
 
                ic.seq++;
-               ic.len -= ret;
-               ic.buf += ret;
+               ic.len -= iret;
+               ic.buf += iret;
        } while (1);
 
        if (iter.seq) {
index 329ef85a8bf7a4e9529838c201482ee0eab78641..9fff50d77fe83d5a32afacbf67876e09ca5705fe 100644 (file)
@@ -11,7 +11,7 @@
  * The memory overhead of the following tap table should be relatively small,
  * no more than 400 bytes.
  */
-static uint8_t taps[64][FIO_MAX_TAPS] =
+static uint8_t lfsr_taps[64][FIO_MAX_TAPS] =
 {
        {0}, {0}, {0},          //LFSRs with less that 3-bits cannot exist
        {3, 2},                 //Tap position for 3-bit LFSR
@@ -158,12 +158,12 @@ static uint8_t *find_lfsr(uint64_t size)
 
        /*
         * For an LFSR, there is always a prohibited state (all ones).
-        * Thus, if we need to find the proper LFSR for our size, we must take that
-        * into account.
+        * Thus, if we need to find the proper LFSR for our size, we must
+        * take that into account.
         */
        for (i = 3; i < 64; i++)
                if ((1UL << i) > size)
-                       return taps[i];
+                       return lfsr_taps[i];
 
        return NULL;
 }
@@ -234,15 +234,15 @@ int lfsr_reset(struct fio_lfsr *fl, unsigned long seed)
 int lfsr_init(struct fio_lfsr *fl, uint64_t nums, unsigned long seed,
                unsigned int spin)
 {
-       uint8_t *lfsr_taps;
+       uint8_t *taps;
 
-       lfsr_taps = find_lfsr(nums);
-       if (!lfsr_taps)
+       taps = find_lfsr(nums);
+       if (!taps)
                return 1;
 
        fl->max_val = nums - 1;
-       fl->xormask = lfsr_create_xormask(lfsr_taps);
-       fl->cached_bit = 1UL << (lfsr_taps[0] - 1);
+       fl->xormask = lfsr_create_xormask(taps);
+       fl->cached_bit = 1UL << (taps[0] - 1);
 
        if (prepare_spin(fl, spin))
                return 1;
diff --git a/parse.c b/parse.c
index 9e31908aebf41bf17ba69fbcfb68947839099cd7..282baa4c154554b7f537e25f0d723a70dc4df6ea 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -1081,11 +1081,13 @@ static int string_distance(const char *s1, const char *s2)
                q[0] = p[0] + 1;
                for (j = 1; j <= s2_len; j++) {
                        unsigned int sub = p[j - 1];
+                       unsigned int pmin;
 
                        if (s1[i - 1] != s2[j - 1])
                                sub++;
 
-                       q[j] = min(p[j] + 1, min(q[j - 1] + 1, sub));
+                       pmin = min(q[j - 1] + 1, sub);
+                       q[j] = min(p[j] + 1, pmin);
                }
                r = p;
                p = q;
index b5bf8780743b0923a590d624602e8784ac5b53f0..14eb199ccd3a6b4fb6c3cee252a870eff76cd9d3 100644 (file)
--- a/server.c
+++ b/server.c
@@ -287,14 +287,14 @@ struct fio_net_cmd *fio_net_recv_cmd(int sk)
                /* zero-terminate text input */
                if (cmdret->pdu_len) {
                        if (cmdret->opcode == FIO_NET_CMD_TEXT) {
-                               struct cmd_text_pdu *pdu = (struct cmd_text_pdu *) cmdret->payload;
-                               char *buf = (char *) pdu->buf;
+                               struct cmd_text_pdu *__pdu = (struct cmd_text_pdu *) cmdret->payload;
+                               char *buf = (char *) __pdu->buf;
 
-                               buf[pdu->buf_len] = '\0';
+                               buf[__pdu->buf_len] = '\0';
                        } else if (cmdret->opcode == FIO_NET_CMD_JOB) {
-                               struct cmd_job_pdu *pdu = (struct cmd_job_pdu *) cmdret->payload;
-                               char *buf = (char *) pdu->buf;
-                               int len = le32_to_cpu(pdu->buf_len);
+                               struct cmd_job_pdu *__pdu = (struct cmd_job_pdu *) cmdret->payload;
+                               char *buf = (char *) __pdu->buf;
+                               int len = le32_to_cpu(__pdu->buf_len);
 
                                buf[len] = '\0';
                        }
@@ -1209,7 +1209,6 @@ static int fio_send_iolog_gz(struct cmd_iolog_pdu *pdu, struct io_log *log)
 
        do {
                unsigned int this_len, flags = 0;
-               int ret;
 
                stream.avail_out = FIO_SERVER_MAX_FRAGMENT_PDU;
                stream.next_out = out_pdu;
@@ -1734,8 +1733,7 @@ int fio_start_server(char *pidfile)
                free(pidfile);
                return -1;
        } else if (pid) {
-               int ret = write_pid(pid, pidfile);
-
+               ret = write_pid(pid, pidfile);
                free(pidfile);
                _exit(ret);
        }
index baf29acb9d41a9434ec028f8212f8842f6ff7972..32dda92e858be105a4fc641c961600901f8c499c 100644 (file)
@@ -450,7 +450,7 @@ static struct btrace_pid *pid_hash_get(pid_t pid)
  * Load a blktrace file by reading all the blk_io_trace entries, and storing
  * them as io_pieces like the fio text version would do.
  */
-static int load_blktrace(const char *filename, int need_swap)
+static int load_blktrace(const char *fname, int need_swap)
 {
        struct btrace_pid *p;
        unsigned long traces;
@@ -458,7 +458,7 @@ static int load_blktrace(const char *filename, int need_swap)
        struct fifo *fifo;
        int fd, ret = 0;
 
-       fd = open(filename, O_RDONLY);
+       fd = open(fname, O_RDONLY);
        if (fd < 0) {
                perror("open trace file\n");
                return 1;
@@ -468,8 +468,7 @@ static int load_blktrace(const char *filename, int need_swap)
 
        traces = 0;
        do {
-               int ret = trace_fifo_get(fifo, fd, &t, sizeof(t));
-
+               ret = trace_fifo_get(fifo, fd, &t, sizeof(t));
                if (ret < 0)
                        goto err;
                else if (!ret)