[PATCH] Fix warnings from icc
authorJens Axboe <jens.axboe@oracle.com>
Tue, 5 Dec 2006 10:44:16 +0000 (11:44 +0100)
committerJens Axboe <jens.axboe@oracle.com>
Tue, 5 Dec 2006 10:44:16 +0000 (11:44 +0100)
icc spewed a bunch of warnings on building fio, but it did actually build
and work. Some of them are real bugs, most are just "helpful" warnings.

icc doesn't like pointer arithmetic, however these are not fixed up. It
works as-is, just ignore those class of warnings.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
15 files changed:
Makefile
engines/fio-engine-sg.c
eta.c
filesetup.c
fio.c
fio.h
gettime.c
init.c
io_u.c
log.c
memory.c
parse.c
stat.c
time.c
verify.c

index 71b33c88c9c6adee0acc48f51a5f76af75b511c2..832ed6db536e0b804d8da4b88d654b699bdab0c6 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,6 @@
-CC     = gcc
-CFLAGS = -W -Wwrite-strings -Wall -O2 -g -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
+#CC    = /opt/intel/cce/9.1.045/bin/icc
+CC     = gcc -W
+CFLAGS = -Wwrite-strings -Wall -O2 -g -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
 PROGS  = fio
 SCRIPTS = fio_generate_plots
 OBJS = gettime.o fio.o ioengines.o init.o stat.o log.o time.o md5.o crc32.o \
index 9c5037f5d11fb0391cc25eda994a44366e3297ce..e0748892e1ed216b4a9837e0278cce1a2c98d3b5 100644 (file)
@@ -185,12 +185,12 @@ static int fio_sgio_prep(struct thread_data *td, struct io_u *io_u)
        if (hdr->dxfer_direction != SG_DXFER_NONE) {
                nr_blocks = io_u->buflen / sd->bs;
                lba = io_u->offset / sd->bs;
-               hdr->cmdp[2] = (lba >> 24) & 0xff;
-               hdr->cmdp[3] = (lba >> 16) & 0xff;
-               hdr->cmdp[4] = (lba >>  8) & 0xff;
-               hdr->cmdp[5] = lba & 0xff;
-               hdr->cmdp[7] = (nr_blocks >> 8) & 0xff;
-               hdr->cmdp[8] = nr_blocks & 0xff;
+               hdr->cmdp[2] = (unsigned char) ((lba >> 24) & 0xff);
+               hdr->cmdp[3] = (unsigned char) ((lba >> 16) & 0xff);
+               hdr->cmdp[4] = (unsigned char) ((lba >>  8) & 0xff);
+               hdr->cmdp[5] = (unsigned char) (lba & 0xff);
+               hdr->cmdp[7] = (unsigned char) ((nr_blocks >> 8) & 0xff);
+               hdr->cmdp[8] = (unsigned char) (nr_blocks & 0xff);
        }
 
        return 0;
diff --git a/eta.c b/eta.c
index 99e59ec51d78d4bac7ff45180f16f3ce9407a7d2..5ea429404945bb63a6f63989b4df6bf50757af60 100644 (file)
--- a/eta.c
+++ b/eta.c
@@ -84,15 +84,15 @@ static void eta_to_str(char *str, int eta_sec)
 
        if (d || always_d) {
                always_d = 1;
-               str += sprintf(str, "%02dd:", d);
+               str += sprintf(str, "%02ud:", d);
        }
        if (h || always_h) {
                always_h = 1;
-               str += sprintf(str, "%02dh:", h);
+               str += sprintf(str, "%02uh:", h);
        }
 
