[PATCH] Fix warnings from icc

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>
diff --git a/Makefile b/Makefile
index 71b33c8..832ed6d 100644
--- 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 \
diff --git a/engines/fio-engine-sg.c b/engines/fio-engine-sg.c
index 9c5037f..e074889 100644
--- a/engines/fio-engine-sg.c
+++ b/engines/fio-engine-sg.c
@@ -185,12 +185,12 @@
 	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 99e59ec..5ea4294 100644
--- a/eta.c
+++ b/eta.c
@@ -84,15 +84,15 @@
 
 	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 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 @@
 		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;
diff --git a/filesetup.c b/filesetup.c
index 21854a9..2e8821c 100644
--- a/filesetup.c
+++ b/filesetup.c
@@ -117,7 +117,7 @@
 	}
 
 	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 a4efe38..3ffe1e1 100644
--- a/fio.c
+++ b/fio.c
@@ -105,7 +105,7 @@
 
 		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 @@
  * 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 791b005..16d5523 100644
--- a/fio.h
+++ b/fio.h
@@ -18,6 +18,12 @@
 #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_sample {
 	unsigned long time;
 	unsigned long val;
-	unsigned int ddir;
+	enum fio_ddir ddir;
 };
 
 struct io_log {
@@ -43,7 +49,7 @@
 	struct fio_file *file;
 	unsigned long long offset;
 	unsigned int len;
-	int ddir;
+	enum fio_ddir ddir;
 };
 
 /*
@@ -71,7 +77,7 @@
 	unsigned int resid;
 	unsigned int error;
 
-	unsigned char ddir;
+	enum fio_ddir ddir;
 
 	/*
 	 * io engine private data
@@ -111,12 +117,6 @@
 	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 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 @@
 /*
  * 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 *);
diff --git a/gettime.c b/gettime.c
index c691113..161240e 100644
--- a/gettime.c
+++ b/gettime.c
@@ -101,15 +101,17 @@
 
 #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 36c1839..346c465 100644
--- a/init.c
+++ b/init.c
@@ -582,7 +582,6 @@
 	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 @@
 				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 @@
 		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 @@
 /*
  * 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 8ec9dd9..558b0b0 100644
--- a/io_u.c
+++ b/io_u.c
@@ -123,7 +123,7 @@
 		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 @@
  * 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 @@
 
 	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 a112a31..f61215e 100644
--- 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 @@
 		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 @@
 	else if (td->write_iolog_file)
 		ret = init_iolog_write(td);
 
-	return 0;
+	return ret;
 }
 
 int setup_rate(struct thread_data *td)
diff --git a/memory.c b/memory.c
index d8924a8..39dc250 100644
--- 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 @@
 	} 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 8cd427a..50d8ae5 100644
--- a/parse.c
+++ b/parse.c
@@ -276,7 +276,7 @@
 		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 731b303..b4facc7 100644
--- a/stat.c
+++ b/stat.c
@@ -372,7 +372,7 @@
 
 	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 @@
 	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 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 @@
 	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 @@
 		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 @@
 		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 6c9eb0a..d0ecbe5 100644
--- a/time.c
+++ b/time.c
@@ -7,7 +7,7 @@
 
 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 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;
diff --git a/verify.c b/verify.c
index 43520bd..692eb5b 100644
--- a/verify.c
+++ b/verify.c
@@ -91,7 +91,7 @@
 	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;
 	}