Make fio -Wshadow clean
Found a few issues, actually.
Signed-off-by: Jens Axboe <axboe@fb.com>
diff --git a/backend.c b/backend.c
index cae4e38..c0b446a 100644
--- a/backend.c
+++ b/backend.c
@@ -1345,7 +1345,6 @@
/* 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 @@
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 @@
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];
diff --git a/client.c b/client.c
index edc02a0..e9eab81 100644
--- a/client.c
+++ b/client.c
@@ -654,15 +654,13 @@
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;
diff --git a/engines/e4defrag.c b/engines/e4defrag.c
index 6854070..d6113a9 100644
--- a/engines/e4defrag.c
+++ b/engines/e4defrag.c
@@ -98,8 +98,8 @@
}
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 baada7b..db08e2a 100644
--- a/eta.c
+++ b/eta.c
@@ -10,15 +10,15 @@
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 @@
* 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)) {
diff --git a/gettime.c b/gettime.c
index 9f83620..6a7e35f 100644
--- a/gettime.c
+++ b/gettime.c
@@ -531,7 +531,7 @@
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 @@
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 @@
}
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 d815ad9..438ad5d 100644
--- a/io_u.c
+++ b/io_u.c
@@ -206,7 +206,6 @@
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 4a7d939..1ff64e6 100644
--- a/iolog.c
+++ b/iolog.c
@@ -871,18 +871,18 @@
*/
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) {
diff --git a/lib/lfsr.c b/lib/lfsr.c
index 329ef85..9fff50d 100644
--- a/lib/lfsr.c
+++ b/lib/lfsr.c
@@ -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 @@
/*
* 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_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 9e31908..282baa4 100644
--- a/parse.c
+++ b/parse.c
@@ -1081,11 +1081,13 @@
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;
diff --git a/server.c b/server.c
index b5bf878..14eb199 100644
--- a/server.c
+++ b/server.c
@@ -287,14 +287,14 @@
/* 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 @@
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 @@
free(pidfile);
return -1;
} else if (pid) {
- int ret = write_pid(pid, pidfile);
-
+ ret = write_pid(pid, pidfile);
free(pidfile);
_exit(ret);
}
diff --git a/t/btrace2fio.c b/t/btrace2fio.c
index baf29ac..32dda92 100644
--- a/t/btrace2fio.c
+++ b/t/btrace2fio.c
@@ -450,7 +450,7 @@
* 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 @@
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 @@
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)