-       str += sprintf(str, "%02dm:", m);
-       str += sprintf(str, "%02ds", s);
+       str += sprintf(str, "%02um:", m);
+       str += sprintf(str, "%02us", s);
 }
 
 /*
@@ -101,7 +101,7 @@ static void eta_to_str(char *str, int eta_sec)
 static int thread_eta(struct thread_data *td, unsigned long elapsed)
 {
        unsigned long long bytes_total, bytes_done;
-       unsigned int eta_sec = 0;
+       unsigned long eta_sec = 0;
 
        bytes_total = td->total_io_size;
 
@@ -127,7 +127,7 @@ static int thread_eta(struct thread_data *td, unsigned long elapsed)
                if (perc > 1.0)
                        perc = 1.0;
 
-               eta_sec = (elapsed * (1.0 / perc)) - elapsed;
+               eta_sec = (unsigned long) (elapsed * (1.0 / perc)) - elapsed;
 
                if (td->timeout && eta_sec > (td->timeout - elapsed))
                        eta_sec = td->timeout - elapsed;
index 21854a9739747bb1f5bd16d95e034116d5b7c170..2e8821c5c6d6a36ef0e840d3e9b6161f3ba5eb1f 100644 (file)
@@ -117,7 +117,7 @@ static int create_files(struct thread_data *td)
        }
 
        temp_stall_ts = 1;
-       fprintf(f_out, "%s: Laying out IO file(s) (%d x %LuMiB == %LuMiB)\n",
+       fprintf(f_out, "%s: Laying out IO file(s) (%u x %LuMiB == %LuMiB)\n",
                                td->name, td->nr_uniq_files,
                                (td->total_file_size >> 20) / td->nr_uniq_files,
                                td->total_file_size >> 20);
diff --git a/fio.c b/fio.c
index a4efe385bbb11364638d0b3567842189186e1af3..3ffe1e17a601eebc54debbb1f51580a969b56bc1 100644 (file)
--- a/fio.c
+++ b/fio.c
@@ -105,7 +105,7 @@ static int check_min_rate(struct thread_data *td, struct timeval *now)
 
                rate = (td->this_io_bytes[ddir] - td->rate_bytes) / spent;
                if (rate < td->ratemin) {
-                       fprintf(f_out, "%s: min rate %d not met, got %ldKiB/sec\n", td->name, td->ratemin, rate);
+                       fprintf(f_out, "%s: min rate %u not met, got %luKiB/sec\n", td->name, td->ratemin, rate);
                        return 1;
                }
        }
@@ -242,7 +242,7 @@ static int fio_io_sync(struct thread_data *td, struct fio_file *f)
  * The main verify engine. Runs over the writes we previusly submitted,
  * reads the blocks back in, and checks the crc/md5 of the data.
  */
