summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMohamad Chaarawi <chaarawi@hdfgroup.org>2013-07-03 16:12:32 (GMT)
committerMohamad Chaarawi <chaarawi@hdfgroup.org>2013-07-03 16:12:32 (GMT)
commitdfcb3cebf17c20b6dfc0a1dd5178c2e2d01c4422 (patch)
tree6dd345c9832ff210c96dc7d642ba2e2f4d394bf6
parent6da129cef05328a6935bb6ce65319944cdce5a95 (diff)
downloadhdf5-dfcb3cebf17c20b6dfc0a1dd5178c2e2d01c4422.zip
hdf5-dfcb3cebf17c20b6dfc0a1dd5178c2e2d01c4422.tar.gz
hdf5-dfcb3cebf17c20b6dfc0a1dd5178c2e2d01c4422.tar.bz2
[svn-r23862] Change printfs in perform output and h5dump to prevent overflow.
This fixes: https://jira.hdfgroup.uiuc.edu/browse/HDFFV-8450 Tested on Jam.
-rw-r--r--perform/pio_engine.c56
-rw-r--r--perform/pio_perf.c20
-rw-r--r--perform/sio_engine.c10
-rw-r--r--perform/sio_perf.c12
-rw-r--r--src/H5system.c3
-rw-r--r--tools/h5dump/h5dump_ddl.c4
6 files changed, 53 insertions, 52 deletions
diff --git a/perform/pio_engine.c b/perform/pio_engine.c
index 0e3190c..87fa82c 100644
--- a/perform/pio_engine.c
+++ b/perform/pio_engine.c
@@ -245,52 +245,52 @@ do_pio(parameters param)
/* Validate transfer buffer size & block size*/
if(blk_size<=0) {
HDfprintf(stderr,
- "Transfer block size (%Hd) must be > 0\n", (long long)blk_size);
+ "Transfer block size (%zu) must be > 0\n", blk_size);
GOTOERROR(FAIL);
}
if(buf_size<=0) {
HDfprintf(stderr,
- "Transfer buffer size (%Hd) must be > 0\n", (long long)buf_size);
+ "Transfer buffer size (%zu) must be > 0\n", buf_size);
GOTOERROR(FAIL);
}
if ((buf_size % blk_size) != 0){
HDfprintf(stderr,
- "Transfer buffer size (%Hd) must be a multiple of the "
- "interleaved I/O block size (%Hd)\n",
- (long long)buf_size, (long long)blk_size);
+ "Transfer buffer size (%zu) must be a multiple of the "
+ "interleaved I/O block size (%zu)\n",
+ buf_size, blk_size);
GOTOERROR(FAIL);
}
if((snbytes%pio_mpi_nprocs_g)!=0) {
HDfprintf(stderr,
- "Dataset size (%Hd) must be a multiple of the "
- "number of processes (%d)\n",
- (long long)snbytes, pio_mpi_nprocs_g);
+ "Dataset size (%" H5_PRINTF_LL_WIDTH "d) must be a multiple of the "
+ "number of processes (%d)\n",
+ (long long)snbytes, pio_mpi_nprocs_g);
GOTOERROR(FAIL);
}
if (!param.dim2d){
if(((snbytes/pio_mpi_nprocs_g)%buf_size)!=0) {
HDfprintf(stderr,
- "Dataset size/process (%Hd) must be a multiple of the "
- "trasfer buffer size (%Hd)\n",
- (long long)(snbytes/pio_mpi_nprocs_g), (long long)buf_size);
+ "Dataset size/process (%" H5_PRINTF_LL_WIDTH "d) must be a multiple of the "
+ "trasfer buffer size (%zu)\n",
+ (long long)(snbytes/pio_mpi_nprocs_g), buf_size);
GOTOERROR(FAIL);
}
}
else {
if((snbytes%buf_size)!=0) {
HDfprintf(stderr,
- "Dataset side size (%Hd) must be a multiple of the "
- "trasfer buffer size (%Hd)\n",
- (long long)snbytes, (long long)buf_size);
+ "Dataset side size (%" H5_PRINTF_LL_WIDTH "d) must be a multiple of the "
+ "trasfer buffer size (%zu)\n",
+ (long long)snbytes, buf_size);
GOTOERROR(FAIL);
}
}
/* Allocate transfer buffer */
if ((buffer = malloc(bsize)) == NULL){
- HDfprintf(stderr, "malloc for transfer buffer size (%Hd) failed\n",
- (long long)(bsize));
+ HDfprintf(stderr, "malloc for transfer buffer size (%zu) failed\n",
+ bsize);
GOTOERROR(FAIL);
}
@@ -651,13 +651,13 @@ do_write(results *res, file_descr *fd, parameters *parms, long ndsets,
HDprint_rank(output);
if (!parms->dim2d) {
HDfprintf(output, "Debug(do_write): "
- "buf_size=%Hd, bytes_begin=%Hd, bytes_count=%Hd\n",
- (long long)buf_size, (long long)bytes_begin[0],
+ "buf_size=%zu, bytes_begin=%" H5_PRINTF_LL_WIDTH "d, bytes_count=%" H5_PRINTF_LL_WIDTH "d\n",
+ buf_size, (long long)bytes_begin[0],
(long long)bytes_count);
} else {
HDfprintf(output, "Debug(do_write): "
- "linear buf_size=%Hd, bytes_begin=(%Hd,%Hd), bytes_count=%Hd\n",
- (long long)buf_size*blk_size, (long long)bytes_begin[0],
+ "linear buf_size=%zu, bytes_begin=(%" H5_PRINTF_LL_WIDTH "d,%" H5_PRINTF_LL_WIDTH "d), bytes_count=%" H5_PRINTF_LL_WIDTH "d\n",
+ buf_size*blk_size, (long long)bytes_begin[0],
(long long)bytes_begin[1], (long long)bytes_count);
}
}
@@ -1625,13 +1625,13 @@ do_read(results *res, file_descr *fd, parameters *parms, long ndsets,
HDprint_rank(output);
if (!parms->dim2d) {
HDfprintf(output, "Debug(do_write): "
- "buf_size=%Hd, bytes_begin=%Hd, bytes_count=%Hd\n",
- (long long)buf_size, (long long)bytes_begin[0],
+ "buf_size=%zu, bytes_begin=%" H5_PRINTF_LL_WIDTH "d, bytes_count=%" H5_PRINTF_LL_WIDTH "d\n",
+ buf_size, (long long)bytes_begin[0],
(long long)bytes_count);
} else {
HDfprintf(output, "Debug(do_write): "
- "linear buf_size=%Hd, bytes_begin=(%Hd,%Hd), bytes_count=%Hd\n",
- (long long)buf_size*blk_size, (long long)bytes_begin[0],
+ "linear buf_size=%zu, bytes_begin=(%" H5_PRINTF_LL_WIDTH "d,%" H5_PRINTF_LL_WIDTH "d), bytes_count=%" H5_PRINTF_LL_WIDTH "d\n",
+ buf_size*blk_size, (long long)bytes_begin[0],
(long long)bytes_begin[1], (long long)bytes_count);
}
}
@@ -2336,10 +2336,10 @@ do_read(results *res, file_descr *fd, parameters *parms, long ndsets,
if (++nerror < 20){
/* report at most 20 errors */
HDprint_rank(output);
- HDfprintf(output, "read data error, expected (%Hd), "
- "got (%Hd)\n",
- (long long)pio_mpi_rank_g+1,
- (long long)*(ucharptr-1));
+ HDfprintf(output, "read data error, expected (%d), "
+ "got (%d)\n",
+ pio_mpi_rank_g+1,
+ (int)*(ucharptr-1));
} /* end if */
} /* end if */
} /* end for */
diff --git a/perform/pio_perf.c b/perform/pio_perf.c
index 337e982..a47754b 100644
--- a/perform/pio_perf.c
+++ b/perform/pio_perf.c
@@ -1116,14 +1116,14 @@ recover_size_and_print(long long val, const char *end)
if (val >= ONE_KB && (val % ONE_KB) == 0) {
if (val >= ONE_MB && (val % ONE_MB) == 0) {
if (val >= ONE_GB && (val % ONE_GB) == 0)
- HDfprintf(output, "%HdGB%s", val / ONE_GB, end);
+ HDfprintf(output, "%" H5_PRINTF_LL_WIDTH "d""GB%s", val / ONE_GB, end);
else
- HDfprintf(output, "%HdMB%s", val / ONE_MB, end);
+ HDfprintf(output, "%" H5_PRINTF_LL_WIDTH "d""MB%s", val / ONE_MB, end);
} else {
- HDfprintf(output, "%HdKB%s", val / ONE_KB, end);
+ HDfprintf(output, "%" H5_PRINTF_LL_WIDTH "d""KB%s", val / ONE_KB, end);
}
} else {
- HDfprintf(output, "%Hd%s", val, end);
+ HDfprintf(output, "%" H5_PRINTF_LL_WIDTH "d""%s", val, end);
}
}
@@ -1150,12 +1150,12 @@ report_parameters(struct options *opts)
HDfprintf(output, "rank %d: IO API=", rank);
print_io_api(opts->io_types);
- HDfprintf(output, "rank %d: Number of files=%Hd\n", rank,
- (long long)opts->num_files);
- HDfprintf(output, "rank %d: Number of datasets=%Hd\n", rank,
- (long long)opts->num_dsets);
- HDfprintf(output, "rank %d: Number of iterations=%Hd\n", rank,
- (long long)opts->num_iters);
+ HDfprintf(output, "rank %d: Number of files=%ld\n", rank,
+ opts->num_files);
+ HDfprintf(output, "rank %d: Number of datasets=%ld\n", rank,
+ opts->num_dsets);
+ HDfprintf(output, "rank %d: Number of iterations=%d\n", rank,
+ opts->num_iters);
HDfprintf(output, "rank %d: Number of processes=%d:%d\n", rank,
opts->min_num_procs, opts->max_num_procs);
diff --git a/perform/sio_engine.c b/perform/sio_engine.c
index df2e21e..541a9b0 100644
--- a/perform/sio_engine.c
+++ b/perform/sio_engine.c
@@ -196,15 +196,15 @@ do_sio(parameters param)
/* Validate transfer buffer size */
if (param.buf_size[i]<=0) {
HDfprintf(stderr,
- "Transfer buffer size[%d] (%Hd) must be > 0\n", i,(long long)buf_size[i]);
+ "Transfer buffer size[%d] (%zu) must be > 0\n", i,buf_size[i]);
GOTOERROR(FAIL);
}
if ((param.dset_size[i]%param.buf_size[i])!=0) {
HDfprintf(stderr,
- "Dataset size[%d] (%Hd) must be a multiple of the "
- "trasfer buffer size[%d] (%Hd)\n",param.rank,
- (long long)param.dset_size[i], param.rank, (long long)param.buf_size[i]);
+ "Dataset size[%d] (%" H5_PRINTF_LL_WIDTH "d) must be a multiple of the "
+ "trasfer buffer size[%d] (%zu)\n",param.rank,
+ (long long)param.dset_size[i], param.rank, param.buf_size[i]);
GOTOERROR(FAIL);
}
@@ -212,7 +212,7 @@ do_sio(parameters param)
/* Allocate transfer buffer */
if ((buffer = malloc(linear_buf_size)) == NULL){
- HDfprintf(stderr, "malloc for transfer buffer size (%Hd) failed\n", (long long)(linear_buf_size));
+ HDfprintf(stderr, "malloc for transfer buffer size (%zu) failed\n", linear_buf_size);
GOTOERROR(FAIL);
}
diff --git a/perform/sio_perf.c b/perform/sio_perf.c
index 16e1750..5c09e84 100644
--- a/perform/sio_perf.c
+++ b/perform/sio_perf.c
@@ -827,14 +827,14 @@ recover_size_and_print(long long val, const char *end)
if (val >= ONE_KB && (val % ONE_KB) == 0) {
if (val >= ONE_MB && (val % ONE_MB) == 0) {
if (val >= ONE_GB && (val % ONE_GB) == 0)
- HDfprintf(output, "%HdGB%s", val / ONE_GB, end);
+ HDfprintf(output, "%" H5_PRINTF_LL_WIDTH "d""GB%s", val / ONE_GB, end);
else
- HDfprintf(output, "%HdMB%s", val / ONE_MB, end);
+ HDfprintf(output, "%" H5_PRINTF_LL_WIDTH "d""MB%s", val / ONE_MB, end);
} else {
- HDfprintf(output, "%HdKB%s", val / ONE_KB, end);
+ HDfprintf(output, "%" H5_PRINTF_LL_WIDTH "d""KB%s", val / ONE_KB, end);
}
} else {
- HDfprintf(output, "%Hd%s", val, end);
+ HDfprintf(output, "%" H5_PRINTF_LL_WIDTH "d""%s", val, end);
}
}
@@ -860,8 +860,8 @@ report_parameters(struct options *opts)
HDfprintf(output, "IO API=");
print_io_api(opts->io_types);
- HDfprintf(output, "Number of iterations=%Hd\n",
- (long long)opts->num_iters);
+ HDfprintf(output, "Number of iterations=%d\n",
+ opts->num_iters);
HDfprintf(output, "Dataset size=");
diff --git a/src/H5system.c b/src/H5system.c
index 85e554e..2a94028 100644
--- a/src/H5system.c
+++ b/src/H5system.c
@@ -189,7 +189,7 @@ HDfprintf(FILE *stream, const char *fmt, ...)
}
/* Extra type modifiers */
- if(HDstrchr("ZHhlqLI", *s)) {
+ if(HDstrchr("zZHhlqLI", *s)) {
switch(*s) {
/*lint --e{506} Don't issue warnings about constant value booleans */
/*lint --e{774} Don't issue warnings boolean within 'if' always evaluates false/true */
@@ -203,6 +203,7 @@ HDfprintf(FILE *stream, const char *fmt, ...)
break;
case 'Z':
+ case 'z':
if(sizeof(size_t) < sizeof(long))
modifier[0] = '\0';
else if(sizeof(size_t) == sizeof(long))
diff --git a/tools/h5dump/h5dump_ddl.c b/tools/h5dump/h5dump_ddl.c
index a9a23a5..bb54e3f 100644
--- a/tools/h5dump/h5dump_ddl.c
+++ b/tools/h5dump/h5dump_ddl.c
@@ -1179,9 +1179,9 @@ dump_fcpl(hid_t fid)
indentation(dump_indent + COL);
PRINTSTREAM(rawoutstream, "%s %u\n","OBJECTHEADER_VERSION", finfo.sohm.version);
indentation(dump_indent + COL);
- PRINTSTREAM(rawoutstream,"%s %Hd\n","OFFSET_SIZE", (long long)off_size);
+ PRINTSTREAM(rawoutstream,"%s %zu\n","OFFSET_SIZE", off_size);
indentation(dump_indent + COL);
- PRINTSTREAM(rawoutstream,"%s %Hd\n","LENGTH_SIZE", (long long)len_size);
+ PRINTSTREAM(rawoutstream,"%s %zu\n","LENGTH_SIZE", len_size);
indentation(dump_indent + COL);
PRINTSTREAM(rawoutstream, "%s %u\n","BTREE_RANK", sym_ik);
indentation(dump_indent + COL);