From 04edf60421b2eb0818f4e9cef89f6ca5cbc647a0 Mon Sep 17 00:00:00 2001 From: Dominik Bruhn Date: Mon, 23 Apr 2012 15:33:50 +0200 Subject: [PATCH] Changed to correct 64bit format-strings. Most of the format-strings for uint64_t were wrong. %llu is architecture dependant whereas uint64_t is always 64bit long. The PRIu64 macro (from inttypes.h) provides the correct formatstring. --- ffsb_fs.c | 16 ++++++++-------- ffsb_fs.h | 2 +- ffsb_op.c | 2 +- ffsb_tg.c | 4 ++-- fh.c | 6 +++--- fileops.c | 6 +++--- util.c | 4 ++-- 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/ffsb_fs.c b/ffsb_fs.c index 94b80c1..89c2c2c 100644 --- a/ffsb_fs.c +++ b/ffsb_fs.c @@ -214,7 +214,7 @@ static int verify_file(struct benchfiles *bf, char *fname, void *fs_ptr) filesize = ffsb_get_filesize(fname); if (filesize < minsize || filesize > maxsize) { - printf("size %llu bytes for file %s is invalid\n", + printf("size %"PRIu64" bytes for file %s is invalid\n", filesize, fname); return 1; } @@ -592,7 +592,7 @@ void fs_print_config(ffsb_fs_t *fs) int i; printf("\t Fileset weight:\n"); for (i = 0; i < fs->num_weights; i++) - printf("\t\t %12llu (%6s) -> %u (%.2f\%)\n", + printf("\t\t %12"PRIu64" (%6s) -> %u (%.2f%%)\n", fs->size_weights[i].size, ffsb_printsize(buf, fs->size_weights[i].size, 256), fs->size_weights[i].weight, @@ -600,9 +600,9 @@ void fs_print_config(ffsb_fs_t *fs) (float)fs->sum_weights) * 100); } else { - printf("\t min file size = %llu\t(%s)\n", fs->minfilesize, + printf("\t min file size = %"PRIu64"\t(%s)\n", fs->minfilesize, ffsb_printsize(buf, fs->minfilesize, 256)); - printf("\t max file size = %llu\t(%s)\n", fs->maxfilesize, + printf("\t max file size = %"PRIu64"\t(%s)\n", fs->maxfilesize, ffsb_printsize(buf, fs->maxfilesize, 256)); } printf("\t directio = %s\n", (fs->flags & FFSB_FS_DIRECTIO) ? @@ -613,18 +613,18 @@ void fs_print_config(ffsb_fs_t *fs) "on" : "off"); printf("\t\n"); printf("\t aging is %s\n", (fs->age_fs) ? "on" : "off"); - printf("\t current utilization = %.2f\%\n", getfsutil(fs->basedir)*100); + printf("\t current utilization = %.2f%%\n", getfsutil(fs->basedir)*100); if (fs->age_fs) { - printf("\t desired utilization = %.2lf%\n", fs->desired_fsutil * 100); + printf("\t desired utilization = %.2lf%%\n", fs->desired_fsutil * 100); printf("\t \n"); tg_print_config_aging(fs->aging_tg, fs->basedir); } printf("\t\n"); } -int fs_needs_stats(ffsb_fs_t *fs, syscall_t sys) +intptr_t fs_needs_stats(ffsb_fs_t *fs, syscall_t sys) { - return (fs != NULL) ? (int)fs->fsd.config : 0; + return (fs != NULL) ? (intptr_t)(fs->fsd.config) : 0; } void fs_add_stat(ffsb_fs_t *fs, syscall_t sys, uint32_t val) diff --git a/ffsb_fs.h b/ffsb_fs.h index 7b38104..def300e 100644 --- a/ffsb_fs.h +++ b/ffsb_fs.h @@ -178,7 +178,7 @@ uint32_t fs_get_numdirs(ffsb_fs_t *fs); double fs_get_desired_fsutil(ffsb_fs_t *fs); /* For these two, fs == NULL is OK */ -int fs_needs_stats(ffsb_fs_t *fs, syscall_t s); +intptr_t fs_needs_stats(ffsb_fs_t *fs, syscall_t s); void fs_add_stat(ffsb_fs_t *fs, syscall_t sys, uint32_t val); #endif /* _FFSB_FS_H_ */ diff --git a/ffsb_op.c b/ffsb_op.c index 0cae599..588c934 100644 --- a/ffsb_op.c +++ b/ffsb_op.c @@ -109,7 +109,7 @@ void print_results(struct ffsb_op_results *results, double runtime) total_weight += results->op_weight[i]; } - printf(" Op Name Transactions\t Trans/sec\t% Trans\t % Op Weight\t Throughput\n"); + printf(" Op Name Transactions\t Trans/sec\t%% Trans\t %% Op Weight\t Throughput\n"); printf(" ======= ============\t =========\t=======\t ===========\t ==========\n"); for (i = 0; i < FFSB_NUMOPS ; i++) if (results->ops[i] != 0) diff --git a/ffsb_tg.c b/ffsb_tg.c index 908e89c..f63a735 100644 --- a/ffsb_tg.c +++ b/ffsb_tg.c @@ -271,7 +271,7 @@ static void tg_print_config_helper(ffsb_tg_t *tg) printf("\t num_threads = %d\n", tg->num_threads); printf("\t\n"); printf("\t read_random = %s\n", (tg->read_random) ? "on" : "off"); - printf("\t read_size = %llu\t(%s)\n", tg->read_size, + printf("\t read_size = %"PRIu64"\t(%s)\n", tg->read_size, ffsb_printsize(buf, tg->read_size, 256)); printf("\t read_blocksize = %u\t(%s)\n", tg->read_blocksize, ffsb_printsize(buf, tg->read_blocksize, 256)); @@ -280,7 +280,7 @@ static void tg_print_config_helper(ffsb_tg_t *tg) ffsb_printsize(buf, tg->read_skipsize, 256)); printf("\t\n"); printf("\t write_random = %s\n", (tg->write_random) ? "on" : "off"); - printf("\t write_size = %llu\t(%s)\n", tg->write_size, + printf("\t write_size = %"PRIu64"\t(%s)\n", tg->write_size, ffsb_printsize(buf, tg->write_size, 256)); printf("\t fsync_file = %d\n", tg->fsync_file); printf("\t write_blocksize = %u\t(%s)\n", tg->write_blocksize, diff --git a/fh.c b/fh.c index f99b455..624bd0d 100644 --- a/fh.c +++ b/fh.c @@ -177,7 +177,7 @@ void fhwrite(int fd, void *buf, uint32_t size, ffsb_thread_t *ft, ffsb_fs_t *fs) } if (realsize != size) { - printf("Wrote %d instead of %d bytes.\n" + printf("Wrote %zd instead of %d bytes.\n" "Probably out of disk space\n", realsize, size); perror("write"); exit(1); @@ -209,10 +209,10 @@ void fhseek(int fd, uint64_t offset, int whence, ffsb_thread_t *ft, if (res == -1) { if (whence == SEEK_SET) - fprintf(stderr, "tried to seek to %lld\n", offset); + fprintf(stderr, "tried to seek to %"PRIu64"\n", offset); else fprintf(stderr, "tried to seek from current " - "position to %lld\n", offset); + "position to %"PRIu64"\n", offset); perror("seek"); exit(1); diff --git a/fileops.c b/fileops.c index 801fa42..dd2911d 100644 --- a/fileops.c +++ b/fileops.c @@ -135,14 +135,14 @@ void ffsb_readfile(ffsb_thread_t *ft, ffsb_fs_t *fs, unsigned opnum) (read_blocksize + read_skipsize); if (minfilesize > filesize) { - printf("Error: read size %llu bytes too big " + printf("Error: read size %"PRIu64" bytes too big " "w/ skipsize %u and blocksize %u," - " for file of size %llu bytes\n" + " for file of size %"PRIu64" bytes\n" " aborting\n\n", read_size, read_skipsize, read_blocksize, filesize); printf("minimum file size must be at least " - " %llu bytes\n", minfilesize); + " %"PRIu64" bytes\n", minfilesize); exit(1); } diff --git a/util.c b/util.c index df5d755..6649814 100644 --- a/util.c +++ b/util.c @@ -330,7 +330,7 @@ void ffsb_bench_gettimeofday(void) total_usec = difftime.tv_sec * 1000000; total_usec += difftime.tv_usec; average = total_usec / 1000ull; - printf("average time for gettimeofday(): %llu nsec\n", average); + printf("average time for gettimeofday(): %"PRIu64" nsec\n", average); } void ffsb_bench_getpid(void) @@ -347,5 +347,5 @@ void ffsb_bench_getpid(void) total_usec = difftime.tv_sec * 1000000; total_usec += difftime.tv_usec; average = total_usec / 1000ull; - printf("average time for getpid(): %llu nsec\n", average); + printf("average time for getpid(): %"PRIu64" nsec\n", average); } -- 2.47.3