-void do_verify(struct thread_data *td)
+static void do_verify(struct thread_data *td)
 {
        struct io_u *io_u, *v_io_u = NULL;
        struct io_completion_data icd;
diff --git a/fio.h b/fio.h
index 791b005e49cf429cbaa99be3cadbdb64680c428a..16d5523feb6bf2af4f5f3684010645ceae95ccec 100644 (file)
--- a/fio.h
+++ b/fio.h
 #include "arch.h"
 #include "os.h"
 
+enum fio_ddir {
+       DDIR_READ = 0,
+       DDIR_WRITE,
+       DDIR_SYNC,
+};
+
 struct io_stat {
        unsigned long val;
        unsigned long val_sq;
@@ -29,7 +35,7 @@ struct io_stat {
 struct io_sample {
        unsigned long time;
        unsigned long val;
-       unsigned int ddir;
+       enum fio_ddir ddir;
 };
 
 struct io_log {
@@ -43,7 +49,7 @@ struct io_piece {
        struct fio_file *file;
        unsigned long long offset;
        unsigned int len;
-       int ddir;
+       enum fio_ddir ddir;
 };
 
 /*
@@ -71,7 +77,7 @@ struct io_u {
        unsigned int resid;
        unsigned int error;
 
-       unsigned char ddir;
+       enum fio_ddir ddir;
 
        /*
         * io engine private data
@@ -111,12 +117,6 @@ struct group_run_stats {
        unsigned long long agg[2];
 };
 
-enum fio_ddir {
-       DDIR_READ = 0,
-       DDIR_WRITE,
-       DDIR_SYNC,
-};
-
 /*
  * What type of allocation to use for io buffers
  */
@@ -358,6 +358,7 @@ extern int terse_output;
 extern FILE *f_out;
 extern FILE *f_err;
 extern int temp_stall_ts;
+extern unsigned long long mlock_size;
 
 extern struct thread_data *threads;
 
@@ -437,9 +438,9 @@ extern void write_iolog_close(struct thread_data *);
 /*
  * Logging
  */
-extern void add_clat_sample(struct thread_data *, int, unsigned long);
-extern void add_slat_sample(struct thread_data *, int, unsigned long);
-extern void add_bw_sample(struct thread_data *, int, struct timeval *);
+extern void add_clat_sample(struct thread_data *, enum fio_ddir, unsigned long);
+extern void add_slat_sample(struct thread_data *, enum fio_ddir, unsigned long);
+extern void add_bw_sample(struct thread_data *, enum fio_ddir, struct timeval *);
 extern void show_run_stats(void);
 extern void init_disk_util(struct thread_data *);
 extern void update_rusage_stat(struct thread_data *);
index c691113e9ad85365999d942aff8d99415101be31..161240eeedbbcee0107bfc92a5c1fa7e94954915 100644 (file)
--- a/gettime.c
+++ b/gettime.c
@@ -101,15 +101,17 @@ static void fio_init gtod_init(void)
 
 #endif /* FIO_DEBUG_TIME */
 
+#ifdef FIO_DEBUG_TIME
 void fio_gettime(struct timeval *tp, void *caller)
+#else
+void fio_gettime(struct timeval *tp, void fio_unused *caller)
+#endif
 {
 #ifdef FIO_DEBUG_TIME
        if (!caller)
                caller = __builtin_return_address(0);
 
        gtod_log_caller(caller);
-#else
-       caller = NULL;
 #endif
 repeat:
        if (!clock_gettime_works)
diff --git a/init.c b/init.c
index 36c1839b18767ef3910a44f4fb56333f2562e2c5..346c465a3d9d9a7bb6d5a0311bd6575b8b9a7fd8 100644 (file)
--- a/init.c
+++ b/init.c
@@ -582,7 +582,6 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num)
        if (td->filetype == FIO_TYPE_FILE || td->filename) {
                char tmp[PATH_MAX];
                int len = 0;
-               int i;
 
                if (td->directory && td->directory[0] != '\0')
                        sprintf(tmp, "%s/", td->directory);
@@ -652,7 +651,7 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num)
                                c3 = to_kmg(td->min_bs[DDIR_WRITE]);
                                c4 = to_kmg(td->max_bs[DDIR_WRITE]);
 
-                               fprintf(f_out, "%s: (g=%d): rw=%s, odir=%d, bs=%s-%s/%s-%s, rate=%d, ioengine=%s, iodepth=%d\n", td->name, td->groupid, ddir_str[ddir], td->odirect, c1, c2, c3, c4, td->rate, td->io_ops->name, td->iodepth);
+                               fprintf(f_out, "%s: (g=%d): rw=%s, odir=%u, bs=%s-%s/%s-%s, rate=%u, ioengine=%s, iodepth=%u\n", td->name, td->groupid, ddir_str[ddir], td->odirect, c1, c2, c3, c4, td->rate, td->io_ops->name, td->iodepth);
 
                                free(c1);
                                free(c2);
@@ -787,12 +786,12 @@ static int str_rw_cb(void *data, const char *mem)
                td->sequential = 0;
                return 0;
        } else if (!strncmp(mem, "rw", 2)) {
-               td->ddir = 0;
+               td->ddir = DDIR_READ;
                td->iomix = 1;
                td->sequential = 1;
                return 0;
        } else if (!strncmp(mem, "randrw", 6)) {
-               td->ddir = 0;
+               td->ddir = DDIR_READ;
                td->iomix = 1;
                td->sequential = 0;
                return 0;
@@ -894,7 +893,7 @@ static int str_cpumask_cb(void *data, unsigned int *val)
 /*
  * This is our [ini] type file parser.
  */
-int parse_jobs_ini(char *file, int stonewall_flag)
+static int parse_jobs_ini(char *file, int stonewall_flag)
 {
        unsigned int global;
        struct thread_data *td;
diff --git a/io_u.c b/io_u.c
index 8ec9dd9ecbfdd9b721b7a0b905fdbee9b89c5a84..558b0b072cef200dd140020c47008d29a1a01fcc 100644 (file)
--- a/io_u.c
+++ b/io_u.c
@@ -123,7 +123,7 @@ static unsigned int get_next_buflen(struct thread_data *td, int ddir)
                buflen = td->min_bs[ddir];
        else {
                r = os_random_long(&td->bsrange_state);
-               buflen = (1 + (double) (td->max_bs[ddir] - 1) * r / (RAND_MAX + 1.0));
+               buflen = (unsigned int) (1 + (double) (td->max_bs[ddir] - 1) * r / (RAND_MAX + 1.0));
                if (!td->bs_unaligned)
                        buflen = (buflen + td->min_bs[ddir] - 1) & ~(td->min_bs[ddir] - 1);
        }
@@ -147,7 +147,7 @@ static unsigned int get_next_buflen(struct thread_data *td, int ddir)
  * mixed read/write workload, check the rwmix cycle and switch if
  * necessary.
  */
-static int get_rw_ddir(struct thread_data *td)
+static enum fio_ddir get_rw_ddir(struct thread_data *td)
 {
        if (td_rw(td)) {
                struct timeval now;
@@ -314,7 +314,7 @@ void io_completed(struct thread_data *td, struct io_u *io_u,
 
        if (!io_u->error) {
                unsigned int bytes = io_u->buflen - io_u->resid;
-               const int idx = io_u->ddir;
+               const enum fio_ddir idx = io_u->ddir;
 
                td->io_blocks[idx]++;
                td->io_bytes[idx] += bytes;
diff --git a/log.c b/log.c
index a112a31ac8fa065b23544acdd7fc0883606ef27b..f61215eae73e2b63e3868e713f99bf95eddeb240 100644 (file)
--- a/log.c
+++ b/log.c
@@ -5,7 +5,7 @@
 
 void write_iolog_put(struct thread_data *td, struct io_u *io_u)
 {
-       fprintf(td->iolog_f, "%d,%llu,%u\n", io_u->ddir, io_u->offset, io_u->buflen);
+       fprintf(td->iolog_f, "%u,%llu,%u\n", io_u->ddir, io_u->offset, io_u->buflen);
 }
 
 int read_iolog_get(struct thread_data *td, struct io_u *io_u)
@@ -125,7 +125,7 @@ static int init_iolog_read(struct thread_data *td)
                INIT_LIST_HEAD(&ipo->list);
                ipo->offset = offset;
                ipo->len = bytes;
-               ipo->ddir = rw;
+               ipo->ddir = (enum fio_ddir) rw;
                if (bytes > td->max_bs[rw])
                        td->max_bs[rw] = bytes;
                list_add_tail(&ipo->list, &td->io_log_list);
@@ -180,7 +180,7 @@ int init_iolog(struct thread_data *td)
        else if (td->write_iolog_file)
                ret = init_iolog_write(td);
 
-       return 0;
+       return ret;
 }
 
 int setup_rate(struct thread_data *td)
index d8924a85e0cf6e5a62af17feb638d953f10fbe64..39dc250c52ba052800eeea1ed9815282b427a006 100644 (file)
--- a/memory.c
+++ b/memory.c
@@ -8,7 +8,6 @@
 #include "fio.h"
 #include "os.h"
 
-extern unsigned long long mlock_size;
 static void *pinned_mem;
 
 void fio_unpin_memory(void)
@@ -102,7 +101,7 @@ void free_io_mem(struct thread_data *td)
        } else if (td->mem_type == MEM_MMAP)
                munmap(td->orig_buffer, td->orig_buffer_size);
        else
-               log_err("Bad memory type %d\n", td->mem_type);
+               log_err("Bad memory type %u\n", td->mem_type);
 
        td->orig_buffer = NULL;
 }
diff --git a/parse.c b/parse.c
index 8cd427a9f3ce2b6cf7547ce4822d8da614e7b82e..50d8ae5e5f4fe56ea12ba5ff33ca76fe48e114a4 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -276,7 +276,7 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data,
                break;
        }
        default:
-               fprintf(stderr, "Bad option type %d\n", o->type);
+               fprintf(stderr, "Bad option type %u\n", o->type);
                ret = 1;
        }
 
diff --git a/stat.c b/stat.c
index 731b3036544de363e9db4a82084cce1316203d1e..b4facc7eab4da21a71ff7f343f7e2f264ab9ea40 100644 (file)
--- a/stat.c
+++ b/stat.c
@@ -372,7 +372,7 @@ static void show_thread_status(struct thread_data *td,
 
        runtime = mtime_since(&td->epoch, &td->end_time);
        if (runtime) {
-               double runt = runtime;
+               double runt = (double) runtime;
 
                usr_cpu = (double) td->usr_time * 100 / runt;
                sys_cpu = (double) td->sys_time * 100 / runt;
@@ -429,7 +429,7 @@ static void show_thread_status_terse(struct thread_data *td,
        show_ddir_status_terse(td, rs, 1);
 
        if (td->runtime[0] + td->runtime[1]) {
-               double runt = td->runtime[0] + td->runtime[1];
+               double runt = (double) (td->runtime[0] + td->runtime[1]);
 
                usr_cpu = (double) td->usr_time * 100 / runt;
                sys_cpu = (double) td->sys_time * 100 / runt;
@@ -542,7 +542,7 @@ static inline void add_stat_sample(struct io_stat *is, unsigned long val)
 }
 
 static void add_log_sample(struct thread_data *td, struct io_log *iolog,
-                          unsigned long val, int ddir)
+                          unsigned long val, enum fio_ddir ddir)
 {
        if (iolog->nr_samples == iolog->max_samples) {
                int new_size = sizeof(struct io_sample) * iolog->max_samples*2;
@@ -557,7 +557,8 @@ static void add_log_sample(struct thread_data *td, struct io_log *iolog,
        iolog->nr_samples++;
 }
 
-void add_clat_sample(struct thread_data *td, int ddir, unsigned long msec)
+void add_clat_sample(struct thread_data *td, enum fio_ddir ddir,
+                    unsigned long msec)
 {
        add_stat_sample(&td->clat_stat[ddir], msec);
 
@@ -565,7 +566,8 @@ void add_clat_sample(struct thread_data *td, int ddir, unsigned long msec)
                add_log_sample(td, td->clat_log, msec, ddir);
 }
 
-void add_slat_sample(struct thread_data *td, int ddir, unsigned long msec)
+void add_slat_sample(struct thread_data *td, enum fio_ddir ddir,
+                    unsigned long msec)
 {
        add_stat_sample(&td->slat_stat[ddir], msec);
 
@@ -573,7 +575,8 @@ void add_slat_sample(struct thread_data *td, int ddir, unsigned long msec)
                add_log_sample(td, td->slat_log, msec, ddir);
 }
 
-void add_bw_sample(struct thread_data *td, int ddir, struct timeval *t)
+void add_bw_sample(struct thread_data *td, enum fio_ddir ddir,
+                  struct timeval *t)
 {
        unsigned long spent = mtime_since(&td->stat_sample_time[ddir], t);
        unsigned long rate;
diff --git a/time.c b/time.c
index 6c9eb0a894c951b08b09ad653594a8884fc13bbf..d0ecbe5c831af59f857164af9fa433d96eaceda0 100644 (file)
--- a/time.c
+++ b/time.c
@@ -7,7 +7,7 @@ static struct timeval genesis;
 
 unsigned long utime_since(struct timeval *s, struct timeval *e)
 {
-       double sec, usec;
+       long sec, usec;
 
        sec = e->tv_sec - s->tv_sec;
        usec = e->tv_usec - s->tv_usec;
@@ -31,7 +31,7 @@ unsigned long utime_since_now(struct timeval *s)
 
 unsigned long mtime_since(struct timeval *s, struct timeval *e)
 {
-       double sec, usec;
+       long sec, usec;
 
        sec = e->tv_sec - s->tv_sec;
        usec = e->tv_usec - s->tv_usec;
index 43520bd398992d7292294df13d782917b1e77272..692eb5baeb17161f8d137b539fa0cfa094833e6b 100644 (file)
--- a/verify.c
+++ b/verify.c
@@ -91,7 +91,7 @@ static int verify_io_u(struct io_u *io_u)
        else if (hdr->verify_type == VERIFY_CRC32)
                ret = verify_io_u_crc32(hdr, io_u);
        else {
-               log_err("Bad verify type %d\n", hdr->verify_type);
+               log_err("Bad verify type %u\n", hdr->verify_type);
                ret = 1;
        }