From 761c27292d4add2be17056d8065cad4ff4e87036 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Tue, 23 Sep 2014 16:06:04 -0600 Subject: [PATCH] Fix 32-bit compile warnings Signed-off-by: Jens Axboe --- lib/zipf.c | 2 +- t/btrace2fio.c | 2 +- t/dedupe.c | 8 ++++---- t/lfsr-test.c | 11 ++++++----- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/lib/zipf.c b/lib/zipf.c index e75dc2aa..c691bc51 100644 --- a/lib/zipf.c +++ b/lib/zipf.c @@ -23,7 +23,7 @@ static void zipf_update(struct zipf_state *zs) * 10M max, that should be doable in 1-2s on even slow machines. * Precision will take a slight hit, but nothing major. */ - to_gen = min(zs->nranges, ZIPF_MAX_GEN); + to_gen = min(zs->nranges, (uint64_t) ZIPF_MAX_GEN); for (i = 0; i < to_gen; i++) zs->zetan += pow(1.0 / (double) (i + 1), zs->theta); diff --git a/t/btrace2fio.c b/t/btrace2fio.c index e4e05ca4..5666a560 100644 --- a/t/btrace2fio.c +++ b/t/btrace2fio.c @@ -589,7 +589,7 @@ static void __output_p_ascii(struct btrace_pid *p, unsigned long *ios) perc = ((float) o->merges[i] * 100.0) / (float) total; printf("\tmerges: %lu (perc=%3.2f%%)\n", o->merges[i], perc); perc = ((float) o->seq[i] * 100.0) / (float) o->ios[i]; - printf("\tseq: %lu (perc=%3.2f%%)\n", o->seq[i], perc); + printf("\tseq: %lu (perc=%3.2f%%)\n", (unsigned long) o->seq[i], perc); printf("\trate: %lu KB/sec\n", o_to_kb_rate(o, i)); for (j = 0; j < o->nr_bs[i]; j++) { diff --git a/t/dedupe.c b/t/dedupe.c index d816a093..e51e444e 100644 --- a/t/dedupe.c +++ b/t/dedupe.c @@ -368,7 +368,7 @@ static int dedupe_check(const char *filename) return 1; } - printf("Will check <%s>, size <%lu>\n", filename, dev_size); + printf("Will check <%s>, size <%llu>\n", filename, (unsigned long long) dev_size); return __dedupe_check(dev_fd, dev_size); } @@ -378,10 +378,10 @@ static void show_chunk(struct chunk *c) struct flist_head *n; struct extent *e; - printf("c hash %8x %8x %8x %8x, count %lu\n", c->hash[0], c->hash[1], c->hash[2], c->hash[3], c->count); + printf("c hash %8x %8x %8x %8x, count %lu\n", c->hash[0], c->hash[1], c->hash[2], c->hash[3], (unsigned long) c->count); flist_for_each(n, &c->extent_list) { e = flist_entry(n, struct extent, list); - printf("\toffset %lu\n", e->offset); + printf("\toffset %llu\n", (unsigned long long) e->offset); } } @@ -410,7 +410,7 @@ static void iter_rb_tree(void) } while ((n = rb_next(n)) != NULL); - printf("Extents=%lu, Unique extents=%lu\n", nextents, nchunks); + printf("Extents=%lu, Unique extents=%lu\n", (unsigned long) nextents, (unsigned long) nchunks); printf("De-dupe factor: %3.2f\n", (double) nextents / (double) nchunks); perc = 1.00 - ((double) nchunks / (double) nextents); diff --git a/t/lfsr-test.c b/t/lfsr-test.c index d371087c..481f37e8 100644 --- a/t/lfsr-test.c +++ b/t/lfsr-test.c @@ -65,11 +65,11 @@ int main(int argc, char *argv[]) printf("LFSR specs\n"); printf("==========================\n"); printf("Size is %u\n", 64 - __builtin_clzl(fl->cached_bit)); - printf("Max val is %lu\n", fl->max_val); - printf("XOR-mask is 0x%lX\n", fl->xormask); - printf("Seed is %lu\n", fl->last_val); + printf("Max val is %lu\n", (unsigned long) fl->max_val); + printf("XOR-mask is 0x%lX\n", (unsigned long) fl->xormask); + printf("Seed is %lu\n", (unsigned long) fl->last_val); printf("Spin is %u\n", fl->spin); - printf("Cycle length is %lu\n", fl->cycle_length); + printf("Cycle length is %lu\n", (unsigned long) fl->cycle_length); /* Create verification table */ if (verify) { @@ -102,7 +102,8 @@ int main(int argc, char *argv[]) for (i = 0; i < numbers; i++) { if (*(uint8_t *)(v + i) != 1) { fprintf(stderr, "failed (%lu = %d).\n", - i, *(uint8_t *)(v + i)); + (unsigned long) i, + *(uint8_t *)(v + i)); r = 1; break; } -- 2.25.1