diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2013-05-11 15:59:48 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2013-05-11 15:59:48 (GMT) |
commit | d38fe20df6bdb30906b18cf01ee644c44ed5b944 (patch) | |
tree | f9ebbcca3baaf76c5e4c4bcc5139e551cf3d6a0c /tools | |
parent | 5ecebe5b9bc161153a3391bf32eb64687f675172 (diff) | |
download | hdf5-d38fe20df6bdb30906b18cf01ee644c44ed5b944.zip hdf5-d38fe20df6bdb30906b18cf01ee644c44ed5b944.tar.gz hdf5-d38fe20df6bdb30906b18cf01ee644c44ed5b944.tar.bz2 |
[svn-r23695] Description:
Clean up warnings in H5Tconv.c (down to _only_ 9000 lines of output now!)
Merge changes from Coverity branch back to trunk:
r20684:
Fix for coverity bug #1721 which was due to the fix for coverity bug #943.
r20685:
Use HDstrncpy. --gh
r20761:
Purpose: Fix valgrind issues
Description:
Free image_data and data as appropriate in test_image.
r20762:
Purpose: Fix coverity issue 600
Description:
Add check for return value of H5O_close in H5Ocopy. Also cleaned up various
warnings.
r20763:
Purpose: Fix valgrind issues with h5stat
Description:
Modified h5stat to free "iter" before exit, and free "hand" before exit if
parse_command_line exits directly.
r20764:
fixed coverity issues:
69, 327, 614, 684, 685, 696, 697, 1681, 967, 826, 660, 80
r20765:
Fixed coverity bug 668
Pulled x * y * z multiply out of malloc operand into a separate n_elements variable to quiet integer overflow warning.
No actual integer overflow tests are performed since it's just a test program but I did add a check that n_elements is >= 1.
I also changed an error condition from doing its own close and returning -1 to "goto out;" like the rest of the program.
r20766:
Fixed coverity bug 667
Pulled x * y * z multiply out of malloc operand into a separate n_elements variable to quiet integer overflow warning.
No actual integer overflow tests are performed since it's just a test program.
Tested on:
Mac OSX/64 10.8.3 (amazon) w/C++ & FORTRAN
(h5committest upcoming)
Diffstat (limited to 'tools')
-rw-r--r-- | tools/h5jam/getub.c | 2 | ||||
-rw-r--r-- | tools/h5stat/h5stat.c | 337 | ||||
-rw-r--r-- | tools/lib/h5diff_array.c | 6 | ||||
-rw-r--r-- | tools/lib/h5tools.c | 16 | ||||
-rw-r--r-- | tools/lib/h5tools_dump.c | 88 |
5 files changed, 241 insertions, 208 deletions
diff --git a/tools/h5jam/getub.c b/tools/h5jam/getub.c index f536605..d84f7f2 100644 --- a/tools/h5jam/getub.c +++ b/tools/h5jam/getub.c @@ -153,7 +153,7 @@ main (int argc, const char *argv[]) exit (EXIT_FAILURE); } - buf = malloc ((unsigned)(size + 1)); + buf = (char *)HDmalloc ((unsigned)(size + 1)); if (buf == NULL) { HDclose (fd); diff --git a/tools/h5stat/h5stat.c b/tools/h5stat/h5stat.c index a68760d..dcc2c08 100644 --- a/tools/h5stat/h5stat.c +++ b/tools/h5stat/h5stat.c @@ -136,7 +136,8 @@ static int display_object = FALSE; /* not implemented yet */ /* a structure for handling the order command-line parameters come in */ struct handler_t { - char *obj; + size_t obj_count; + char **obj; }; @@ -552,7 +553,7 @@ dataset_stats(iter_t *iter, const char *name, const H5O_info_t *oi) if(type_found) (iter->dset_type_info[u].count)++; else { - unsigned curr_ntype = iter->dset_ntypes; + unsigned curr_ntype = (unsigned)iter->dset_ntypes; /* Increment # of datatypes seen for datasets */ iter->dset_ntypes++; @@ -670,9 +671,11 @@ obj_stats(const char *path, const H5O_info_t *oi, const char *already_visited, break; case H5O_TYPE_NAMED_DATATYPE: - datatype_stats(iter, oi); + datatype_stats(iter, oi); break; + case H5O_TYPE_UNKNOWN: + case H5O_TYPE_NTYPES: default: /* Gather statistics about this type of object */ iter->uniq_others++; @@ -710,6 +713,9 @@ lnk_stats(const char UNUSED *path, const H5L_info_t *li, void *_iter) iter->uniq_links++; break; + case H5L_TYPE_HARD: + case H5L_TYPE_MAX: + case H5L_TYPE_ERROR: default: /* Gather statistics about this type of object */ iter->uniq_others++; @@ -740,19 +746,19 @@ freespace_stats(hid_t fid, iter_t *iter) /* Query section information */ if((nsects = H5Fget_free_sections(fid, H5FD_MEM_DEFAULT, 0, NULL)) < 0) - return(FAIL); + return(FAIL); else if(nsects) { - if(NULL == (sect_info = (H5F_sect_info_t *)HDcalloc((size_t)nsects, sizeof(H5F_sect_info_t)))) - return(FAIL); - nsects = H5Fget_free_sections(fid, H5FD_MEM_DEFAULT, (size_t)nsects, sect_info); - HDassert(nsects); + if(NULL == (sect_info = (H5F_sect_info_t *)HDcalloc((size_t)nsects, sizeof(H5F_sect_info_t)))) + return(FAIL); + nsects = H5Fget_free_sections(fid, H5FD_MEM_DEFAULT, (size_t)nsects, sect_info); + HDassert(nsects); } /* end else-if */ for(u = 0; u < (size_t)nsects; u++) { unsigned bin; /* "bin" the number of objects falls in */ - if(sect_info[u].size < SIZE_SMALL_SECTS) - (iter->num_small_sects[(size_t)sect_info[u].size])++; + if(sect_info[u].size < SIZE_SMALL_SECTS) + (iter->num_small_sects[(size_t)sect_info[u].size])++; /* Add section size to proper bin */ bin = ceil_log10((unsigned long)sect_info[u].size); @@ -781,6 +787,35 @@ freespace_stats(hid_t fid, iter_t *iter) /*------------------------------------------------------------------------- + * Function: hand_free + * + * Purpose: Free handler structure + * + * Return: Success: 0 + * + * Failure: Never fails + * + *------------------------------------------------------------------------- + */ +static void +hand_free(struct handler_t *hand) +{ + if(hand) { + unsigned u; + + for(u = 0; u < hand->obj_count; u++) + if(hand->obj[u]) { + HDfree(hand->obj[u]); + hand->obj[u] = NULL; + } /* end if */ + hand->obj_count = 0; + HDfree(hand->obj); + HDfree(hand); + } /* end if */ +} /* end hand_free() */ + + +/*------------------------------------------------------------------------- * Function: parse_command_line * * Purpose: Parses command line and sets up global variable to control output @@ -794,50 +829,25 @@ freespace_stats(hid_t fid, iter_t *iter) * *------------------------------------------------------------------------- */ -static struct handler_t * -parse_command_line(int argc, const char *argv[]) +static int +parse_command_line(int argc, const char *argv[], struct handler_t **hand_ret) { - int opt, i; + int opt; + unsigned u; struct handler_t *hand = NULL; - /* Allocate space to hold the command line info */ - if((hand = (struct handler_t *)HDcalloc((size_t)argc, sizeof(struct handler_t)))==NULL) { - error_msg("unable to parse command line arguments \n"); - goto error; - } - /* parse command line options */ - while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) { - switch ((char)opt) { + while((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) { + switch((char)opt) { case 'h': usage(h5tools_getprogname()); h5tools_setstatus(EXIT_SUCCESS); - if (hand) { - for (i = 0; i < argc; i++) - if(hand[i].obj) { - free(hand[i].obj); - hand[i].obj=NULL; - } - - free(hand); - hand = NULL; - } goto done; break; case 'V': print_version(h5tools_getprogname()); h5tools_setstatus(EXIT_SUCCESS); - if (hand) { - for (i = 0; i < argc; i++) - if(hand[i].obj) { - free(hand[i].obj); - hand[i].obj=NULL; - } - - free(hand); - hand = NULL; - } goto done; break; @@ -894,45 +904,52 @@ parse_command_line(int argc, const char *argv[]) case 'O': display_all = FALSE; display_object = TRUE; - for(i = 0; i < argc; i++) - if(!hand[i].obj) { - hand[i].obj = HDstrdup(opt_arg); - break; + + /* Allocate space to hold the command line info */ + if(NULL == (hand = (struct handler_t *)HDcalloc((size_t)1, sizeof(struct handler_t)))) { + error_msg("unable to allocate memory for object struct\n"); + goto error; + } /* end if */ + + /* Allocate space to hold the object strings */ + hand->obj_count = (size_t)argc; + if(NULL == (hand->obj = (char **)HDcalloc((size_t)argc, sizeof(char *)))) { + error_msg("unable to allocate memory for object array\n"); + goto error; + } /* end if */ + + /* Store object names */ + for(u = 0; u < hand->obj_count; u++) + if(NULL == (hand->obj[u] = HDstrdup(opt_arg))) { + error_msg("unable to allocate memory for object name\n"); + goto error; } /* end if */ break; default: usage(h5tools_getprogname()); - h5tools_setstatus(EXIT_FAILURE); goto error; } /* end switch */ } /* end while */ /* check for file name to be processed */ - if (argc <= opt_ind) { + if(argc <= opt_ind) { error_msg("missing file name\n"); usage(h5tools_getprogname()); - h5tools_setstatus(EXIT_FAILURE); goto error; } /* end if */ + /* Set handler structure */ + *hand_ret = hand; + done: - return hand; + return 0; error: - if (hand) { - for (i = 0; i < argc; i++) - if(hand[i].obj) { - free(hand[i].obj); - hand[i].obj=NULL; - } - - free(hand); - hand = NULL; - } + hand_free(hand); h5tools_setstatus(EXIT_FAILURE); - return hand; + return -1; } @@ -947,32 +964,39 @@ error: * *------------------------------------------------------------------------- */ -static herr_t +static void iter_free(iter_t *iter) { /* Clear array of bins for group counts */ - if(iter->group_bins) - free(iter->group_bins); - iter->group_bins = NULL; + if(iter->group_bins) { + HDfree(iter->group_bins); + iter->group_bins = NULL; + } /* end if */ + /* Clear array of bins for attribute counts */ - if(iter->attr_bins) - free(iter->attr_bins); - iter->attr_bins = NULL; + if(iter->attr_bins) { + HDfree(iter->attr_bins); + iter->attr_bins = NULL; + } /* end if */ + /* Clear dataset datatype information found */ - if(iter->dset_type_info) - free(iter->dset_type_info); - iter->dset_type_info = NULL; + if(iter->dset_type_info) { + HDfree(iter->dset_type_info); + iter->dset_type_info = NULL; + } /* end if */ + /* Clear array of bins for dataset dimensions */ - if(iter->dset_dim_bins) - free(iter->dset_dim_bins); - iter->dset_dim_bins = NULL; - /* Clear array of bins for free-space section sizes */ - if(iter->sect_bins) - free(iter->sect_bins); - iter->sect_bins = NULL; + if(iter->dset_dim_bins) { + HDfree(iter->dset_dim_bins); + iter->dset_dim_bins = NULL; + } /* end if */ - return 0; -} + /* Clear array of bins for free-space section sizes */ + if(iter->sect_bins) { + HDfree(iter->sect_bins); + iter->sect_bins = NULL; + } /* end if */ +} /* end iter_free() */ /*------------------------------------------------------------------------- @@ -1428,7 +1452,7 @@ print_storage_summary(const iter_t *iter) { hsize_t total_meta = 0; hsize_t unaccount = 0; - float percent = 0.0; + double percent = 0.0f; HDfprintf(stdout, "File space management strategy: %s\n", FS_STRATEGY_NAME[iter->fs_strategy]); printf("Summary of file space information:\n"); @@ -1451,7 +1475,7 @@ print_storage_summary(const iter_t *iter) HDfprintf(stdout, " File metadata: %Hu bytes\n", total_meta); HDfprintf(stdout, " Raw data: %Hu bytes\n", iter->dset_storage_size); - percent = ((float)iter->free_space / (float)iter->filesize) * 100; + percent = ((double)iter->free_space / (double)iter->filesize) * (double)100.0f; HDfprintf(stdout, " Amount/Percent of tracked free space: %Hu bytes/%3.1f%\n", iter->free_space, percent); @@ -1584,10 +1608,7 @@ main(int argc, const char *argv[]) iter_t iter; const char *fname = NULL; hid_t fid = -1; - hid_t fcpl; struct handler_t *hand = NULL; - H5F_info2_t finfo; - int i; h5tools_setprogname(PROGRAMNAME); h5tools_setstatus(EXIT_SUCCESS); @@ -1598,97 +1619,91 @@ main(int argc, const char *argv[]) /* Initialize h5tools lib */ h5tools_init(); - if((hand = parse_command_line(argc, argv))==NULL) { - goto done; - } - - fname = argv[opt_ind]; - - printf("Filename: %s\n", fname); - HDmemset(&iter, 0, sizeof(iter)); - fid = H5Fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT); - if(fid < 0) { - error_msg("unable to open file \"%s\"\n", fname); - h5tools_setstatus(EXIT_FAILURE); + if(parse_command_line(argc, argv, &hand) < 0) goto done; - } /* end if */ - /* Initialize iter structure */ - iter.fid = fid; - - if(H5Fget_filesize(fid, &iter.filesize) < 0) - warn_msg("Unable to retrieve file size\n"); - HDassert(iter.filesize != 0); - - /* Get storge info for file-level structures */ - if(H5Fget_info2(fid, &finfo) < 0) - warn_msg("Unable to retrieve file info\n"); - else { - iter.super_size = finfo.super.super_size; - iter.super_ext_size = finfo.super.super_ext_size; - iter.SM_hdr_storage_size = finfo.sohm.hdr_size; - iter.SM_index_storage_size = finfo.sohm.msgs_info.index_size; - iter.SM_heap_storage_size = finfo.sohm.msgs_info.heap_size; - iter.free_space = finfo.free.tot_space; - iter.free_hdr = finfo.free.meta_size; - } /* end else */ - - if((fcpl = H5Fget_create_plist(fid)) < 0) - warn_msg("Unable to retrieve file creation property\n"); - - if(H5Pget_userblock(fcpl, &iter.ublk_size) < 0) - warn_msg("Unable to retrieve userblock size\n"); + fname = argv[opt_ind]; - if(H5Pget_file_space(fcpl, &iter.fs_strategy, &iter.fs_threshold) < 0) - warn_msg("Unable to retrieve file space information\n"); - HDassert(iter.fs_strategy != 0 && iter.fs_strategy < H5F_FILE_SPACE_NTYPES); + /* Check for filename given */ + if(fname) { + hid_t fcpl; + H5F_info2_t finfo; - /* get information for free-space sections */ - if(freespace_stats(fid, &iter) < 0) - warn_msg("Unable to retrieve freespace info\n"); + printf("Filename: %s\n", fname); - /* Walk the objects or all file */ - if(display_object) { - unsigned u; + fid = H5Fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT); + if(fid < 0) { + error_msg("unable to open file \"%s\"\n", fname); + h5tools_setstatus(EXIT_FAILURE); + goto done; + } /* end if */ - u = 0; - while(hand[u].obj) { - if (h5trav_visit(fid, hand[u].obj, TRUE, TRUE, obj_stats, lnk_stats, &iter) < 0) - warn_msg("Unable to traverse object \"%s\"\n", hand[u].obj); + /* Initialize iter structure */ + iter.fid = fid; + + if(H5Fget_filesize(fid, &iter.filesize) < 0) + warn_msg("Unable to retrieve file size\n"); + HDassert(iter.filesize != 0); + + /* Get storge info for file-level structures */ + if(H5Fget_info2(fid, &finfo) < 0) + warn_msg("Unable to retrieve file info\n"); + else { + iter.super_size = finfo.super.super_size; + iter.super_ext_size = finfo.super.super_ext_size; + iter.SM_hdr_storage_size = finfo.sohm.hdr_size; + iter.SM_index_storage_size = finfo.sohm.msgs_info.index_size; + iter.SM_heap_storage_size = finfo.sohm.msgs_info.heap_size; + iter.free_space = finfo.free.tot_space; + iter.free_hdr = finfo.free.meta_size; + } /* end else */ + + if((fcpl = H5Fget_create_plist(fid)) < 0) + warn_msg("Unable to retrieve file creation property\n"); + + if(H5Pget_userblock(fcpl, &iter.ublk_size) < 0) + warn_msg("Unable to retrieve userblock size\n"); + + if(H5Pget_file_space(fcpl, &iter.fs_strategy, &iter.fs_threshold) < 0) + warn_msg("Unable to retrieve file space information\n"); + HDassert(iter.fs_strategy != 0 && iter.fs_strategy < H5F_FILE_SPACE_NTYPES); + + /* get information for free-space sections */ + if(freespace_stats(fid, &iter) < 0) + warn_msg("Unable to retrieve freespace info\n"); + + /* Walk the objects or all file */ + if(display_object) { + unsigned u; + + for(u = 0; u < hand->obj_count; u++) { + if(h5trav_visit(fid, hand->obj[u], TRUE, TRUE, obj_stats, lnk_stats, &iter) < 0) + warn_msg("Unable to traverse object \"%s\"\n", hand->obj[u]); + else + print_statistics(hand->obj[u], &iter); + } /* end for */ + } /* end if */ + else { + if(h5trav_visit(fid, "/", TRUE, TRUE, obj_stats, lnk_stats, &iter) < 0) + warn_msg("Unable to traverse objects/links in file \"%s\"\n", fname); else - print_statistics(hand[u].obj, &iter); - u++; - } /* end while */ + print_statistics("/", &iter); + } /* end else */ } /* end if */ - else { - if (h5trav_visit(fid, "/", TRUE, TRUE, obj_stats, lnk_stats, &iter) < 0) - warn_msg("Unable to traverse objects/links in file \"%s\"\n", fname); - else - print_statistics("/", &iter); - } /* end else */ done: - if(hand) { - for (i = 0; i < argc; i++) - if(hand[i].obj) { - free(hand[i].obj); - hand[i].obj=NULL; - } + hand_free(hand); - free(hand); - hand = NULL; + /* Free iter structure */ + iter_free(&iter); - /* Free iter structure */ - iter_free(&iter); - - if(fid >= 0 && H5Fclose(fid) < 0) { - error_msg("unable to close file \"%s\"\n", fname); - h5tools_setstatus(EXIT_FAILURE); - } - } + if(fid >= 0 && H5Fclose(fid) < 0) { + error_msg("unable to close file \"%s\"\n", fname); + h5tools_setstatus(EXIT_FAILURE); + } /* end if */ leave(h5tools_getstatus()); -} +} /* end main() */ diff --git a/tools/lib/h5diff_array.c b/tools/lib/h5diff_array.c index 528fc40..96b508d 100644 --- a/tools/lib/h5diff_array.c +++ b/tools/lib/h5diff_array.c @@ -5783,17 +5783,19 @@ static int ull2float(unsigned long long ull_value, float *f_value) { hid_t dxpl_id; - unsigned char *buf; + unsigned char *buf = NULL; size_t src_size; size_t dst_size; h5difftrace("ull2float start\n"); if((dxpl_id = H5Pcreate(H5P_DATASET_XFER))<0) - return -1; + goto error; src_size = H5Tget_size(H5T_NATIVE_ULLONG); dst_size = H5Tget_size(H5T_NATIVE_FLOAT); buf = (unsigned char*)HDcalloc(1, MAX(src_size, dst_size)); + if(!buf) + goto error; HDmemcpy(buf, &ull_value, src_size); diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c index 5f4227c..3e9c43e 100644 --- a/tools/lib/h5tools.c +++ b/tools/lib/h5tools.c @@ -527,16 +527,18 @@ h5tools_detect_vlen_str(hid_t tid) } } else if(tclass == H5T_COMPOUND) { - int i = 0; - int n = H5Tget_nmembers(tid); + unsigned nmembs; + int snmembs = H5Tget_nmembers(tid); + unsigned u; - if(n < 0) { - n = ret; + if(snmembs < 0) { + ret = FAIL; goto done; } + nmembs = (unsigned)snmembs; - for(i = 0; i < n; i++) { - hid_t mtid = H5Tget_member_type(tid, i); + for(u = 0; u < nmembs; u++) { + hid_t mtid = H5Tget_member_type(tid, u); ret = h5tools_detect_vlen_str(mtid); if((ret == TRUE) || (ret < 0)) { @@ -1150,6 +1152,8 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t s = *(char**) mem; if (s != NULL) size = HDstrlen(s); + else + H5E_THROW(FAIL, H5E_tools_min_id_g, "NULL string"); } else { s = (char *) mem; diff --git a/tools/lib/h5tools_dump.c b/tools/lib/h5tools_dump.c index d6cd0a0..b3c8f5e 100644 --- a/tools/lib/h5tools_dump.c +++ b/tools/lib/h5tools_dump.c @@ -188,7 +188,7 @@ table_t *h5dump_type_table = NULL; /*type table reference for datatype dump */ static int h5tools_print_region_data_blocks(hid_t region_id, FILE *stream, const h5tool_format_t *info, h5tools_context_t *cur_ctx, h5tools_str_t *buffer/*string into which to render */, size_t ncols, - int ndims, hid_t type_id, hssize_t nblocks, hsize_t *ptdata); + unsigned ndims, hid_t type_id, hsize_t nblocks, hsize_t *ptdata); hbool_t h5tools_dump_region_data_points(hid_t region_space, hid_t region_id, FILE *stream, const h5tool_format_t *info, @@ -419,7 +419,7 @@ static int h5tools_print_region_data_blocks(hid_t region_id, FILE *stream, const h5tool_format_t *info, h5tools_context_t *cur_ctx, h5tools_str_t *buffer/*string into which to render */, size_t ncols, - int ndims, hid_t type_id, hssize_t nblocks, hsize_t *ptdata) + unsigned ndims, hid_t type_id, hsize_t nblocks, hsize_t *ptdata) { hbool_t dimension_break = TRUE; hsize_t *dims1 = NULL; @@ -432,9 +432,9 @@ h5tools_print_region_data_blocks(hid_t region_id, unsigned int region_flags; /* buffer extent flags */ hsize_t numelem; hsize_t numindex; - size_t jndx; unsigned indx; - int type_size; + unsigned jndx; + size_t type_size; int ret_value = SUCCEED; hid_t mem_space = -1; hid_t sid1 = -1; @@ -447,6 +447,7 @@ h5tools_print_region_data_blocks(hid_t region_id, HDassert(ptdata); HDmemset(&ctx, 0, sizeof(ctx)); + /* Get the dataspace of the dataset */ if((sid1 = H5Dget_space(region_id)) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_space failed"); @@ -463,7 +464,7 @@ h5tools_print_region_data_blocks(hid_t region_id, } /* Create dataspace for reading buffer */ - if((mem_space = H5Screate_simple(ndims, dims1, NULL)) < 0) + if((mem_space = H5Screate_simple((int)ndims, dims1, NULL)) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Screate_simple failed"); if((type_size = H5Tget_size(type_id)) == 0) @@ -504,7 +505,7 @@ h5tools_print_region_data_blocks(hid_t region_id, HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed"); /* assume entire data space to be printed */ - for (indx = 0; indx < (size_t) ctx.ndims; indx++) + for (indx = 0; indx < (unsigned)ctx.ndims; indx++) ctx.p_min_idx[indx] = start[indx]; init_acc_pos(&ctx, total_size); @@ -513,11 +514,11 @@ h5tools_print_region_data_blocks(hid_t region_id, if (blkndx == nblocks - 1) region_flags |= END_OF_DATA; - for (indx = 0; indx < (size_t)ctx.ndims; indx++) + for (indx = 0; indx < (unsigned)ctx.ndims; indx++) ctx.p_max_idx[indx] = dims1[indx]; curr_pos = 0; - ctx.sm_pos = blkndx*2*ndims; + ctx.sm_pos = blkndx * 2 * ndims; ctx.size_last_dim = dims1[ndims-1]; h5tools_region_simple_prefix(stream, info, &ctx, curr_pos, ptdata, 0); @@ -540,7 +541,7 @@ h5tools_print_region_data_blocks(hid_t region_id, if(FALSE == dimension_break) elmtno = 0; - } /* end for (jndx = 0; jndx < numelem; jndx++, region_elmtno++, ctx.cur_elmt++) */ + } /* end for (numindex = 0; numindex < numelem; numindex++, elmtno++, ctx.cur_elmt++) */ ctx.indent_level--; } /* end for (blkndx = 0; blkndx < nblocks; blkndx++) */ @@ -593,24 +594,28 @@ h5tools_dump_region_data_blocks(hid_t region_space, hid_t region_id, { HERR_INIT(hbool_t, TRUE) hbool_t dimension_break = TRUE; - hssize_t nblocks; + hssize_t snblocks; + hsize_t nblocks; hsize_t alloc_size; hsize_t *ptdata = NULL; - int ndims; + int sndims; + unsigned ndims; hid_t dtype = -1; hid_t type_id = -1; - int i; + hsize_t u; HDassert(info); HDassert(ctx); HDassert(buffer); - if((nblocks = H5Sget_select_hyper_nblocks(region_space)) <= 0) + if((snblocks = H5Sget_select_hyper_nblocks(region_space)) <= 0) H5E_THROW(dimension_break, H5E_tools_min_id_g, "H5Sget_select_hyper_nblocks failed"); + nblocks = (hsize_t)snblocks; /* Print block information */ - if((ndims = H5Sget_simple_extent_ndims(region_space)) < 0) + if((sndims = H5Sget_simple_extent_ndims(region_space)) < 0) H5E_THROW(dimension_break, H5E_tools_min_id_g, "H5Sget_simple_extent_ndims failed"); + ndims = (unsigned)sndims; /* Render the region { element begin */ h5tools_str_reset(buffer); @@ -635,27 +640,26 @@ h5tools_dump_region_data_blocks(hid_t region_space, hid_t region_id, //HGOTO_ERROR(dimension_break, H5E_tools_min_id_g, "Could not allocate buffer for ptdata"); } - H5_CHECK_OVERFLOW(nblocks, hssize_t, hsize_t); - if(H5Sget_select_hyper_blocklist(region_space, (hsize_t) 0, (hsize_t) nblocks, ptdata) < 0) + if(H5Sget_select_hyper_blocklist(region_space, (hsize_t)0, nblocks, ptdata) < 0) HGOTO_ERROR(dimension_break, H5E_tools_min_id_g, "H5Rget_select_hyper_blocklist failed"); - for (i = 0; i < nblocks; i++) { - int j; + for(u = 0; u < nblocks; u++) { + unsigned v; h5tools_str_append(buffer, info->dset_blockformat_pre, - i ? "," OPTIONAL_LINE_BREAK " " : "", (unsigned long) i); + u ? "," OPTIONAL_LINE_BREAK " " : "", (unsigned long)u); /* Start coordinates and opposite corner */ - for (j = 0; j < ndims; j++) - h5tools_str_append(buffer, "%s" HSIZE_T_FORMAT, j ? "," : "(", - ptdata[i * 2 * ndims + j]); + for (v = 0; v < ndims; v++) + h5tools_str_append(buffer, "%s" HSIZE_T_FORMAT, v ? "," : "(", + ptdata[u * 2 * ndims + v]); - for (j = 0; j < ndims; j++) - h5tools_str_append(buffer, "%s" HSIZE_T_FORMAT, j ? "," : ")-(", - ptdata[i * 2 * ndims + j + ndims]); + for (v = 0; v < ndims; v++) + h5tools_str_append(buffer, "%s" HSIZE_T_FORMAT, v ? "," : ")-(", + ptdata[u * 2 * ndims + v + ndims]); h5tools_str_append(buffer, ")"); - } /* end for (i = 0; i < nblocks; i++) */ + } /* end for (u = 0; u < nblocks; u++) */ dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter); /* Render the region datatype info and indices element end */ @@ -2222,12 +2226,16 @@ h5tools_print_datatype(FILE *stream, h5tools_str_t *buffer, const h5tool_format_ /* Change the endianness and see if they're equal. */ order = H5Tget_order(tmp_type); - if (order == H5T_ORDER_LE) - H5Tset_order(str_type, H5T_ORDER_LE); - else if (order == H5T_ORDER_BE) - H5Tset_order(str_type, H5T_ORDER_BE); - - if (H5Tequal(tmp_type, str_type)) { + if(order == H5T_ORDER_LE) { + if(H5Tset_order(str_type, H5T_ORDER_LE) < 0) + HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tset_order failed"); + } /* end if */ + else if(order == H5T_ORDER_BE) { + if(H5Tset_order(str_type, H5T_ORDER_BE) < 0) + HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tset_order failed"); + } /* end if */ + + if(H5Tequal(tmp_type, str_type)) { h5tools_str_append(buffer, "H5T_C_S1;"); goto found_string_type; } @@ -2249,12 +2257,16 @@ h5tools_print_datatype(FILE *stream, h5tools_str_t *buffer, const h5tool_format_ /* Change the endianness and see if they're equal. */ order = H5Tget_order(tmp_type); - if (order == H5T_ORDER_LE) - H5Tset_order(str_type, H5T_ORDER_LE); - else if (order == H5T_ORDER_BE) - H5Tset_order(str_type, H5T_ORDER_BE); - - if (H5Tequal(tmp_type, str_type)) { + if(order == H5T_ORDER_LE) { + if(H5Tset_order(str_type, H5T_ORDER_LE) < 0) + HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tset_order failed"); + } /* end if */ + else if(order == H5T_ORDER_BE) { + if(H5Tset_order(str_type, H5T_ORDER_BE) < 0) + HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tset_order failed"); + } /* end if */ + + if(H5Tequal(tmp_type, str_type)) { h5tools_str_append(buffer, "H5T_FORTRAN_S1;"); goto found_string_type; } |