From f84af6ecc6ec547545c167018ea3400f9171c8ab Mon Sep 17 00:00:00 2001 From: Richard Warren Date: Tue, 15 Aug 2017 09:17:04 -0400 Subject: Fix the t_bigio test so that it runs on 32bit machines --- testpar/t_bigio.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/testpar/t_bigio.c b/testpar/t_bigio.c index a4a1323..ca2b55d 100644 --- a/testpar/t_bigio.c +++ b/testpar/t_bigio.c @@ -785,7 +785,7 @@ dataset_big_write(void) } /* create a memory dataspace */ - mem_dataspace = H5Screate_simple (1, &bigcount, NULL); + mem_dataspace = H5Screate_simple (1, dims, NULL); VRFY((mem_dataspace >= 0), ""); /* set up the collective transfer properties list */ @@ -903,7 +903,7 @@ dataset_big_write(void) VRFY((ret >= 0), "H5Dclose1 succeeded"); free(wdata); -#endif +#endif H5Fclose(fid); } @@ -1217,7 +1217,7 @@ dataset_big_read(void) if(coords) free(coords); /* create a memory dataspace */ - mem_dataspace = H5Screate_simple (1, &bigcount, NULL); + mem_dataspace = H5Screate_simple (1, dims, NULL); VRFY((mem_dataspace >= 0), ""); /* set up the collective transfer properties list */ @@ -1684,8 +1684,9 @@ coll_chunktest(const char* filename, VRFY((mem_dataspace >= 0), "mem dataspace created succeeded"); } else { + hsize_t dsdims[1] = {num_points}; current_dims = num_points; - mem_dataspace = H5Screate_simple (1, ¤t_dims, NULL); + mem_dataspace = H5Screate_simple (1, dsdims, NULL); VRFY((mem_dataspace >= 0), "mem_dataspace create succeeded"); } @@ -1962,8 +1963,9 @@ coll_chunktest(const char* filename, VRFY((mem_dataspace >= 0), ""); } else { + hsize_t dsdims[1] = {num_points}; current_dims = num_points; - mem_dataspace = H5Screate_simple (1, ¤t_dims, NULL); + mem_dataspace = H5Screate_simple (1, dsdims, NULL); VRFY((mem_dataspace >= 0), "mem_dataspace create succeeded"); } -- cgit v0.12 From b82ba32275f7ed998aafa68a1cecaab3e80323da Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Wed, 23 Aug 2017 16:12:40 -0500 Subject: HDFFV-10282 refactor out assert calls in tools --- tools/lib/h5diff_dset.c | 13 +- tools/lib/h5diff_util.c | 7 +- tools/lib/h5tools.c | 33 +-- tools/lib/h5tools_ref.c | 43 ++-- tools/lib/h5tools_type.c | 2 - tools/lib/h5tools_utils.c | 8 +- tools/lib/h5trav.c | 32 ++- tools/src/h5copy/h5copy.c | 96 +++---- tools/src/h5dump/h5dump.c | 182 +++++++------- tools/src/h5dump/h5dump_ddl.c | 210 ++++++++-------- tools/src/h5dump/h5dump_xml.c | 457 +++++++++++++++++----------------- tools/src/h5jam/h5jam.c | 13 +- tools/src/h5jam/h5unjam.c | 54 ++-- tools/src/h5ls/h5ls.c | 33 ++- tools/src/h5repack/h5repack.c | 1 - tools/src/h5repack/h5repack_copy.c | 2 - tools/src/h5repack/h5repack_filters.c | 368 ++++++++++++--------------- tools/src/h5repack/h5repack_refs.c | 8 +- 18 files changed, 754 insertions(+), 808 deletions(-) diff --git a/tools/lib/h5diff_dset.c b/tools/lib/h5diff_dset.c index 991ef48..a4f7863 100644 --- a/tools/lib/h5diff_dset.c +++ b/tools/lib/h5diff_dset.c @@ -358,7 +358,6 @@ hsize_t diff_datasetid( hid_t did1, nelmts2 *= dims2[i]; h5diffdebug3("nelmts: %ld - %ld\n", nelmts1, nelmts2); - HDassert(nelmts1 == nelmts2); if(tclass != H5T_ARRAY) { /*----------------------------------------------------------------- @@ -459,7 +458,7 @@ hsize_t diff_datasetid( hid_t did1, size = 1; sm_size[i - 1] = MIN(dadims[i - 1], size); sm_nbytes *= sm_size[i - 1]; - HDassert(sm_nbytes > 0); + h5diffdebug2("sm_nbytes: %ld\n", sm_nbytes); } /* end for */ /* malloc return code should be verified. @@ -469,10 +468,10 @@ hsize_t diff_datasetid( hid_t did1, * that fails to address freeing other objects created here. * E.g., sm_space. */ - sm_buf1 = HDmalloc((size_t)sm_nbytes); - HDassert(sm_buf1); - sm_buf2 = HDmalloc((size_t)sm_nbytes); - HDassert(sm_buf2); + if((sm_buf1 = HDmalloc((size_t)sm_nbytes)) == NULL) + goto error; + if((sm_buf2 = HDmalloc((size_t)sm_nbytes)) == NULL) + goto error; sm_nelmts = sm_nbytes / p_type_nbytes; sm_space = H5Screate_simple(1, &sm_nelmts, NULL); @@ -682,7 +681,6 @@ int diff_can_type( hid_t f_tid1, /* file data type */ * check for non supported classes *------------------------------------------------------------------------- */ - HDassert(tclass1 == tclass2); switch (tclass1) { case H5T_TIME: if((options->m_verbose || options->m_list_not_cmp) && obj1_name && obj2_name) { @@ -754,7 +752,6 @@ int diff_can_type( hid_t f_tid1, /* file data type */ * check for different dimensions *------------------------------------------------------------------------- */ - HDassert(rank1 == rank2); for(i = 0; indims); - - ctx->acc[ctx->ndims - 1] = 1; - for (i = ((int)ctx->ndims - 2); i >= 0; i--) - ctx->acc[i] = ctx->acc[i + 1] * dims[i + 1]; - for (j = 0; j < ctx->ndims; j++) - ctx->pos[j] = 0; + if(ctx->ndims > 0) { + ctx->acc[ctx->ndims - 1] = 1; + for (i = ((int)ctx->ndims - 2); i >= 0; i--) + ctx->acc[i] = ctx->acc[i + 1] * dims[i + 1]; + for (j = 0; j < ctx->ndims; j++) + ctx->pos[j] = 0; + } } /*------------------------------------------------------------------------- @@ -1410,13 +1410,17 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t memb = H5Tget_super(tid); ndims = H5Tget_array_ndims(tid); H5Tget_array_dims2(tid, dims); - HDassert(ndims >= 1 && ndims <= H5S_MAX_RANK); - - /* calculate the number of array elements */ - for (k = 0, nelmts = 1; k < ndims; k++) { - temp_nelmts = nelmts; - temp_nelmts *= dims[k]; - nelmts = (size_t) temp_nelmts; + if(ndims >= 1 && ndims <= H5S_MAX_RANK) { + /* calculate the number of array elements */ + for (k = 0, nelmts = 1; k < ndims; k++) { + temp_nelmts = nelmts; + temp_nelmts *= dims[k]; + nelmts = (size_t) temp_nelmts; + } + } + else { + H5Tclose(memb); + H5E_THROW(FAIL, H5E_tools_min_id_g, "calculate the number of array elements failed"); } for (block_index = 0; block_index < block_nelmts; block_index++) { @@ -1641,7 +1645,6 @@ render_bin_output_region_blocks(hid_t region_space, hid_t region_id, ndims = (unsigned)sndims; alloc_size = nblocks * ndims * 2 * sizeof(ptdata[0]); - HDassert(alloc_size == (hsize_t) ((size_t) alloc_size)); /*check for overflow*/ if((ptdata = (hsize_t*) HDmalloc((size_t) alloc_size)) == NULL) HGOTO_ERROR(FALSE, H5E_tools_min_id_g, "Could not allocate buffer for ptdata"); diff --git a/tools/lib/h5tools_ref.c b/tools/lib/h5tools_ref.c index 16a949d..6153f0c 100644 --- a/tools/lib/h5tools_ref.c +++ b/tools/lib/h5tools_ref.c @@ -107,19 +107,21 @@ static int init_ref_path_table(void) { /* Sanity check */ - HDassert(thefile > 0); - - /* Create skip list to store reference path information */ - if((ref_path_table = H5SL_create(H5SL_TYPE_HADDR, NULL))==NULL) + if(thefile > 0) { + /* Create skip list to store reference path information */ + if((ref_path_table = H5SL_create(H5SL_TYPE_HADDR, NULL))==NULL) + return (-1); + + /* Iterate over objects in this file */ + if(h5trav_visit(thefile, "/", TRUE, TRUE, init_ref_path_cb, NULL, NULL) < 0) { + error_msg("unable to construct reference path table\n"); + h5tools_setstatus(EXIT_FAILURE); + } /* end if */ + + return(0); + } + else return (-1); - - /* Iterate over objects in this file */ - if(h5trav_visit(thefile, "/", TRUE, TRUE, init_ref_path_cb, NULL, NULL) < 0) { - error_msg("unable to construct reference path table\n"); - h5tools_setstatus(EXIT_FAILURE); - } /* end if */ - - return(0); } /*------------------------------------------------------------------------- @@ -212,16 +214,17 @@ ref_path_table_put(const char *path, haddr_t objno) { ref_path_node_t *new_node; - HDassert(ref_path_table); - HDassert(path); - - if((new_node = (ref_path_node_t *)HDmalloc(sizeof(ref_path_node_t))) == NULL) - return(-1); + if(ref_path_table && path) { + if((new_node = (ref_path_node_t *)HDmalloc(sizeof(ref_path_node_t))) == NULL) + return(-1); - new_node->objno = objno; - new_node->path = HDstrdup(path); + new_node->objno = objno; + new_node->path = HDstrdup(path); - return(H5SL_insert(ref_path_table, new_node, &(new_node->objno))); + return(H5SL_insert(ref_path_table, new_node, &(new_node->objno))); + } + else + return (-1); } /* diff --git a/tools/lib/h5tools_type.c b/tools/lib/h5tools_type.c index ae7160b..ee58ccb 100644 --- a/tools/lib/h5tools_type.c +++ b/tools/lib/h5tools_type.c @@ -92,7 +92,6 @@ h5tools_get_little_endian_type(hid_t tid) case H5T_NO_CLASS: case H5T_NCLASSES: default: - HDassert(0); break; } /* end switch */ @@ -179,7 +178,6 @@ h5tools_get_big_endian_type(hid_t tid) case H5T_NO_CLASS: case H5T_NCLASSES: default: - HDassert(0); break; } /* end switch */ diff --git a/tools/lib/h5tools_utils.c b/tools/lib/h5tools_utils.c index 08213df..8c435b2 100644 --- a/tools/lib/h5tools_utils.c +++ b/tools/lib/h5tools_utils.c @@ -608,7 +608,6 @@ find_objs_cb(const char *name, const H5O_info_t *oinfo, const char *already_seen case H5O_TYPE_UNKNOWN: case H5O_TYPE_NTYPES: default: - HDassert(0); break; } /* end switch */ @@ -777,8 +776,11 @@ H5tools_get_symlink_info(hid_t file_id, const char * linkpath, h5tool_link_info_ } /* end if */ /* trg_path must be freed out of this function when finished using */ - link_info->trg_path = (char*)HDcalloc(link_info->linfo.u.val_size, sizeof(char)); - HDassert(link_info->trg_path); + if((link_info->trg_path = (char*)HDcalloc(link_info->linfo.u.val_size, sizeof(char))) == NULL) { + if(link_info->opt.msg_mode == 1) + parallel_print("Warning: unable to allocate buffer for <%s>\n",linkpath); + goto out; + } /* end if */ /* get link value */ if(H5Lget_val(file_id, linkpath, (void *)link_info->trg_path, link_info->linfo.u.val_size, H5P_DEFAULT) < 0) { diff --git a/tools/lib/h5trav.c b/tools/lib/h5trav.c index 3d55f2d..ddc0109 100644 --- a/tools/lib/h5trav.c +++ b/tools/lib/h5trav.c @@ -557,7 +557,7 @@ trav_info_free(trav_info_t *info) if(info) { /* Free visited symbolic links path and file (if alloc) */ - for(u=0; u < info->symlink_visited.nused; u++) + for(u=0; u < info->symlink_visited.nused; u++) { if (info->symlink_visited.objs[u].file) HDfree(info->symlink_visited.objs[u].file); @@ -789,8 +789,6 @@ trav_table_addlink(trav_table_t *table, haddr_t objno, const char *path) return; } /* end for */ } /* end for */ - - HDassert(0 && "object not in table?!?"); } @@ -1017,7 +1015,7 @@ trav_print_visit_obj(const char *path, const H5O_info_t *oinfo, /* Finish printing line about object */ printf("\n"); if(trav_verbosity > 0) - H5Aiterate_by_name(print_udata->fid, path, trav_index_by, trav_index_order, + H5Aiterate_by_name(print_udata->fid, path, trav_index_by, trav_index_order, NULL, trav_attr, &op_data, H5P_DEFAULT); } else @@ -1051,12 +1049,12 @@ trav_print_visit_lnk(const char *path, const H5L_info_t *linfo, void *udata) case H5L_TYPE_SOFT: if(linfo->u.val_size > 0) { char *targbuf = (char*)HDmalloc(linfo->u.val_size + 1); - HDassert(targbuf); - - if(H5Lget_val(print_udata->fid, path, targbuf, linfo->u.val_size + 1, H5P_DEFAULT) < 0) - targbuf[0] = 0; - printf(" %-10s %s -> %s\n", "link", path, targbuf); - HDfree(targbuf); + if(targbuf) { + if(H5Lget_val(print_udata->fid, path, targbuf, linfo->u.val_size + 1, H5P_DEFAULT) < 0) + targbuf[0] = 0; + printf(" %-10s %s -> %s\n", "link", path, targbuf); + HDfree(targbuf); + } } /* end if */ else printf(" %-10s %s ->\n", "link", path); @@ -1069,13 +1067,13 @@ trav_print_visit_lnk(const char *path, const H5L_info_t *linfo, void *udata) const char *objname = NULL; targbuf = (char*)HDmalloc(linfo->u.val_size + 1); - HDassert(targbuf); - - if(H5Lget_val(print_udata->fid, path, targbuf, linfo->u.val_size + 1, H5P_DEFAULT) < 0) - targbuf[0] = 0; - if(H5Lunpack_elink_val(targbuf, linfo->u.val_size, NULL, &filename, &objname) >= 0) - printf(" %-10s %s -> %s %s\n", "ext link", path, filename, objname); - HDfree(targbuf); + if(targbuf) { + if(H5Lget_val(print_udata->fid, path, targbuf, linfo->u.val_size + 1, H5P_DEFAULT) < 0) + targbuf[0] = 0; + if(H5Lunpack_elink_val(targbuf, linfo->u.val_size, NULL, &filename, &objname) >= 0) + printf(" %-10s %s -> %s %s\n", "ext link", path, filename, objname); + HDfree(targbuf); + } } /* end if */ else printf(" %-10s %s ->\n", "ext link", path); diff --git a/tools/src/h5copy/h5copy.c b/tools/src/h5copy/h5copy.c index 3f91fce..be84b26 100644 --- a/tools/src/h5copy/h5copy.c +++ b/tools/src/h5copy/h5copy.c @@ -159,36 +159,28 @@ static int parse_flag(const char* s_flag, unsigned *flag) { unsigned fla=0; - if (HDstrcmp(s_flag,"shallow")==0) - { + if (HDstrcmp(s_flag, "shallow") == 0) { fla = H5O_COPY_SHALLOW_HIERARCHY_FLAG; } - else if (HDstrcmp(s_flag,"soft")==0) - { + else if (HDstrcmp(s_flag, "soft") == 0) { fla = H5O_COPY_EXPAND_SOFT_LINK_FLAG; } - else if (HDstrcmp(s_flag,"ext")==0) - { + else if (HDstrcmp(s_flag, "ext") == 0) { fla = H5O_COPY_EXPAND_EXT_LINK_FLAG; } - else if (HDstrcmp(s_flag,"ref")==0) - { + else if (HDstrcmp(s_flag, "ref") == 0) { fla = H5O_COPY_EXPAND_REFERENCE_FLAG; } - else if (HDstrcmp(s_flag,"noattr")==0) - { + else if (HDstrcmp(s_flag, "noattr") == 0) { fla = H5O_COPY_WITHOUT_ATTR_FLAG; } - else if (HDstrcmp(s_flag,"allflags")==0) - { + else if (HDstrcmp(s_flag, "allflags") == 0) { fla = H5O_COPY_ALL; } - else if (HDstrcmp(s_flag,"nullmsg")==0) - { + else if (HDstrcmp(s_flag, "nullmsg") == 0) { fla = H5O_COPY_PRESERVE_NULL_FLAG; } - else - { + else { error_msg("Error in input flag\n"); return -1; } @@ -247,25 +239,21 @@ main (int argc, const char *argv[]) HDmemset(&linkinfo, 0, sizeof(h5tool_link_info_t)); /* Check for no command line parameters */ - if(argc == 1) - { + if(argc == 1) { usage(); leave(EXIT_FAILURE); } /* end if */ /* 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 'd': oname_dst = HDstrdup(opt_arg); break; case 'f': /* validate flag */ - if (parse_flag(opt_arg,&flag)<0) - { + if (parse_flag(opt_arg, &flag) < 0) { usage(); leave(EXIT_FAILURE); } @@ -316,29 +304,25 @@ main (int argc, const char *argv[]) * check for missing file/object names *-------------------------------------------------------------------------*/ - if (fname_src==NULL) - { + if (fname_src==NULL) { error_msg("Input file name missing\n"); usage(); leave(EXIT_FAILURE); } - if (fname_dst==NULL) - { + if (fname_dst==NULL) { error_msg("Output file name missing\n"); usage(); leave(EXIT_FAILURE); } - if (oname_src==NULL) - { + if (oname_src==NULL) { error_msg("Source object name missing\n"); usage(); leave(EXIT_FAILURE); } - if (oname_dst==NULL) - { + if (oname_dst==NULL) { error_msg("Destination object name missing\n"); usage(); leave(EXIT_FAILURE); @@ -367,8 +351,7 @@ main (int argc, const char *argv[]) /*------------------------------------------------------------------------- * test for error in opening input file *-------------------------------------------------------------------------*/ - if (fid_src==-1) - { + if (fid_src==-1) { error_msg("Could not open input file <%s>...Exiting\n", fname_src); leave(EXIT_FAILURE); } @@ -386,8 +369,7 @@ main (int argc, const char *argv[]) /*------------------------------------------------------------------------- * test for error in opening output file *-------------------------------------------------------------------------*/ - if (fid_dst==-1) - { + if (fid_dst==-1) { error_msg("Could not open output file <%s>...Exiting\n", fname_dst); leave(EXIT_FAILURE); } @@ -396,12 +378,10 @@ main (int argc, const char *argv[]) * print some info *-------------------------------------------------------------------------*/ - if (verbose) - { + if (verbose) { printf("Copying file <%s> and object <%s> to file <%s> and object <%s>\n", fname_src, oname_src, fname_dst, oname_dst); if (flag) { - HDassert(str_flag); printf("Using %s flag\n", str_flag); } } @@ -416,8 +396,7 @@ main (int argc, const char *argv[]) HGOTO_ERROR(EXIT_FAILURE, H5E_tools_min_id_g, "H5Pcreate failed"); /* set options for object copy */ - if (flag) - { + if (flag) { if ( H5Pset_copy_object(ocpl_id, flag) < 0) HGOTO_ERROR(EXIT_FAILURE, H5E_tools_min_id_g, "H5Pset_copy_object failed"); } @@ -440,24 +419,21 @@ main (int argc, const char *argv[]) if(verbose) printf("%s: Creating parent groups\n", h5tools_getprogname()); } /* end if */ - else /* error, if parent groups doesn't already exist in destination file */ - { + else { + /* error, if parent groups doesn't already exist in destination file */ size_t i, len; len = HDstrlen(oname_dst); /* check if all the parents groups exist. skip root group */ - for (i = 1; i < len; i++) - { - if ('/'==oname_dst[i]) - { + for (i = 1; i < len; i++) { + if ('/'==oname_dst[i]) { char *str_ptr; str_ptr = (char *)HDcalloc(i + 1, sizeof(char)); HDstrncpy(str_ptr, oname_dst, i); str_ptr[i]='\0'; - if (H5Lexists(fid_dst, str_ptr, H5P_DEFAULT) <= 0) - { + if (H5Lexists(fid_dst, str_ptr, H5P_DEFAULT) <= 0) { error_msg("group <%s> doesn't exist. Use -p to create parent groups.\n", str_ptr); HDfree(str_ptr); HGOTO_ERROR(EXIT_FAILURE, H5E_tools_min_id_g, "H5Lexists failed"); @@ -475,15 +451,15 @@ main (int argc, const char *argv[]) linkinfo.opt.msg_mode = 1; li_ret = H5tools_get_symlink_info(fid_src, oname_src, &linkinfo, 1); - if (li_ret == 0) /* dangling link */ - { + if (li_ret == 0) { + /* dangling link */ if(H5Lcopy(fid_src, oname_src, fid_dst, oname_dst, H5P_DEFAULT, H5P_DEFAULT) < 0) HGOTO_ERROR(EXIT_FAILURE, H5E_tools_min_id_g, "H5Lcopy failed"); } - else /* valid link */ - { + else { + /* valid link */ if (H5Ocopy(fid_src, /* Source file or group identifier */ oname_src, /* Name of the source object to be copied */ fid_dst, /* Destination file or group identifier */ @@ -518,13 +494,13 @@ done: if (linkinfo.trg_path) HDfree(linkinfo.trg_path); - H5E_BEGIN_TRY { - H5Pclose(ocpl_id); - H5Pclose(lcpl_id); - H5Fclose(fid_src); - H5Fclose(fid_dst); - } H5E_END_TRY; + H5E_BEGIN_TRY { + H5Pclose(ocpl_id); + H5Pclose(lcpl_id); + H5Fclose(fid_src); + H5Fclose(fid_dst); + } H5E_END_TRY; - leave(ret_value); + leave(ret_value); } diff --git a/tools/src/h5dump/h5dump.c b/tools/src/h5dump/h5dump.c index bf2e127..b90d60f 100644 --- a/tools/src/h5dump/h5dump.c +++ b/tools/src/h5dump/h5dump.c @@ -721,93 +721,100 @@ parse_mask_list(const char *h_list) const char *ptr = NULL; /* sanity check */ - HDassert(h_list); + if(h_list) { + HDmemset(packed_mask,0,sizeof(packed_mask)); + + packed_bits_num = 0; + /* scan in pair of offset,length separated by commas. */ + ptr = h_list; + while (*ptr) { + /* scan for an offset which is an unsigned int */ + if (!HDisdigit(*ptr)) { + error_msg("Bad mask list(%s)\n", h_list); + return FAIL; + } + soffset_value = HDatoi(ptr); + offset_value = (unsigned)soffset_value; + if (soffset_value < 0 || offset_value >= PACKED_BITS_SIZE_MAX) { + error_msg("Packed Bit offset value(%d) must be between 0 and %u\n", + soffset_value, (unsigned)(PACKED_BITS_SIZE_MAX - 1)); + return FAIL; + } - HDmemset(packed_mask,0,sizeof(packed_mask)); + /* skip to end of integer */ + while (HDisdigit(*++ptr)) + ; + /* Look for the common separator */ + if (*ptr++ != ',') { + error_msg("Bad mask list(%s), missing expected comma separator.\n", h_list); + return FAIL; + } - packed_bits_num = 0; - /* scan in pair of offset,length separated by commas. */ - ptr = h_list; - while (*ptr) { - /* scan for an offset which is an unsigned int */ - if (!HDisdigit(*ptr)) { - error_msg("Bad mask list(%s)\n", h_list); - return FAIL; - } - soffset_value = HDatoi(ptr); - offset_value = (unsigned)soffset_value; - if (soffset_value < 0 || offset_value >= PACKED_BITS_SIZE_MAX) { - error_msg("Packed Bit offset value(%d) must be between 0 and %u\n", - soffset_value, (unsigned)(PACKED_BITS_SIZE_MAX - 1)); - return FAIL; - } + /* scan for a length which is a positive int */ + if (!HDisdigit(*ptr)) { + error_msg("Bad mask list(%s)\n", h_list); + return FAIL; + } + slength_value = HDatoi(ptr); + if (slength_value <= 0) { + error_msg("Packed Bit length value(%d) must be positive.\n", slength_value); + return FAIL; + } + length_value = (unsigned)slength_value; + if ((offset_value + length_value) > PACKED_BITS_SIZE_MAX) { + error_msg("Packed Bit offset+length value(%u) too large. Max is %u\n", + offset_value+length_value, (unsigned)PACKED_BITS_SIZE_MAX); + return FAIL; + } - /* skip to end of integer */ - while (HDisdigit(*++ptr)) - ; - /* Look for the common separator */ - if (*ptr++ != ',') { - error_msg("Bad mask list(%s), missing expected comma separator.\n", h_list); - return FAIL; - } + /* skip to end of int */ + while (HDisdigit(*++ptr)) + ; - /* scan for a length which is a positive int */ - if (!HDisdigit(*ptr)) { - error_msg("Bad mask list(%s)\n", h_list); - return FAIL; - } - slength_value = HDatoi(ptr); - if (slength_value <= 0) { - error_msg("Packed Bit length value(%d) must be positive.\n", slength_value); - return FAIL; + /* store the offset,length pair */ + if (packed_bits_num >= PACKED_BITS_MAX) { + /* too many requests */ + error_msg("Too many masks requested (max. %d). Mask list(%s)\n", PACKED_BITS_MAX, h_list); + return FAIL; + } + packed_offset[packed_bits_num] = offset_value; + packed_length[packed_bits_num] = length_value; + /* create the bit mask by left shift 1's by length, then negate it. */ + /* After packed_mask is calculated, packed_length is not needed but */ + /* keep it for debug purpose. */ + temp_mask = ~0ULL; + if(length_value < (int)(8 *sizeof(unsigned long long))) { + temp_mask = temp_mask << length_value; + packed_mask[packed_bits_num] = ~temp_mask; + } + else + packed_mask[packed_bits_num] = temp_mask; + packed_bits_num++; + + /* skip a possible comma separator */ + if (*ptr == ',') { + if (!(*++ptr)) { + /* unexpected end of string */ + error_msg("Bad mask list(%s), unexpected end of string.\n", h_list); + return FAIL; + } + } } - length_value = (unsigned)slength_value; - if ((offset_value + length_value) > PACKED_BITS_SIZE_MAX) { - error_msg("Packed Bit offset+length value(%u) too large. Max is %u\n", - offset_value+length_value, (unsigned)PACKED_BITS_SIZE_MAX); + if(packed_bits_num > PACKED_BITS_MAX) { + error_msg("Maximum number of packed bits exceeded\n"); return FAIL; } - - /* skip to end of int */ - while (HDisdigit(*++ptr)) - ; - - /* store the offset,length pair */ - if (packed_bits_num >= PACKED_BITS_MAX) { - /* too many requests */ - error_msg("Too many masks requested (max. %d). Mask list(%s)\n", PACKED_BITS_MAX, h_list); + if (packed_bits_num == 0) { + /* got no masks! */ + error_msg("Bad mask list(%s)\n", h_list); return FAIL; } - packed_offset[packed_bits_num] = offset_value; - packed_length[packed_bits_num] = length_value; - /* create the bit mask by left shift 1's by length, then negate it. */ - /* After packed_mask is calculated, packed_length is not needed but */ - /* keep it for debug purpose. */ - temp_mask = ~0ULL; - if(length_value < (int)(8 *sizeof(unsigned long long))) { - temp_mask = temp_mask << length_value; - packed_mask[packed_bits_num] = ~temp_mask; - } - else - packed_mask[packed_bits_num] = temp_mask; - packed_bits_num++; - - /* skip a possible comma separator */ - if (*ptr == ',') { - if (!(*++ptr)) { - /* unexpected end of string */ - error_msg("Bad mask list(%s), unexpected end of string.\n", h_list); - return FAIL; - } - } + return SUCCEED; } - HDassert(packed_bits_num <= PACKED_BITS_MAX); - if (packed_bits_num == 0) { - /* got no masks! */ - error_msg("Bad mask list(%s)\n", h_list); + else { + error_msg("Bad mask list argument\n"); return FAIL; } - return SUCCEED; } @@ -1708,13 +1715,18 @@ h5_fileaccess(void) HDmemset(memb_name, 0, sizeof memb_name); HDmemset(memb_addr, 0, sizeof memb_addr); - HDassert(HDstrlen(multi_letters)==H5FD_MEM_NTYPES); - for (mt=H5FD_MEM_DEFAULT; mt 0); - *prfx = (char *)HDcalloc(prfx_len, 1); + if(prfx_len > 0) + *prfx = (char *)HDcalloc(prfx_len, 1); + else + error_msg("unable to allocate prefix buffer\n"); } diff --git a/tools/src/h5dump/h5dump_ddl.c b/tools/src/h5dump/h5dump_ddl.c index 0a45840..eecd113 100644 --- a/tools/src/h5dump/h5dump_ddl.c +++ b/tools/src/h5dump/h5dump_ddl.c @@ -248,17 +248,19 @@ dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void H5_ATTR /* Keep copy of prefix before iterating into group */ old_prefix = HDstrdup(prefix); - HDassert(old_prefix); + if (old_prefix) { + /* Append group name to prefix */ + add_prefix(&prefix, &prefix_len, name); - /* Append group name to prefix */ - add_prefix(&prefix, &prefix_len, name); + /* Iterate into group */ + dump_function_table->dump_group_function(obj, name); - /* Iterate into group */ - dump_function_table->dump_group_function(obj, name); - - /* Restore old prefix name */ - HDstrcpy(prefix, old_prefix); - HDfree(old_prefix); + /* Restore old prefix name */ + HDstrcpy(prefix, old_prefix); + HDfree(old_prefix); + } + else + error_msg("warning: null prefix\n"); /* Close group */ H5Gclose(obj); @@ -408,131 +410,137 @@ dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void H5_ATTR switch(linfo->type) { case H5L_TYPE_SOFT: - targbuf = (char *)HDmalloc(linfo->u.val_size); - HDassert(targbuf); - - ctx.need_prefix = TRUE; - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "%s \"%s\" %s", - h5tools_dump_header_format->softlinkbegin, name, - h5tools_dump_header_format->softlinkblockbegin); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - - ctx.indent_level++; - - if(H5Lget_val(group, name, targbuf, linfo->u.val_size, H5P_DEFAULT) < 0) { - error_msg("unable to get link value\n"); + if((targbuf = (char *)HDmalloc(linfo->u.val_size)) == NULL) { + error_msg("unable to allocate buffer\n"); h5tools_setstatus(EXIT_FAILURE); ret = FAIL; } else { - /* print the value of a soft link */ - /* Standard DDL: no modification */ ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "LINKTARGET \"%s\"", targbuf); + h5tools_str_append(&buffer, "%s \"%s\" %s", + h5tools_dump_header_format->softlinkbegin, name, + h5tools_dump_header_format->softlinkblockbegin); h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - } - ctx.indent_level--; + ctx.indent_level++; - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); + if(H5Lget_val(group, name, targbuf, linfo->u.val_size, H5P_DEFAULT) < 0) { + error_msg("unable to get link value\n"); + h5tools_setstatus(EXIT_FAILURE); + ret = FAIL; + } + else { + /* print the value of a soft link */ + /* Standard DDL: no modification */ + ctx.need_prefix = TRUE; + h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - /* Render the element */ - h5tools_str_reset(&buffer); - if(HDstrlen(h5tools_dump_header_format->softlinkblockend)) { - h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->softlinkblockend); - if(HDstrlen(h5tools_dump_header_format->softlinkend)) - h5tools_str_append(&buffer, " "); - } - if(HDstrlen(h5tools_dump_header_format->softlinkend)) - h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->softlinkend); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "LINKTARGET \"%s\"", targbuf); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + } - HDfree(targbuf); - break; + ctx.indent_level--; - case H5L_TYPE_EXTERNAL: - targbuf = (char *)HDmalloc(linfo->u.val_size); - HDassert(targbuf); + ctx.need_prefix = TRUE; + h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); + /* Render the element */ + h5tools_str_reset(&buffer); + if(HDstrlen(h5tools_dump_header_format->softlinkblockend)) { + h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->softlinkblockend); + if(HDstrlen(h5tools_dump_header_format->softlinkend)) + h5tools_str_append(&buffer, " "); + } + if(HDstrlen(h5tools_dump_header_format->softlinkend)) + h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->softlinkend); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "%s \"%s\" %s", - h5tools_dump_header_format->extlinkbegin, name, - h5tools_dump_header_format->extlinkblockbegin); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + HDfree(targbuf); + } + break; - if(H5Lget_val(group, name, targbuf, linfo->u.val_size, H5P_DEFAULT) < 0) { - indentation(dump_indent); - error_msg("unable to get external link value\n"); + case H5L_TYPE_EXTERNAL: + if((targbuf = (char *)HDmalloc(linfo->u.val_size)) == NULL) { + error_msg("unable to allocate buffer\n"); h5tools_setstatus(EXIT_FAILURE); ret = FAIL; - } /* end if */ + } else { - const char *filename; - const char *targname; + ctx.need_prefix = TRUE; + h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - if(H5Lunpack_elink_val(targbuf, linfo->u.val_size, NULL, &filename, &targname) < 0) { + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "%s \"%s\" %s", + h5tools_dump_header_format->extlinkbegin, name, + h5tools_dump_header_format->extlinkblockbegin); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + + if(H5Lget_val(group, name, targbuf, linfo->u.val_size, H5P_DEFAULT) < 0) { indentation(dump_indent); - error_msg("unable to unpack external link value\n"); + error_msg("unable to get external link value\n"); h5tools_setstatus(EXIT_FAILURE); ret = FAIL; } /* end if */ else { - ctx.indent_level++; + const char *filename; + const char *targname; - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); + if(H5Lunpack_elink_val(targbuf, linfo->u.val_size, NULL, &filename, &targname) < 0) { + indentation(dump_indent); + error_msg("unable to unpack external link value\n"); + h5tools_setstatus(EXIT_FAILURE); + ret = FAIL; + } /* end if */ + else { + ctx.indent_level++; - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "TARGETFILE \"%s\"", filename); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + ctx.need_prefix = TRUE; + h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "TARGETFILE \"%s\"", filename); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "TARGETPATH \"%s\"", targname); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + ctx.need_prefix = TRUE; + h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - /* dump the external link */ - dump_extlink(group, name, targname); - ctx.indent_level--; + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "TARGETPATH \"%s\"", targname); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + + /* dump the external link */ + dump_extlink(group, name, targname); + ctx.indent_level--; + } /* end else */ } /* end else */ - } /* end else */ - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); + ctx.need_prefix = TRUE; + h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - /* Render the element */ - h5tools_str_reset(&buffer); - if(HDstrlen(h5tools_dump_header_format->extlinkblockend)) { - h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->extlinkblockend); + /* Render the element */ + h5tools_str_reset(&buffer); + if(HDstrlen(h5tools_dump_header_format->extlinkblockend)) { + h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->extlinkblockend); + if(HDstrlen(h5tools_dump_header_format->extlinkend)) + h5tools_str_append(&buffer, " "); + } if(HDstrlen(h5tools_dump_header_format->extlinkend)) - h5tools_str_append(&buffer, " "); - } - if(HDstrlen(h5tools_dump_header_format->extlinkend)) - h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->extlinkend); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->extlinkend); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - HDfree(targbuf); + HDfree(targbuf); + } break; case H5L_TYPE_ERROR: case H5L_TYPE_MAX: - HDassert(0); - /* fall through */ case H5L_TYPE_HARD: default: ctx.need_prefix = TRUE; @@ -1082,7 +1090,7 @@ dump_dataset(hid_t did, const char *name, struct subset_t *sset) case H5T_NO_CLASS: case H5T_NCLASSES: default: - HDassert(0); + error_msg("invalid H5TCLASS type\n"); break; } /* end switch */ } /* for(u=0; uudlinkbegin, links, h5tools_dump_header_format->udlinkblockbegin); diff --git a/tools/src/h5dump/h5dump_xml.c b/tools/src/h5dump/h5dump_xml.c index d731013..a83ec08 100644 --- a/tools/src/h5dump/h5dump_xml.c +++ b/tools/src/h5dump/h5dump_xml.c @@ -198,18 +198,22 @@ xml_dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void H5_ char *old_prefix; /* Pointer to previous prefix */ /* Keep copy of prefix before iterating into group */ - old_prefix = HDstrdup(prefix); - HDassert(old_prefix); - - /* Append group name to prefix */ - add_prefix(&prefix, &prefix_len, name); + if((old_prefix = HDstrdup(prefix)) == NULL) { + error_msg("unable to allocate buffer\n"); + h5tools_setstatus(EXIT_FAILURE); + ret = FAIL; + } + else { + /* Append group name to prefix */ + add_prefix(&prefix, &prefix_len, name); - /* Iterate into group */ - dump_function_table->dump_group_function(obj, name); + /* Iterate into group */ + dump_function_table->dump_group_function(obj, name); - /* Restore old prefix name */ - HDstrcpy(prefix, old_prefix); - HDfree(old_prefix); + /* Restore old prefix name */ + HDstrcpy(prefix, old_prefix); + HDfree(old_prefix); + } /* Close group */ H5Gclose(obj); @@ -360,161 +364,167 @@ xml_dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void H5_ switch(linfo->type) { case H5L_TYPE_SOFT: - targbuf = (char *)HDmalloc(linfo->u.val_size); - HDassert(targbuf); - - if(H5Lget_val(group, name, targbuf, linfo->u.val_size, H5P_DEFAULT) < 0) { - error_msg("unable to get link value\n"); + if((targbuf = (char *)HDmalloc(linfo->u.val_size)) == NULL) { + error_msg("unable to allocate buffer\n"); h5tools_setstatus(EXIT_FAILURE); ret = FAIL; } else { - /* print the value of a soft link */ - /* XML */ - char linkxid[100]; - char parentxid[100]; - char targetxid[100]; - char *t_prefix = xml_escape_the_name(HDstrcmp(prefix,"") ? prefix : "/"); - char *t_name = xml_escape_the_name(name); - char *t_targbuf = xml_escape_the_name(targbuf); - char *t_obj_path = xml_escape_the_name(obj_path); - char *t_link_path; - int res; - - t_link_path = (char *)HDmalloc(HDstrlen(prefix) + linfo->u.val_size + 1); - if(targbuf[0] == '/') - HDstrcpy(t_link_path, targbuf); + if(H5Lget_val(group, name, targbuf, linfo->u.val_size, H5P_DEFAULT) < 0) { + error_msg("unable to get link value\n"); + h5tools_setstatus(EXIT_FAILURE); + ret = FAIL; + } else { - HDstrcpy(t_link_path, prefix); - HDstrcat(HDstrcat(t_link_path, "/"), targbuf); - } /* end else */ + /* print the value of a soft link */ + /* XML */ + char linkxid[100]; + char parentxid[100]; + char targetxid[100]; + char *t_prefix = xml_escape_the_name(HDstrcmp(prefix,"") ? prefix : "/"); + char *t_name = xml_escape_the_name(name); + char *t_targbuf = xml_escape_the_name(targbuf); + char *t_obj_path = xml_escape_the_name(obj_path); + char *t_link_path; + int res; - /* Create OBJ-XIDs for the parent and object */ - xml_name_to_XID(t_obj_path, linkxid, (int)sizeof(linkxid), 1); - xml_name_to_XID(prefix, parentxid, (int)sizeof(parentxid), 1); + t_link_path = (char *)HDmalloc(HDstrlen(prefix) + linfo->u.val_size + 1); + if(targbuf[0] == '/') + HDstrcpy(t_link_path, targbuf); + else { + HDstrcpy(t_link_path, prefix); + HDstrcat(HDstrcat(t_link_path, "/"), targbuf); + } /* end else */ - /* Try to create an OBJ-XID for the object pointed to */ - res = xml_name_to_XID(t_link_path, targetxid, (int)sizeof(targetxid), 0); - if (res == 0) { - /* target obj found */ - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); + /* Create OBJ-XIDs for the parent and object */ + xml_name_to_XID(t_obj_path, linkxid, (int)sizeof(linkxid), 1); + xml_name_to_XID(prefix, parentxid, (int)sizeof(parentxid), 1); - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sSoftLink LinkName=\"%s\" " - "OBJ-XID=\"%s\" " - "H5SourcePath=\"%s\" " - "TargetPath=\"%s\" TargetObj=\"%s\" " - "Parents=\"%s\" H5ParentPaths=\"%s\" />", - xmlnsprefix, - t_name, /* LinkName */ - linkxid, /* OBJ-XID */ - t_obj_path, /* H5SourcePath */ - t_targbuf, /* TargetPath */ - targetxid, /* TargetObj */ - parentxid, /* Parents */ - t_prefix); /* H5ParentPaths */ - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - } - else { - /* dangling link -- omit from xml attributes */ - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); + /* Try to create an OBJ-XID for the object pointed to */ + res = xml_name_to_XID(t_link_path, targetxid, (int)sizeof(targetxid), 0); + if (res == 0) { + /* target obj found */ + ctx.need_prefix = TRUE; + h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sSoftLink LinkName=\"%s\" " - "OBJ-XID=\"%s\" " - "H5SourcePath=\"%s\" " - "TargetPath=\"%s\" " - "Parents=\"%s\" H5ParentPaths=\"%s\" />", - xmlnsprefix, - t_name, /* LinkName */ - linkxid, /* OBJ-XID */ - t_obj_path, /* H5SourcePath */ - t_targbuf, /* TargetPath */ - parentxid, /* Parents */ - t_prefix); /* H5ParentPaths */ - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "<%sSoftLink LinkName=\"%s\" " + "OBJ-XID=\"%s\" " + "H5SourcePath=\"%s\" " + "TargetPath=\"%s\" TargetObj=\"%s\" " + "Parents=\"%s\" H5ParentPaths=\"%s\" />", + xmlnsprefix, + t_name, /* LinkName */ + linkxid, /* OBJ-XID */ + t_obj_path, /* H5SourcePath */ + t_targbuf, /* TargetPath */ + targetxid, /* TargetObj */ + parentxid, /* Parents */ + t_prefix); /* H5ParentPaths */ + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + } + else { + /* dangling link -- omit from xml attributes */ + ctx.need_prefix = TRUE; + h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); + + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "<%sSoftLink LinkName=\"%s\" " + "OBJ-XID=\"%s\" " + "H5SourcePath=\"%s\" " + "TargetPath=\"%s\" " + "Parents=\"%s\" H5ParentPaths=\"%s\" />", + xmlnsprefix, + t_name, /* LinkName */ + linkxid, /* OBJ-XID */ + t_obj_path, /* H5SourcePath */ + t_targbuf, /* TargetPath */ + parentxid, /* Parents */ + t_prefix); /* H5ParentPaths */ + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + } + + HDfree(t_prefix); + HDfree(t_name); + HDfree(t_targbuf); + HDfree(t_obj_path); + HDfree(t_link_path); } - HDfree(t_prefix); - HDfree(t_name); - HDfree(t_targbuf); - HDfree(t_obj_path); - HDfree(t_link_path); + HDfree(targbuf); } - - HDfree(targbuf); break; case H5L_TYPE_EXTERNAL: - targbuf = (char *)HDmalloc(linfo->u.val_size); - HDassert(targbuf); - - if(H5Lget_val(group, name, targbuf, linfo->u.val_size, H5P_DEFAULT) < 0) { - error_msg("unable to get external link value\n"); + if((targbuf = (char *)HDmalloc(linfo->u.val_size)) == NULL) { + error_msg("unable to allocate buffer\n"); h5tools_setstatus(EXIT_FAILURE); ret = FAIL; - } /* end if */ + } else { - const char *filename; - const char *targname; - - if(H5Lunpack_elink_val(targbuf, linfo->u.val_size, NULL, &filename, &targname) < 0) { - error_msg("unable to unpack external link value\n"); + if(H5Lget_val(group, name, targbuf, linfo->u.val_size, H5P_DEFAULT) < 0) { + error_msg("unable to get external link value\n"); h5tools_setstatus(EXIT_FAILURE); ret = FAIL; } /* end if */ else { - char linkxid[100]; - char parentxid[100]; - char *t_name = xml_escape_the_name(name); - char *t_prefix = xml_escape_the_name(HDstrcmp(prefix,"") ? prefix : "/"); - char *t_obj_path = xml_escape_the_name(obj_path); - char *t_filename = xml_escape_the_name(filename); - char *t_targname = xml_escape_the_name(targname); + const char *filename; + const char *targname; - /* Create OBJ-XIDs for the parent and object */ - xml_name_to_XID(t_obj_path, linkxid, (int)sizeof(linkxid), 1); - xml_name_to_XID(prefix, parentxid, (int)sizeof(parentxid), 1); + if(H5Lunpack_elink_val(targbuf, linfo->u.val_size, NULL, &filename, &targname) < 0) { + error_msg("unable to unpack external link value\n"); + h5tools_setstatus(EXIT_FAILURE); + ret = FAIL; + } /* end if */ + else { + char linkxid[100]; + char parentxid[100]; + char *t_name = xml_escape_the_name(name); + char *t_prefix = xml_escape_the_name(HDstrcmp(prefix,"") ? prefix : "/"); + char *t_obj_path = xml_escape_the_name(obj_path); + char *t_filename = xml_escape_the_name(filename); + char *t_targname = xml_escape_the_name(targname); - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); + /* Create OBJ-XIDs for the parent and object */ + xml_name_to_XID(t_obj_path, linkxid, (int)sizeof(linkxid), 1); + xml_name_to_XID(prefix, parentxid, (int)sizeof(parentxid), 1); - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sExternalLink LinkName=\"%s\" " - "OBJ-XID=\"%s\" " - "H5SourcePath=\"%s\" " - "TargetFilename=\"%s\" " - "TargetPath=\"%s\" " - "Parents=\"%s\" H5ParentPaths=\"%s\" />", - xmlnsprefix, - t_name, /* LinkName */ - linkxid, /* OBJ-XID */ - t_obj_path, /* H5SourcePath */ - filename, /* TargetFilename */ - targname, /* TargetPath*/ - parentxid, /* Parents */ - t_prefix); /* H5ParentPaths */ - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + ctx.need_prefix = TRUE; + h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - HDfree(t_prefix); - HDfree(t_name); - HDfree(t_filename); - HDfree(t_targname); - HDfree(t_obj_path); + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "<%sExternalLink LinkName=\"%s\" " + "OBJ-XID=\"%s\" " + "H5SourcePath=\"%s\" " + "TargetFilename=\"%s\" " + "TargetPath=\"%s\" " + "Parents=\"%s\" H5ParentPaths=\"%s\" />", + xmlnsprefix, + t_name, /* LinkName */ + linkxid, /* OBJ-XID */ + t_obj_path, /* H5SourcePath */ + filename, /* TargetFilename */ + targname, /* TargetPath*/ + parentxid, /* Parents */ + t_prefix); /* H5ParentPaths */ + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + + HDfree(t_prefix); + HDfree(t_name); + HDfree(t_filename); + HDfree(t_targname); + HDfree(t_obj_path); + } /* end else */ } /* end else */ - } /* end else */ - HDfree(targbuf); + HDfree(targbuf); + } break; case H5L_TYPE_ERROR: case H5L_TYPE_MAX: - HDassert(0); - /* fall through */ case H5L_TYPE_HARD: default: { @@ -674,7 +684,6 @@ xml_escape_the_name(const char *str) for (i = 0; i < len; i++) { size_t esc_len; - HDassert(ncp_len); if (*cp == '\'') { HDstrncpy(ncp, apos, ncp_len); esc_len = HDstrlen(apos); @@ -768,7 +777,6 @@ xml_escape_the_string(const char *str, int slen) for (i = 0; i < len; i++) { size_t esc_len; - HDassert(ncp_len); if (*cp == '\\') { *ncp++ = '\\'; *ncp = *cp; @@ -1514,8 +1522,6 @@ xml_print_datatype(hid_t type, unsigned in_group) case H5T_NO_CLASS: case H5T_NCLASSES: - HDassert(0); - /* fall through */ default: ctx.need_prefix = TRUE; h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); @@ -1968,22 +1974,26 @@ xml_dump_data(hid_t obj_id, int obj_data, struct subset_t H5_ATTR_UNUSED * sset, for (i = 0; i < ndims; i++) nelmts *= size[i]; - buf = HDmalloc((size_t)(nelmts * MAX(H5Tget_size(type), H5Tget_size(p_type)))); - HDassert(buf); - - if (H5Aread(obj_id, p_type, buf) >= 0) { - h5tools_context_t datactx; - HDmemset(&datactx, 0, sizeof(datactx)); - datactx.need_prefix = TRUE; - datactx.indent_level = ctx.indent_level; - datactx.cur_column = ctx.cur_column; - status = h5tools_dump_mem(rawoutstream, outputformat, &datactx, obj_id, p_type, space, buf); + if((buf = HDmalloc((size_t)(nelmts * MAX(H5Tget_size(type), H5Tget_size(p_type))))) == NULL) { + error_msg("unable to allocate buffer\n"); + h5tools_setstatus(EXIT_FAILURE); + status = FAIL; } - /* Reclaim any VL memory, if necessary */ - if (vl_data) - H5Dvlen_reclaim(p_type, space, H5P_DEFAULT, buf); + else { + if (H5Aread(obj_id, p_type, buf) >= 0) { + h5tools_context_t datactx; + HDmemset(&datactx, 0, sizeof(datactx)); + datactx.need_prefix = TRUE; + datactx.indent_level = ctx.indent_level; + datactx.cur_column = ctx.cur_column; + status = h5tools_dump_mem(rawoutstream, outputformat, &datactx, obj_id, p_type, space, buf); + } + /* Reclaim any VL memory, if necessary */ + if (vl_data) + H5Dvlen_reclaim(p_type, space, H5P_DEFAULT, buf); - HDfree(buf); + HDfree(buf); + } } H5Tclose(p_type); H5Sclose(space); @@ -2239,8 +2249,6 @@ xml_dump_attr(hid_t attr, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED break; case H5T_NO_CLASS: case H5T_NCLASSES: - HDassert(0); - /* fall through */ default: ctx.need_prefix = TRUE; h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); @@ -3672,8 +3680,6 @@ xml_dump_fill_value(hid_t dcpl, hid_t type) break; case H5T_NO_CLASS: case H5T_NCLASSES: - HDassert(0); - /* fall through */ case H5T_STRING: case H5T_REFERENCE: default: @@ -3812,91 +3818,95 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t H5_ATTR_UNUSED * s /* Print information about storage layout */ if (H5D_CHUNKED == H5Pget_layout(dcpl)) { - maxdims = H5Sget_simple_extent_ndims(space); - HDassert(maxdims >= 0); - chsize = (hsize_t *)HDmalloc((size_t)maxdims * sizeof(hsize_t)); - ctx.indent_level++; - dump_indent += COL; + if((maxdims = H5Sget_simple_extent_ndims(space)) < 0) { + error_msg("unable to get maxdims\n"); + h5tools_setstatus(EXIT_FAILURE); + } + else { + chsize = (hsize_t *)HDmalloc((size_t)maxdims * sizeof(hsize_t)); + ctx.indent_level++; + dump_indent += COL; - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); + ctx.need_prefix = TRUE; + h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sStorageLayout>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - ctx.indent_level++; - dump_indent += COL; + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "<%sStorageLayout>", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + ctx.indent_level++; + dump_indent += COL; - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); + ctx.need_prefix = TRUE; + h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sChunkedLayout ", xmlnsprefix); - ndims = H5Pget_chunk(dcpl, maxdims, chsize); - h5tools_str_append(&buffer, "Ndims=\"%d\">", ndims); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "<%sChunkedLayout ", xmlnsprefix); + ndims = H5Pget_chunk(dcpl, maxdims, chsize); + h5tools_str_append(&buffer, "Ndims=\"%d\">", ndims); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - ctx.indent_level++; - dump_indent += COL; + ctx.indent_level++; + dump_indent += COL; - for (i = 0; i < ndims; i++) { + for (i = 0; i < ndims; i++) { + + ctx.need_prefix = TRUE; + h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); + + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "<%sChunkDimension DimSize=\"%" H5_PRINTF_LL_WIDTH "u\" />", xmlnsprefix, chsize[i]); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + } ctx.need_prefix = TRUE; h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); /* Render the element */ h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sChunkDimension DimSize=\"%" H5_PRINTF_LL_WIDTH "u\" />", xmlnsprefix, chsize[i]); + h5tools_str_append(&buffer, "<%sRequiredFilter>", xmlnsprefix); h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - } - - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "<%sRequiredFilter>", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - ctx.indent_level++; - dump_indent += COL; - check_filters(dcpl); - ctx.indent_level--; - dump_indent -= COL; + ctx.indent_level++; + dump_indent += COL; + check_filters(dcpl); + ctx.indent_level--; + dump_indent -= COL; - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); + ctx.need_prefix = TRUE; + h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - ctx.indent_level--; - dump_indent -= COL; + ctx.indent_level--; + dump_indent -= COL; - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); + ctx.need_prefix = TRUE; + h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - ctx.indent_level--; - dump_indent -= COL; + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + ctx.indent_level--; + dump_indent -= COL; - ctx.need_prefix = TRUE; - h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); + ctx.need_prefix = TRUE; + h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_append(&buffer, "", xmlnsprefix); - h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - ctx.indent_level--; - dump_indent -= COL; - HDfree(chsize); + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_append(&buffer, "", xmlnsprefix); + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); + ctx.indent_level--; + dump_indent -= COL; + HDfree(chsize); + } } else if (H5D_CONTIGUOUS == H5Pget_layout(dcpl)) { ctx.indent_level++; @@ -3984,8 +3994,6 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t H5_ATTR_UNUSED * s h5tools_str_append(&buffer, "FillIfSet"); break; case H5D_FILL_TIME_ERROR: - HDassert(0); - /* fall through */ default: h5tools_str_append(&buffer, "?"); break; @@ -4005,8 +4013,6 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t H5_ATTR_UNUSED * s break; case H5D_ALLOC_TIME_DEFAULT: case H5D_ALLOC_TIME_ERROR: - HDassert(0); - /* fall through */ default: h5tools_str_append(&buffer, "?"); break; @@ -4233,9 +4239,6 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t H5_ATTR_UNUSED * s break; case H5T_NO_CLASS: case H5T_NCLASSES: - HDassert(0); - /* fall through */ - default: ctx.need_prefix = TRUE; h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); diff --git a/tools/src/h5jam/h5jam.c b/tools/src/h5jam/h5jam.c index a403cf1..8c15686 100644 --- a/tools/src/h5jam/h5jam.c +++ b/tools/src/h5jam/h5jam.c @@ -73,13 +73,13 @@ usage (const char *prog) HDfprintf (stdout, "Adds user block to front of an HDF5 file and creates a new concatenated file.\n"); HDfprintf (stdout, "\n"); - HDfprintf (stdout, + HDfprintf (stdout, "OPTIONS\n"); - HDfprintf (stdout, + HDfprintf (stdout, " -i in_file.h5 Specifies the input HDF5 file.\n"); - HDfprintf (stdout, + HDfprintf (stdout, " -u in_user_file Specifies the file to be inserted into the user block.\n"); - HDfprintf (stdout, + HDfprintf (stdout, " Can be any file format except an HDF5 format.\n"); HDfprintf (stdout, " -o out_file.h5 Specifies the output HDF5 file.\n"); @@ -392,7 +392,7 @@ main (int argc, const char *argv[]) HDfree (input_file); if(output_file) HDfree (output_file); - + if(ufid >= 0) HDclose (ufid); if(h5fid >= 0) @@ -548,7 +548,8 @@ write_pad(int ofile, hsize_t old_where, hsize_t *new_where) char buf[1]; hsize_t psize; - HDassert(new_where); + if(new_where == NULL) + return FAIL; buf[0] = '\0'; diff --git a/tools/src/h5jam/h5unjam.c b/tools/src/h5jam/h5unjam.c index 1cc8cb3..4e9798e 100644 --- a/tools/src/h5jam/h5unjam.c +++ b/tools/src/h5jam/h5unjam.c @@ -133,28 +133,28 @@ static int parse_command_line(int argc, const char *argv[]) { int opt = FALSE; - + /* parse command line options */ while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) { switch((char)opt) { case 'o': output_file = HDstrdup(opt_arg); - if (output_file) - h5tools_set_data_output_file(output_file, 1); - break; + if (output_file) + h5tools_set_data_output_file(output_file, 1); + break; case 'i': input_file = HDstrdup(opt_arg); - if (input_file) - h5tools_set_input_file(input_file, 1); - break;; + if (input_file) + h5tools_set_input_file(input_file, 1); + break;; case 'u': ub_file = HDstrdup(opt_arg); - if (ub_file) - h5tools_set_output_file(ub_file, 1); - else - rawoutstream = stdout; + if (ub_file) + h5tools_set_output_file(ub_file, 1); + else + rawoutstream = stdout; break; case 'd': @@ -180,7 +180,7 @@ parse_command_line(int argc, const char *argv[]) } return EXIT_SUCCESS; - + done: if(input_file) HDfree(input_file); @@ -240,7 +240,7 @@ main(int argc, const char *argv[]) h5tools_setstatus(EXIT_FAILURE); goto done; } - + testval = H5Fis_hdf5(input_file); if (testval <= 0) { @@ -272,10 +272,8 @@ main(int argc, const char *argv[]) goto done; } - status = H5Pclose(plist); - HDassert(status >= 0); - status = H5Fclose(ifile); - HDassert(status >= 0); + H5Pclose(plist); + H5Fclose(ifile); if (usize == 0) { /* no user block to remove: message? */ @@ -303,7 +301,7 @@ main(int argc, const char *argv[]) error_msg("unable to open output HDF5 file \"%s\"\n", input_file); h5tools_setstatus(EXIT_FAILURE); goto done; - } + } /* copy from 0 to 'usize - 1' into ufid */ if (!do_delete) { @@ -321,18 +319,18 @@ main(int argc, const char *argv[]) h5tools_setstatus(EXIT_FAILURE); goto done; } - + done: if(input_file) HDfree(input_file); - + if(output_file) HDfree(output_file); - + if(ub_file) { HDfree(ub_file); } - + h5tools_close(); return h5tools_getstatus(); @@ -374,7 +372,7 @@ copy_to_file( FILE *infid, FILE *ofid, ssize_t _where, ssize_t show_much ) else bytes_in = how_much; - /* Seek to correct position in input file */ + /* Seek to correct position in input file */ HDfseek(infid, from, SEEK_SET); /* Read data to buffer */ @@ -396,11 +394,11 @@ copy_to_file( FILE *infid, FILE *ofid, ssize_t _where, ssize_t show_much ) to += (off_t)bytes_read; /* Write nchars bytes to output file */ - bytes_wrote = HDfwrite(buf, (size_t)1, bytes_read, ofid); - if(bytes_wrote != bytes_read || (0 == bytes_wrote && HDferror(ofid))) { /* error */ - ret_value = -1; - goto done; - } /* end if */ + bytes_wrote = HDfwrite(buf, (size_t)1, bytes_read, ofid); + if(bytes_wrote != bytes_read || (0 == bytes_wrote && HDferror(ofid))) { /* error */ + ret_value = -1; + goto done; + } /* end if */ } /* end while */ done: diff --git a/tools/src/h5ls/h5ls.c b/tools/src/h5ls/h5ls.c index a181186..d397067 100644 --- a/tools/src/h5ls/h5ls.c +++ b/tools/src/h5ls/h5ls.c @@ -1619,9 +1619,9 @@ list_attr(hid_t obj, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED *ain if(space_type != H5S_NULL && space_type != H5S_NO_CLASS) { if(hexdump_g) - p_type = H5Tcopy(type); + p_type = H5Tcopy(type); else - p_type = H5Tget_native_type(type, H5T_DIR_DEFAULT); + p_type = H5Tget_native_type(type, H5T_DIR_DEFAULT); if(p_type >= 0) { /* VL data special information */ @@ -1631,23 +1631,22 @@ list_attr(hid_t obj, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED *ain if (h5tools_detect_vlen(p_type) == TRUE) vl_data = TRUE; - temp_need= nelmts * MAX(H5Tget_size(type), H5Tget_size(p_type)); - HDassert(temp_need == (hsize_t)((size_t)temp_need)); + temp_need = nelmts * MAX(H5Tget_size(type), H5Tget_size(p_type)); need = (size_t)temp_need; - buf = HDmalloc(need); - HDassert(buf); - if(H5Aread(attr, p_type, buf) >= 0) { - ctx.need_prefix = TRUE; - ctx.indent_level = 2; - ctx.cur_column = (size_t)curr_pos; - h5tools_dump_mem(rawoutstream, info, &ctx, attr, p_type, space, buf); - } + if((buf = HDmalloc(need)) != NULL) { + if(H5Aread(attr, p_type, buf) >= 0) { + ctx.need_prefix = TRUE; + ctx.indent_level = 2; + ctx.cur_column = (size_t)curr_pos; + h5tools_dump_mem(rawoutstream, info, &ctx, attr, p_type, space, buf); + } - /* Reclaim any VL memory, if necessary */ - if (vl_data) - H5Dvlen_reclaim(p_type, space, H5P_DEFAULT, buf); + /* Reclaim any VL memory, if necessary */ + if (vl_data) + H5Dvlen_reclaim(p_type, space, H5P_DEFAULT, buf); - HDfree(buf); + HDfree(buf); + } H5Tclose(p_type); } /* end if */ } @@ -1875,7 +1874,7 @@ dataset_list2(hid_t dset, const char H5_ATTR_UNUSED *name) case H5D_LAYOUT_ERROR: case H5D_NLAYOUTS: default: - HDassert(0); + h5tools_str_append(&buffer, "layout information not available"); break; } /* Print total raw storage size */ diff --git a/tools/src/h5repack/h5repack.c b/tools/src/h5repack/h5repack.c index 4860d9e..76ca117 100644 --- a/tools/src/h5repack/h5repack.c +++ b/tools/src/h5repack/h5repack.c @@ -262,7 +262,6 @@ hid_t copy_named_datatype(hid_t type_in, hid_t fidout, /* Check if this type is the one requested */ if (oinfo.addr == dt->addr_in) { - HDassert(!dt_ret); dt_ret = dt; } /* end if */ } /* end if */ diff --git a/tools/src/h5repack/h5repack_copy.c b/tools/src/h5repack/h5repack_copy.c index 946f5ad..501f084 100644 --- a/tools/src/h5repack/h5repack_copy.c +++ b/tools/src/h5repack/h5repack_copy.c @@ -782,7 +782,6 @@ int do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, switch (travt->objs[i].type) { case H5TRAV_TYPE_UNKNOWN: - HDassert(0); break; /*------------------------------------------------------------------------- @@ -1486,7 +1485,6 @@ static int copy_user_block(const char *infile, const char *outfile, hsize_t size int infid = -1, outfid = -1; /* File descriptors */ /* User block must be any power of 2 equal to 512 or greater (512, 1024, 2048, etc.) */ - HDassert(size > 0); /* Open files */ if ((infid = HDopen(infile, O_RDONLY)) < 0) diff --git a/tools/src/h5repack/h5repack_filters.c b/tools/src/h5repack/h5repack_filters.c index 804727b..c48158c 100644 --- a/tools/src/h5repack/h5repack_filters.c +++ b/tools/src/h5repack/h5repack_filters.c @@ -32,37 +32,32 @@ * *------------------------------------------------------------------------- */ -static int -aux_find_obj(const char* name, /* object name from traverse list */ - pack_opt_t *options, /* repack options */ - pack_info_t *obj /*OUT*/) /* info about object to filter */ +static int aux_find_obj(const char* name, /* object name from traverse list */ + pack_opt_t *options, /* repack options */ + pack_info_t *obj /*OUT*/) /* info about object to filter */ { - char *pdest; - int result; - unsigned int i; - - for ( i=0; iop_tbl->nelems; i++) - { - if (HDstrcmp(options->op_tbl->objs[i].path,name)==0) - { - *obj = options->op_tbl->objs[i]; - return (int)i; - } - - pdest = HDstrstr(name,options->op_tbl->objs[i].path); - result = (int)(pdest - name); - - /* found at position 1, meaning without '/' */ - if( pdest != NULL && result==1 ) - { - *obj = options->op_tbl->objs[i]; - return (int)i; - } - }/*i*/ - - return -1; -} + char *pdest; + int result; + unsigned int i; + + for (i = 0; i < options->op_tbl->nelems; i++) { + if (HDstrcmp(options->op_tbl->objs[i].path,name) == 0) { + *obj = options->op_tbl->objs[i]; + return (int) i; + } + pdest = HDstrstr(name, options->op_tbl->objs[i].path); + result = (int) (pdest - name); + + /* found at position 1, meaning without '/' */ + if (pdest != NULL && result == 1) { + *obj = options->op_tbl->objs[i]; + return (int) i; + } + }/*i*/ + + return -1; +} /*------------------------------------------------------------------------- * Function: aux_assign_obj @@ -74,35 +69,31 @@ aux_find_obj(const char* name, /* object name from traverse list */ * *------------------------------------------------------------------------- */ -static int -aux_assign_obj(const char* name, /* object name from traverse list */ - pack_opt_t *options, /* repack options */ - pack_info_t *obj /*OUT*/) /* info about object to filter */ +static int aux_assign_obj(const char* name, /* object name from traverse list */ + pack_opt_t *options, /* repack options */ + pack_info_t *obj /*OUT*/) /* info about object to filter */ { - int idx, i; + int idx, i; pack_info_t tmp; init_packobject(&tmp); - idx = aux_find_obj(name,options,&tmp); + idx = aux_find_obj(name, options, &tmp); /* name was on input */ - if (idx>=0) - { - + if (idx >= 0) { /* applying to all objects */ - if (options->all_layout) - { + if (options->all_layout) { /* assign the global layout info to the OBJ info */ - tmp.layout=options->layout_g; - switch (options->layout_g) - { + tmp.layout = options->layout_g; + switch (options->layout_g) { case H5D_CHUNKED: - tmp.chunk.rank=options->chunk_g.rank; - for ( i=0; ichunk_g.chunk_lengths[i]; + tmp.chunk.rank = options->chunk_g.rank; + for (i = 0; i < tmp.chunk.rank; i++) + tmp.chunk.chunk_lengths[i] = + options->chunk_g.chunk_lengths[i]; break; case H5D_LAYOUT_ERROR: case H5D_COMPACT: @@ -114,15 +105,14 @@ aux_assign_obj(const char* name, /* object name from traverse list */ break; }/*switch*/ } - else - { + else { tmp.layout = options->op_tbl->objs[idx].layout; - switch (tmp.layout) - { + switch (tmp.layout) { case H5D_CHUNKED: tmp.chunk.rank = options->op_tbl->objs[idx].chunk.rank; - for ( i=0; iop_tbl->objs[idx].chunk.chunk_lengths[i]; + for (i = 0; i < tmp.chunk.rank; i++) + tmp.chunk.chunk_lengths[i] = + options->op_tbl->objs[idx].chunk.chunk_lengths[i]; break; case H5D_LAYOUT_ERROR: case H5D_COMPACT: @@ -137,49 +127,37 @@ aux_assign_obj(const char* name, /* object name from traverse list */ } /* applying to all objects */ - if (options->all_filter) - { + if (options->all_filter) { /* assign the global filter */ - tmp.nfilters=1; - tmp.filter[0]=options->filter_g[0]; + tmp.nfilters = 1; + tmp.filter[0] = options->filter_g[0]; } /* if all */ - else - { - tmp.nfilters=options->op_tbl->objs[idx].nfilters; - for ( i=0; iop_tbl->objs[idx].nfilters; + for (i = 0; i < tmp.nfilters; i++) { tmp.filter[i] = options->op_tbl->objs[idx].filter[i]; } } - - } /* if idx */ - - /* no input name */ - - else - { - - if (options->all_filter) - { + else { + if (options->all_filter) { int k; /* assign the global filters */ - tmp.nfilters=options->n_filter_g; - for ( k = 0; k < options->n_filter_g; k++) - tmp.filter[k]=options->filter_g[k]; + tmp.nfilters = options->n_filter_g; + for (k = 0; k < options->n_filter_g; k++) + tmp.filter[k] = options->filter_g[k]; } - if (options->all_layout) - { + if (options->all_layout) { /* assign the global layout info to the OBJ info */ - tmp.layout=options->layout_g; - switch (options->layout_g) - { + tmp.layout = options->layout_g; + switch (options->layout_g) { case H5D_CHUNKED: - tmp.chunk.rank=options->chunk_g.rank; - for ( i=0; ichunk_g.chunk_lengths[i]; + tmp.chunk.rank = options->chunk_g.rank; + for (i = 0; i < tmp.chunk.rank; i++) + tmp.chunk.chunk_lengths[i] = + options->chunk_g.chunk_lengths[i]; break; case H5D_LAYOUT_ERROR: case H5D_COMPACT: @@ -195,10 +173,8 @@ aux_assign_obj(const char* name, /* object name from traverse list */ *obj = tmp; return 1; - } - /*------------------------------------------------------------------------- * Function: apply_filters * @@ -215,74 +191,69 @@ aux_assign_obj(const char* name, /* object name from traverse list */ *------------------------------------------------------------------------- */ -int apply_filters(const char* name, /* object name from traverse list */ - int rank, /* rank of dataset */ - hsize_t *dims, /* dimensions of dataset */ - size_t msize, /* size of type */ - hid_t dcpl_id, /* dataset creation property list */ - pack_opt_t *options, /* repack options */ - int *has_filter) /* (OUT) object NAME has a filter */ - - +int apply_filters(const char* name, /* object name from traverse list */ + int rank, /* rank of dataset */ + hsize_t *dims, /* dimensions of dataset */ + size_t msize, /* size of type */ + hid_t dcpl_id, /* dataset creation property list */ + pack_opt_t *options, /* repack options */ + int *has_filter) /* (OUT) object NAME has a filter */ { - int nfilters; /* number of filters in DCPL */ - hsize_t chsize[64]; /* chunk size in elements */ + int nfilters; /* number of filters in DCPL */ + hsize_t chsize[64]; /* chunk size in elements */ H5D_layout_t layout; - int i; - pack_info_t obj; + int i; + pack_info_t obj; *has_filter = 0; - if (rank==0) /* scalar dataset, do not apply */ + if (rank == 0) /* scalar dataset, do not apply */ return 0; - /*------------------------------------------------------------------------- + /*------------------------------------------------------------------------- * initialize the assigment object *------------------------------------------------------------------------- */ init_packobject(&obj); - /*------------------------------------------------------------------------- + /*------------------------------------------------------------------------- * find options *------------------------------------------------------------------------- */ - if (aux_assign_obj(name,options,&obj)==0) + if (aux_assign_obj(name, options, &obj) == 0) return 0; /* get information about input filters */ - if ((nfilters = H5Pget_nfilters(dcpl_id))<0) + if ((nfilters = H5Pget_nfilters(dcpl_id)) < 0) return -1; - /*------------------------------------------------------------------------- + /*------------------------------------------------------------------------- * check if we have filters in the pipeline * we want to replace them with the input filters * only remove if we are inserting new ones *------------------------------------------------------------------------- */ - if (nfilters && obj.nfilters ) - { + if (nfilters && obj.nfilters) { *has_filter = 1; - if (H5Premove_filter(dcpl_id,H5Z_FILTER_ALL)<0) + if (H5Premove_filter(dcpl_id, H5Z_FILTER_ALL) < 0) return -1; } - /*------------------------------------------------------------------------- + /*------------------------------------------------------------------------- * check if there is an existent chunk * read it only if there is not a requested layout *------------------------------------------------------------------------- */ - if (obj.layout == -1 ) - { - if ((layout = H5Pget_layout(dcpl_id))<0) + if (obj.layout == -1) { + if ((layout = H5Pget_layout(dcpl_id)) < 0) return -1; - if (layout == H5D_CHUNKED) - { - if ((rank = H5Pget_chunk(dcpl_id,NELMTS(chsize),chsize/*out*/))<0) + if (layout == H5D_CHUNKED) { + if ((rank = H5Pget_chunk(dcpl_id, NELMTS(chsize), chsize/*out*/)) < 0) return -1; obj.layout = H5D_CHUNKED; obj.chunk.rank = rank; - for ( i = 0; i < rank; i++) + for (i = 0; i < rank; i++) obj.chunk.chunk_lengths[i] = chsize[i]; } } @@ -300,19 +271,15 @@ int apply_filters(const char* name, /* object name from traverse list */ *------------------------------------------------------------------------- */ - if (obj.nfilters) - { - - /*------------------------------------------------------------------------- - * filters require CHUNK layout; if we do not have one define a default - *------------------------------------------------------------------------- - */ - if (obj.layout==-1) - { - + if (obj.nfilters) { + /*------------------------------------------------------------------------- + * filters require CHUNK layout; if we do not have one define a default + *------------------------------------------------------------------------- + */ + if (obj.layout == -1) { /* stripmine info */ hsize_t sm_size[H5S_MAX_RANK]; /*stripmine size */ - hsize_t sm_nbytes; /*bytes per stripmine */ + hsize_t sm_nbytes; /*bytes per stripmine */ obj.chunk.rank = rank; @@ -321,138 +288,129 @@ int apply_filters(const char* name, /* object name from traverse list */ * a hyperslab whose size is manageable. */ - - sm_nbytes = msize; - for ( i = rank; i > 0; --i) - { + for (i = rank; i > 0; --i) { hsize_t size = H5TOOLS_BUFSIZE / sm_nbytes; - if ( size == 0) /* datum size > H5TOOLS_BUFSIZE */ + if (size == 0) /* datum size > H5TOOLS_BUFSIZE */ size = 1; sm_size[i - 1] = MIN(dims[i - 1], size); sm_nbytes *= sm_size[i - 1]; HDassert(sm_nbytes > 0); - } - for ( i = 0; i < rank; i++) - { + for (i = 0; i < rank; i++) { obj.chunk.chunk_lengths[i] = sm_size[i]; } - } - for ( i=0; i=0) - { + if (obj.layout >= 0) { /* a layout was defined */ - if (H5Pset_layout(dcpl_id, obj.layout)<0) + if (H5Pset_layout(dcpl_id, obj.layout) < 0) return -1; - if (H5D_CHUNKED == obj.layout) - { - if(H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths)<0) + if (H5D_CHUNKED == obj.layout) { + if (H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths) < 0) return -1; } - else if (H5D_COMPACT == obj.layout) - { - if (H5Pset_alloc_time(dcpl_id, H5D_ALLOC_TIME_EARLY)<0) + else if (H5D_COMPACT == obj.layout) { + if (H5Pset_alloc_time(dcpl_id, H5D_ALLOC_TIME_EARLY) < 0) return -1; } /* remove filters for the H5D_CONTIGUOUS case */ - else if (H5D_CONTIGUOUS == obj.layout) - { - if (H5Premove_filter(dcpl_id,H5Z_FILTER_ALL)<0) + else if (H5D_CONTIGUOUS == obj.layout) { + if (H5Premove_filter(dcpl_id, H5Z_FILTER_ALL) < 0) return -1; } } - return 0; + return 0; } diff --git a/tools/src/h5repack/h5repack_refs.c b/tools/src/h5repack/h5repack_refs.c index 408142c..36038b5 100644 --- a/tools/src/h5repack/h5repack_refs.c +++ b/tools/src/h5repack/h5repack_refs.c @@ -189,8 +189,7 @@ int do_copy_refobjs(hid_t fidin, /* create the reference, -1 parameter for objects */ if(H5Rcreate(&refbuf[u], fidout, refname, H5R_OBJECT, (hid_t)-1) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Rcreate failed"); - if(options->verbose) - { + if(options->verbose) { printf(FORMAT_OBJ,"dset",travt->objs[i].name ); printf("object <%s> object reference created to <%s>\n", travt->objs[i].name, @@ -278,8 +277,7 @@ int do_copy_refobjs(hid_t fidin, HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Rcreate failed"); if(H5Sclose(region_id) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sclose failed"); - if(options->verbose) - { + if(options->verbose) { printf(FORMAT_OBJ,"dset",travt->objs[i].name ); printf("object <%s> region reference created to <%s>\n", travt->objs[i].name, @@ -320,8 +318,6 @@ int do_copy_refobjs(hid_t fidin, HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dopen2 failed"); } /* end else */ - HDassert(dset_out != FAIL); - /*------------------------------------------------------------------------- * copy referenced objects in attributes *------------------------------------------------------------------------- -- cgit v0.12 From 0e44181bbb9797bdf4c7b2c192a457639a4e5ea1 Mon Sep 17 00:00:00 2001 From: Binh-Minh Ribler Date: Thu, 24 Aug 2017 13:46:39 -0500 Subject: Miscellaneous improvements Description: Moved H5Location::getNumObjs to Group::getNumObjs (i.e., H5Gget_info) Switched reinterpret_cast to static_cast in H5Object::iterateAttrs Miscellaneous cleanup Platforms tested: Linux/32 2.6 (jam) Linux/64 (platypus) Darwin (osx1010test) --- c++/src/H5CommonFG.cpp | 5 +-- c++/src/H5File.h | 4 +-- c++/src/H5Group.cpp | 93 +++++++++++++++++++++++++++++--------------------- c++/src/H5Group.h | 3 ++ c++/src/H5Location.cpp | 17 --------- c++/src/H5Location.h | 3 -- c++/src/H5Object.cpp | 15 ++++---- 7 files changed, 71 insertions(+), 69 deletions(-) diff --git a/c++/src/H5CommonFG.cpp b/c++/src/H5CommonFG.cpp index c9c203a..af5ba0e 100644 --- a/c++/src/H5CommonFG.cpp +++ b/c++/src/H5CommonFG.cpp @@ -13,8 +13,8 @@ #include -#include "H5Include.h" #include "H5private.h" // for HDstrcpy +#include "H5Include.h" #include "H5Exception.h" #include "H5IdComponent.h" #include "H5DataSpace.h" @@ -64,7 +64,8 @@ DataType CommonFG::openDataType(const char* name) const throwException("openDataType", "H5Topen2 failed"); // No failure, create and return the DataType object - DataType data_type(type_id); + DataType data_type; + f_DataType_setId(&data_type, type_id); return(data_type); } diff --git a/c++/src/H5File.h b/c++/src/H5File.h index b428a40..0f921ae 100644 --- a/c++/src/H5File.h +++ b/c++/src/H5File.h @@ -21,7 +21,7 @@ namespace H5 { \brief Class H5File represents an HDF5 file and inherits from class Group as file is a root group. - Inheritance: Group -> H5Object -> H5Location -> IdComponent + Inheritance: Group -> CommonFG/H5Object -> H5Location -> IdComponent */ class H5_DLLCPP H5File : public Group { public: @@ -92,7 +92,7 @@ class H5_DLLCPP H5File : public Group { // Throw file exception. virtual void throwException(const H5std_string& func_name, const H5std_string& msg) const; - // for CommonFG to get the file id. + // For CommonFG to get the file id. virtual hid_t getLocId() const; // Default constructor diff --git a/c++/src/H5Group.cpp b/c++/src/H5Group.cpp index 994d9ff..c0e0dd1 100644 --- a/c++/src/H5Group.cpp +++ b/c++/src/H5Group.cpp @@ -62,44 +62,6 @@ Group::Group(const Group& original) : H5Object(), CommonFG(), id(original.id) } //-------------------------------------------------------------------------- -// Function: Group::getObjId -///\brief Opens an object via object header. -///\param obj_name - IN: Path to the object -///\param plist - IN: Access property list for the link pointing to -/// the object -///\exception H5::FileIException or H5::GroupIException -///\par Description -/// This function opens an object in a group or file, using -/// H5Oopen. Thus, an object can be opened without knowing -/// the object's type. -// Programmer Binh-Minh Ribler - March, 2017 -//-------------------------------------------------------------------------- -hid_t Group::getObjId(const char* obj_name, const PropList& plist) const -{ - hid_t ret_value = H5Oopen(getId(), obj_name, plist.getId()); - if (ret_value < 0) - { - throwException("Group::getObjId", "H5Oopen failed"); - } - return(ret_value); -} - -//-------------------------------------------------------------------------- -// Function: Group::getObjId -///\brief This is an overloaded member function, provided for convenience. -/// It takes a reference to a \c H5std_string for the object's name. -///\param obj_name - IN: Path to the object -///\param plist - IN: Access property list for the link pointing to -/// the object -///\exception H5::FileIException or H5::GroupIException -// Programmer Binh-Minh Ribler - March, 2017 -//-------------------------------------------------------------------------- -hid_t Group::getObjId(const H5std_string& obj_name, const PropList& plist) const -{ - return(getObjId(obj_name.c_str(), plist)); -} - -//-------------------------------------------------------------------------- // Function: Group::closeObjId ///\brief Closes an object, which was opened with Group::getObjId ///\exception H5::FileIException or H5::GroupIException @@ -181,6 +143,61 @@ Group::Group(const H5Location& loc, const void* ref, H5R_type_t ref_type, const */ //-------------------------------------------------------------------------- +// Function: Group::getNumObjs +///\brief Returns the number of objects in this group. +///\return Number of objects +///\exception H5::FileIException or H5::GroupIException +// Programmer Binh-Minh Ribler - January, 2003 +//-------------------------------------------------------------------------- +hsize_t Group::getNumObjs() const +{ + H5G_info_t ginfo; // Group information + + herr_t ret_value = H5Gget_info(getId(), &ginfo); + if(ret_value < 0) + throwException("getNumObjs", "H5Gget_info failed"); + return (ginfo.nlinks); +} + +//-------------------------------------------------------------------------- +// Function: Group::getObjId +///\brief Opens an object via object header. +///\param obj_name - IN: Path to the object +///\param plist - IN: Access property list for the link pointing to +/// the object +///\exception H5::FileIException or H5::GroupIException +///\par Description +/// This function opens an object in a group or file, using +/// H5Oopen. Thus, an object can be opened without knowing +/// the object's type. +// Programmer Binh-Minh Ribler - March, 2017 +//-------------------------------------------------------------------------- +hid_t Group::getObjId(const char* obj_name, const PropList& plist) const +{ + hid_t ret_value = H5Oopen(getId(), obj_name, plist.getId()); + if (ret_value < 0) + { + throwException("Group::getObjId", "H5Oopen failed"); + } + return(ret_value); +} + +//-------------------------------------------------------------------------- +// Function: Group::getObjId +///\brief This is an overloaded member function, provided for convenience. +/// It takes a reference to a \c H5std_string for the object's name. +///\param obj_name - IN: Path to the object +///\param plist - IN: Access property list for the link pointing to +/// the object +///\exception H5::FileIException or H5::GroupIException +// Programmer Binh-Minh Ribler - March, 2017 +//-------------------------------------------------------------------------- +hid_t Group::getObjId(const H5std_string& obj_name, const PropList& plist) const +{ + return(getObjId(obj_name.c_str(), plist)); +} + +//-------------------------------------------------------------------------- // Function: Group::getId ///\brief Get the id of this group ///\return Group identifier diff --git a/c++/src/H5Group.h b/c++/src/H5Group.h index a7e1f7c..e5fa174 100644 --- a/c++/src/H5Group.h +++ b/c++/src/H5Group.h @@ -53,6 +53,9 @@ class H5_DLLCPP Group : public H5Object, public CommonFG { // Removed in 1.10.1, because H5Location is baseclass // Group(const Attribute& attr, const void* ref, H5R_type_t ref_type = H5R_OBJECT, const PropList& plist = PropList::DEFAULT); + // Returns the number of objects in this group. + hsize_t getNumObjs() const; + // Opens an object within a group or a file, i.e., root group. hid_t getObjId(const char* name, const PropList& plist = PropList::DEFAULT) const; hid_t getObjId(const H5std_string& name, const PropList& plist = PropList::DEFAULT) const; diff --git a/c++/src/H5Location.cpp b/c++/src/H5Location.cpp index e820b0d..a81e300 100644 --- a/c++/src/H5Location.cpp +++ b/c++/src/H5Location.cpp @@ -1282,23 +1282,6 @@ int H5Location::iterateElems(const H5std_string& name, int *idx, H5G_iterate_t o #endif /* H5_NO_DEPRECATED_SYMBOLS */ //-------------------------------------------------------------------------- -// Function: H5Location::getNumObjs -///\brief Returns the number of objects in this group. -///\return Number of objects -///\exception H5::FileIException or H5::GroupIException -// Programmer Binh-Minh Ribler - January, 2003 -//-------------------------------------------------------------------------- -hsize_t H5Location::getNumObjs() const -{ - H5G_info_t ginfo; // Group information - - herr_t ret_value = H5Gget_info(getId(), &ginfo); - if(ret_value < 0) - throwException("getNumObjs", "H5Gget_info failed"); - return (ginfo.nlinks); -} - -//-------------------------------------------------------------------------- // Function: H5Location::getObjnameByIdx ///\brief Returns the name of an object in this group, given the /// object's index. diff --git a/c++/src/H5Location.h b/c++/src/H5Location.h index a57d3ed..41f7ca0 100644 --- a/c++/src/H5Location.h +++ b/c++/src/H5Location.h @@ -113,9 +113,6 @@ class H5_DLLCPP H5Location : public IdComponent { H5std_string getLinkval(const char* link_name, size_t size=0) const; H5std_string getLinkval(const H5std_string& link_name, size_t size=0) const; - // Returns the number of objects in this group. - hsize_t getNumObjs() const; - // Retrieves the name of an object in this group, given the // object's index. H5std_string getObjnameByIdx(hsize_t idx) const; diff --git a/c++/src/H5Object.cpp b/c++/src/H5Object.cpp index 865d04f..81e61e8 100644 --- a/c++/src/H5Object.cpp +++ b/c++/src/H5Object.cpp @@ -44,10 +44,10 @@ namespace H5 { extern "C" herr_t userAttrOpWrpr(hid_t loc_id, const char *attr_name, const H5A_info_t *ainfo, void *op_data) { - H5std_string s_attr_name = H5std_string(attr_name); - UserData4Aiterate* myData = reinterpret_cast (op_data); - myData->op(*myData->location, s_attr_name, myData->opData); - return 0; + H5std_string s_attr_name = H5std_string(attr_name); + UserData4Aiterate* myData = reinterpret_cast (op_data); + myData->op(*myData->location, s_attr_name, myData->opData); + return 0; } //-------------------------------------------------------------------------- @@ -81,6 +81,7 @@ H5Object::H5Object() : H5Location() {} // This constructor is no longer appropriate because the data member "id" had // been moved to the sub-classes. It is removed from 1.8.15 because it is // a noop and it can be generated by the compiler if needed. +// Removed in 1.10.1 - Aug 2016 //-------------------------------------------------------------------------- // H5Object::H5Object(const H5Object& original) : H5Location() {} @@ -148,7 +149,7 @@ Attribute H5Object::createAttribute(const char* name, const DataType& data_type, //-------------------------------------------------------------------------- Attribute H5Object::createAttribute(const H5std_string& name, const DataType& data_type, const DataSpace& data_space, const PropList& create_plist) const { - return(createAttribute( name.c_str(), data_type, data_space, create_plist)); + return(createAttribute(name.c_str(), data_type, data_space, create_plist)); } //-------------------------------------------------------------------------- @@ -183,7 +184,7 @@ Attribute H5Object::openAttribute(const char* name) const //-------------------------------------------------------------------------- Attribute H5Object::openAttribute(const H5std_string& name) const { - return(openAttribute( name.c_str())); + return(openAttribute(name.c_str())); } //-------------------------------------------------------------------------- @@ -239,7 +240,7 @@ int H5Object::iterateAttrs(attr_operator_t user_op, unsigned *_idx, void *op_dat // call the C library routine H5Aiterate2 to iterate the attributes hsize_t idx = _idx ? static_cast(*_idx) : 0; int ret_value = H5Aiterate2(getId(), H5_INDEX_NAME, H5_ITER_INC, &idx, - userAttrOpWrpr, reinterpret_cast(userData)); + userAttrOpWrpr, static_cast(userData)); // release memory delete userData; -- cgit v0.12 From 883a235d5ca81770228c5cb5f9d162afda0b411f Mon Sep 17 00:00:00 2001 From: Binh-Minh Ribler Date: Fri, 25 Aug 2017 12:07:04 -0500 Subject: Miscellaneous improvements (cont.) Description: Put back H5Location::getNumObjs and marked as deprecated in favor of Group::getNumObjs. Platforms tested: Linux/32 2.6 (jam) Darwin (osx1010test) --- c++/src/H5Location.cpp | 17 +++++++++++++++++ c++/src/H5Location.h | 4 ++++ 2 files changed, 21 insertions(+) diff --git a/c++/src/H5Location.cpp b/c++/src/H5Location.cpp index a81e300..9f2d7d5 100644 --- a/c++/src/H5Location.cpp +++ b/c++/src/H5Location.cpp @@ -1282,6 +1282,23 @@ int H5Location::iterateElems(const H5std_string& name, int *idx, H5G_iterate_t o #endif /* H5_NO_DEPRECATED_SYMBOLS */ //-------------------------------------------------------------------------- +// Function: H5Location::getNumObjs +///\brief Deprecated - moved to H5::Group in 1.10.2. +///\return Deprecated +///\exception Deprecated +// Programmer Binh-Minh Ribler - January, 2003 +//-------------------------------------------------------------------------- +hsize_t H5Location::getNumObjs() const +{ + H5G_info_t ginfo; // Group information + + herr_t ret_value = H5Gget_info(getId(), &ginfo); + if(ret_value < 0) + throwException("getNumObjs", "H5Gget_info failed"); + return (ginfo.nlinks); +} + +//-------------------------------------------------------------------------- // Function: H5Location::getObjnameByIdx ///\brief Returns the name of an object in this group, given the /// object's index. diff --git a/c++/src/H5Location.h b/c++/src/H5Location.h index 41f7ca0..3dfa5d5 100644 --- a/c++/src/H5Location.h +++ b/c++/src/H5Location.h @@ -113,6 +113,10 @@ class H5_DLLCPP H5Location : public IdComponent { H5std_string getLinkval(const char* link_name, size_t size=0) const; H5std_string getLinkval(const H5std_string& link_name, size_t size=0) const; + // Returns the number of objects in this group. + // Deprecated - moved to H5::Group in 1.10.2. + hsize_t getNumObjs() const; + // Retrieves the name of an object in this group, given the // object's index. H5std_string getObjnameByIdx(hsize_t idx) const; -- cgit v0.12 From 22baab211d912f1012057b3a7ae217abd2a44a38 Mon Sep 17 00:00:00 2001 From: Richard Warren Date: Mon, 28 Aug 2017 20:05:52 -0400 Subject: Add commentary around calling H5Screate_simple with a single element --- testpar/t_bigio.c | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/testpar/t_bigio.c b/testpar/t_bigio.c index ca2b55d..611ff1a 100644 --- a/testpar/t_bigio.c +++ b/testpar/t_bigio.c @@ -519,6 +519,7 @@ dataset_big_write(void) /* Create a large dataset */ dims[0] = bigcount; dims[1] = mpi_size; + sid = H5Screate_simple (RANK, dims, NULL); VRFY((sid >= 0), "H5Screate_simple succeeded"); dataset = H5Dcreate2(fid, DATASET1, H5T_NATIVE_LLONG, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); @@ -596,6 +597,7 @@ dataset_big_write(void) /* Create a large dataset */ dims[0] = bigcount; dims[1] = mpi_size; + sid = H5Screate_simple (RANK, dims, NULL); VRFY((sid >= 0), "H5Screate_simple succeeded"); dataset = H5Dcreate2(fid, DATASET2, H5T_NATIVE_LLONG, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); @@ -673,6 +675,7 @@ dataset_big_write(void) /* Create a large dataset */ dims[0] = bigcount; dims[1] = 1; + sid = H5Screate_simple (RANK, dims, NULL); VRFY((sid >= 0), "H5Screate_simple succeeded"); dataset = H5Dcreate2(fid, DATASET3, H5T_NATIVE_LLONG, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); @@ -748,6 +751,7 @@ dataset_big_write(void) /* Create a large dataset */ dims[0] = bigcount; dims[1] = mpi_size * 4; + sid = H5Screate_simple (RANK, dims, NULL); VRFY((sid >= 0), "H5Screate_simple succeeded"); dataset = H5Dcreate2(fid, DATASET4, H5T_NATIVE_LLONG, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); @@ -785,6 +789,10 @@ dataset_big_write(void) } /* create a memory dataspace */ + /* Warning: H5Screate_simple requires an array of hsize_t elements + * even if we only pass only a single value. Attempting anything else + * appears to cause problems with 32 bit compilers. + */ mem_dataspace = H5Screate_simple (1, dims, NULL); VRFY((mem_dataspace >= 0), ""); @@ -821,6 +829,7 @@ dataset_big_write(void) /* Create a large dataset */ dims[0] = bigcount/6; dims[1] = mpi_size * 4; + sid = H5Screate_simple (RANK, dims, NULL); VRFY((sid >= 0), "H5Screate_simple succeeded"); dataset = H5Dcreate2(fid, DATASET5, H5T_NATIVE_LLONG, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); @@ -841,7 +850,7 @@ dataset_big_write(void) file_dataspace = H5Dget_space (dataset); VRFY((file_dataspace >= 0), "H5Dget_space succeeded"); - dims[1] = 4; + // dims[1] = 4; /* create a memory dataspace */ mem_dataspace = H5Screate_simple (RANK, dims, NULL); VRFY((mem_dataspace >= 0), ""); @@ -1217,6 +1226,10 @@ dataset_big_read(void) if(coords) free(coords); /* create a memory dataspace */ + /* Warning: H5Screate_simple requires an array of hsize_t elements + * even if we only pass only a single value. Attempting anything else + * appears to cause problems with 32 bit compilers. + */ mem_dataspace = H5Screate_simple (1, dims, NULL); VRFY((mem_dataspace >= 0), ""); @@ -1276,7 +1289,6 @@ dataset_big_read(void) VRFY((file_dataspace >= 0), "H5Dget_space succeeded"); /* create a memory dataspace */ - dims[1] = 4; mem_dataspace = H5Screate_simple (RANK, dims, NULL); VRFY((mem_dataspace >= 0), ""); @@ -1645,7 +1657,6 @@ coll_chunktest(const char* filename, size_t num_points; /* for point selection */ hsize_t *coords = NULL; /* for point selection */ - hsize_t current_dims; /* for point selection */ int i; /* Create the data space */ @@ -1676,6 +1687,10 @@ coll_chunktest(const char* filename, VRFY((coords != NULL), "coords malloc succeeded"); point_set(start, count, stride, block, num_points, coords, mode); + /* Warning: H5Screate_simple requires an array of hsize_t elements + * even if we only pass only a single value. Attempting anything else + * appears to cause problems with 32 bit compilers. + */ file_dataspace = H5Screate_simple(2, dims, NULL); VRFY((file_dataspace >= 0), "file dataspace created succeeded"); @@ -1684,8 +1699,8 @@ coll_chunktest(const char* filename, VRFY((mem_dataspace >= 0), "mem dataspace created succeeded"); } else { - hsize_t dsdims[1] = {num_points}; - current_dims = num_points; + /* Putting the warning about H5Screate_simple (above) into practice... */ + hsize_t dsdims[1] = {num_points}; mem_dataspace = H5Screate_simple (1, dsdims, NULL); VRFY((mem_dataspace >= 0), "mem_dataspace create succeeded"); } @@ -1963,8 +1978,11 @@ coll_chunktest(const char* filename, VRFY((mem_dataspace >= 0), ""); } else { - hsize_t dsdims[1] = {num_points}; - current_dims = num_points; + /* Warning: H5Screate_simple requires an array of hsize_t elements + * even if we only pass only a single value. Attempting anything else + * appears to cause problems with 32 bit compilers. + */ + hsize_t dsdims[1] = {num_points}; mem_dataspace = H5Screate_simple (1, dsdims, NULL); VRFY((mem_dataspace >= 0), "mem_dataspace create succeeded"); } -- cgit v0.12 From 073f52424766cc4a8ac9d56966cb58c054ce3801 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Thu, 31 Aug 2017 13:37:38 -0500 Subject: HDFFV-10284 Add VS2017 support --- bin/release | 4 +- config/cmake/scripts/HDF5config.cmake | 102 +++++++++++++++++----------------- release_docs/INSTALL_CMake.txt | 67 ++++++++++++---------- 3 files changed, 92 insertions(+), 81 deletions(-) diff --git a/bin/release b/bin/release index 09c033d..6358b0d 100755 --- a/bin/release +++ b/bin/release @@ -214,12 +214,12 @@ tar2cmakezip() fi # step 2: add batch file for building CMake on window - cp /mnt/scr1/pre-release/hdf5/CMake/build-VS2012-32.bat $cmziptmpdir - cp /mnt/scr1/pre-release/hdf5/CMake/build-VS2012-64.bat $cmziptmpdir cp /mnt/scr1/pre-release/hdf5/CMake/build-VS2013-32.bat $cmziptmpdir cp /mnt/scr1/pre-release/hdf5/CMake/build-VS2013-64.bat $cmziptmpdir cp /mnt/scr1/pre-release/hdf5/CMake/build-VS2015-32.bat $cmziptmpdir cp /mnt/scr1/pre-release/hdf5/CMake/build-VS2015-64.bat $cmziptmpdir + cp /mnt/scr1/pre-release/hdf5/CMake/build-VS2017-32.bat $cmziptmpdir + cp /mnt/scr1/pre-release/hdf5/CMake/build-VS2017-64.bat $cmziptmpdir # step 3: add SZIP.tar.gz, ZLib.tar.gz and cmake files cp /mnt/scr1/pre-release/hdf5/CMake/SZip.tar.gz $cmziptmpdir diff --git a/config/cmake/scripts/HDF5config.cmake b/config/cmake/scripts/HDF5config.cmake index e500f14..e7b73b3 100755 --- a/config/cmake/scripts/HDF5config.cmake +++ b/config/cmake/scripts/HDF5config.cmake @@ -11,8 +11,8 @@ # ############################################################################################# ### ${CTEST_SCRIPT_ARG} is of the form OPTION=VALUE ### -### BUILD_GENERATOR required [Unix, VS2015, VS201564, VS2013, VS201364, VS2012, VS201264] ### -### ctest -S HDF5config.cmake,BUILD_GENERATOR=VS201264 -C Release -VV -O hdf5.log ### +### BUILD_GENERATOR required [Unix, VS2017, VS201764, VS2015, VS201564, VS2013, VS201364] ### +### ctest -S HDF5config.cmake,BUILD_GENERATOR=VS201764 -C Release -VV -O hdf5.log ### ############################################################################################# cmake_minimum_required (VERSION 3.2.2 FATAL_ERROR) @@ -21,13 +21,13 @@ cmake_minimum_required (VERSION 3.2.2 FATAL_ERROR) # ctest -S HDF5config.cmake,OPTION=VALUE -C Release -VV -O test.log # where valid options for OPTION are: # BUILD_GENERATOR - The cmake build generator: -# Unix * Unix Makefiles +# Unix * Unix Makefiles +# VS2017 * Visual Studio 15 2017 +# VS201764 * Visual Studio 15 2017 Win64 # VS2015 * Visual Studio 14 2015 -# VS201564 * Visual Studio 14 2015 Win64 +# VS201564 * Visual Studio 14 2015 Win64 # VS2013 * Visual Studio 12 2013 -# VS201364 * Visual Studio 12 2013 Win64 -# VS2012 * Visual Studio 11 2012 -# VS201264 * Visual Studio 11 2012 Win64 +# VS201364 * Visual Studio 12 2013 Win64 # # INSTALLDIR - root folder where hdf5 is installed # CTEST_CONFIGURATION_TYPE - Release, Debug, etc @@ -65,25 +65,7 @@ endif () # build generator must be defined if (NOT DEFINED BUILD_GENERATOR) - message (FATAL_ERROR "BUILD_GENERATOR must be defined - Unix, VS2015, VS201564, VS2013, VS201364, VS2012, or VS201264") -else () - if (${BUILD_GENERATOR} STREQUAL "Unix") - set (CTEST_CMAKE_GENERATOR "Unix Makefiles") - elseif (${BUILD_GENERATOR} STREQUAL "VS2015") - set (CTEST_CMAKE_GENERATOR "Visual Studio 14 2015") - elseif (${BUILD_GENERATOR} STREQUAL "VS201564") - set (CTEST_CMAKE_GENERATOR "Visual Studio 14 2015 Win64") - elseif (${BUILD_GENERATOR} STREQUAL "VS2013") - set (CTEST_CMAKE_GENERATOR "Visual Studio 12 2013") - elseif (${BUILD_GENERATOR} STREQUAL "VS201364") - set (CTEST_CMAKE_GENERATOR "Visual Studio 12 2013 Win64") - elseif (${BUILD_GENERATOR} STREQUAL "VS2012") - set (CTEST_CMAKE_GENERATOR "Visual Studio 11 2012") - elseif (${BUILD_GENERATOR} STREQUAL "VS201264") - set (CTEST_CMAKE_GENERATOR "Visual Studio 11 2012 Win64") - else () - message (FATAL_ERROR "Invalid BUILD_GENERATOR must be - Unix, VS2015, VS201564, VS2013, VS201364, VS2012, or VS201264") - endif () + message (FATAL_ERROR "BUILD_GENERATOR must be defined - Unix, VS2017, or VS201764, VS2015, VS201564, VS2013, VS201364") endif () ################################################################### @@ -135,31 +117,49 @@ endif () if (WIN32) set (SITE_OS_NAME "Windows") set (SITE_OS_VERSION "WIN7") - if (${BUILD_GENERATOR} STREQUAL "VS201564") - set (SITE_OS_BITS "64") - set (SITE_COMPILER_NAME "vs2015") - set (SITE_COMPILER_VERSION "14") - elseif (${BUILD_GENERATOR} STREQUAL "VS2015") - set (SITE_OS_BITS "32") - set (SITE_COMPILER_NAME "vs2015") - set (SITE_COMPILER_VERSION "14") - elseif (${BUILD_GENERATOR} STREQUAL "VS201364") - set (SITE_OS_BITS "64") - set (SITE_COMPILER_NAME "vs2013") - set (SITE_COMPILER_VERSION "12") - elseif (${BUILD_GENERATOR} STREQUAL "VS2013") - set (SITE_OS_BITS "32") - set (SITE_COMPILER_NAME "vs2013") - set (SITE_COMPILER_VERSION "12") - elseif (${BUILD_GENERATOR} STREQUAL "VS201264") - set (SITE_OS_BITS "64") - set (SITE_COMPILER_NAME "vs2012") - set (SITE_COMPILER_VERSION "11") - elseif (${BUILD_GENERATOR} STREQUAL "VS2012") - set (SITE_OS_BITS "32") - set (SITE_COMPILER_NAME "vs2012") - set (SITE_COMPILER_VERSION "11") - endif () + if (${BUILD_GENERATOR} STREQUAL "VS201764") + set (CTEST_CMAKE_GENERATOR "Visual Studio 15 2017 Win64") + set (SITE_OS_BITS "64") + set (SITE_COMPILER_NAME "vs2017") + set (SITE_COMPILER_VERSION "15") + elseif (${BUILD_GENERATOR} STREQUAL "VS2017") + set (CTEST_CMAKE_GENERATOR "Visual Studio 15 2017") + set (SITE_OS_BITS "32") + set (SITE_COMPILER_NAME "vs2017") + set (SITE_COMPILER_VERSION "15") + elseif (${BUILD_GENERATOR} STREQUAL "VS201564") + set (CTEST_CMAKE_GENERATOR "Visual Studio 14 2015 Win64") + set (SITE_OS_BITS "64") + set (SITE_COMPILER_NAME "vs2015") + set (SITE_COMPILER_VERSION "14") + elseif (${BUILD_GENERATOR} STREQUAL "VS2015") + set (CTEST_CMAKE_GENERATOR "Visual Studio 14 2015") + set (SITE_OS_BITS "32") + set (SITE_COMPILER_NAME "vs2015") + set (SITE_COMPILER_VERSION "14") + elseif (${BUILD_GENERATOR} STREQUAL "VS201364") + set (CTEST_CMAKE_GENERATOR "Visual Studio 12 2013 Win64") + set (SITE_OS_BITS "64") + set (SITE_COMPILER_NAME "vs2013") + set (SITE_COMPILER_VERSION "12") + elseif (${BUILD_GENERATOR} STREQUAL "VS2013") + set (CTEST_CMAKE_GENERATOR "Visual Studio 12 2013") + set (SITE_OS_BITS "32") + set (SITE_COMPILER_NAME "vs2013") + set (SITE_COMPILER_VERSION "12") + elseif (${BUILD_GENERATOR} STREQUAL "VS201264") + set (CTEST_CMAKE_GENERATOR "Visual Studio 11 2012 Win64") + set (SITE_OS_BITS "64") + set (SITE_COMPILER_NAME "vs2012") + set (SITE_COMPILER_VERSION "11") + elseif (${BUILD_GENERATOR} STREQUAL "VS2012") + set (CTEST_CMAKE_GENERATOR "Visual Studio 11 2012") + set (SITE_OS_BITS "32") + set (SITE_COMPILER_NAME "vs2012") + set (SITE_COMPILER_VERSION "11") + else () + message (FATAL_ERROR "Invalid BUILD_GENERATOR must be - Unix, VS2017, or VS201764, VS2015, VS201564, VS2013, VS201364") + endif () ## Set the following to unique id your computer ## set (CTEST_SITE "WIN7${BUILD_GENERATOR}.XXXX") else () diff --git a/release_docs/INSTALL_CMake.txt b/release_docs/INSTALL_CMake.txt index 7cb0225..e2489f4 100644 --- a/release_docs/INSTALL_CMake.txt +++ b/release_docs/INSTALL_CMake.txt @@ -656,10 +656,21 @@ The same scripts can be used on Linux, Mac OSX or a Windows machine by adding an option (${CTEST_SCRIPT_ARG}) to the platform configuration script. +# +# Copyright by The HDF Group. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the COPYING file, which can be found at the root of the source code +# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. +# If you do not have access to either file, you may request a copy from +# help@hdfgroup.org. +# ############################################################################################# ### ${CTEST_SCRIPT_ARG} is of the form OPTION=VALUE ### -### BUILD_GENERATOR required [Unix, VS2015, VS201564, VS2013, VS201364, VS2012, VS201264] ### -### ctest -S HDF5config.cmake,BUILD_GENERATOR=VS201264 -C Release -VV -O hdf5.log ### +### BUILD_GENERATOR required [Unix, VS2017, VS201764, VS2015, VS201564, VS2013, VS201364] ### +### ctest -S HDF5config.cmake,BUILD_GENERATOR=VS201764 -C Release -VV -O hdf5.log ### ############################################################################################# cmake_minimum_required (VERSION 3.2.2 FATAL_ERROR) @@ -668,13 +679,13 @@ cmake_minimum_required (VERSION 3.2.2 FATAL_ERROR) # ctest -S HDF5config.cmake,OPTION=VALUE -C Release -VV -O test.log # where valid options for OPTION are: # BUILD_GENERATOR - The cmake build generator: -# Unix * Unix Makefiles +# Unix * Unix Makefiles +# VS2017 * Visual Studio 15 2017 +# VS201764 * Visual Studio 15 2017 Win64 # VS2015 * Visual Studio 14 2015 -# VS201564 * Visual Studio 14 2015 Win64 +# VS201564 * Visual Studio 14 2015 Win64 # VS2013 * Visual Studio 12 2013 -# VS201364 * Visual Studio 12 2013 Win64 -# VS2012 * Visual Studio 11 2012 -# VS201264 * Visual Studio 11 2012 Win64 +# VS201364 * Visual Studio 12 2013 Win64 # # INSTALLDIR - root folder where hdf5 is installed # CTEST_CONFIGURATION_TYPE - Release, Debug, etc @@ -685,7 +696,7 @@ cmake_minimum_required (VERSION 3.2.2 FATAL_ERROR) # NO_MAC_FORTRAN - Yes to be SHARED on a Mac ############################################################################## -set (CTEST_SOURCE_VERSION 1.10.1) +set (CTEST_SOURCE_VERSION "1.11.0") set (CTEST_SOURCE_VERSEXT "") ############################################################################## @@ -712,25 +723,7 @@ endif () # build generator must be defined if (NOT DEFINED BUILD_GENERATOR) - message (FATAL_ERROR "BUILD_GENERATOR must be defined - Unix, VS2015, VS201564, VS2013, VS201364, VS2012, or VS201264") -else () - if (${BUILD_GENERATOR} STREQUAL "Unix") - set (CTEST_CMAKE_GENERATOR "Unix Makefiles") - elseif (${BUILD_GENERATOR} STREQUAL "VS2015") - set (CTEST_CMAKE_GENERATOR "Visual Studio 14 2015") - elseif (${BUILD_GENERATOR} STREQUAL "VS201564") - set (CTEST_CMAKE_GENERATOR "Visual Studio 14 2015 Win64") - elseif (${BUILD_GENERATOR} STREQUAL "VS2013") - set (CTEST_CMAKE_GENERATOR "Visual Studio 12 2013") - elseif (${BUILD_GENERATOR} STREQUAL "VS201364") - set (CTEST_CMAKE_GENERATOR "Visual Studio 12 2013 Win64") - elseif (${BUILD_GENERATOR} STREQUAL "VS2012") - set (CTEST_CMAKE_GENERATOR "Visual Studio 11 2012") - elseif (${BUILD_GENERATOR} STREQUAL "VS201264") - set (CTEST_CMAKE_GENERATOR "Visual Studio 11 2012 Win64") - else () - message (FATAL_ERROR "Invalid BUILD_GENERATOR must be - Unix, VS2015, VS201564, VS2013, VS201364, VS2012, or VS201264") - endif () + message (FATAL_ERROR "BUILD_GENERATOR must be defined - Unix, VS2017, or VS201764, VS2015, VS201564, VS2013, VS201364") endif () ################################################################### @@ -782,30 +775,48 @@ endif () if (WIN32) set (SITE_OS_NAME "Windows") set (SITE_OS_VERSION "WIN7") - if (${BUILD_GENERATOR} STREQUAL "VS201564") + if (${BUILD_GENERATOR} STREQUAL "VS201764") + set (CTEST_CMAKE_GENERATOR "Visual Studio 15 2017 Win64") + set (SITE_OS_BITS "64") + set (SITE_COMPILER_NAME "vs2017") + set (SITE_COMPILER_VERSION "15") + elseif (${BUILD_GENERATOR} STREQUAL "VS2017") + set (CTEST_CMAKE_GENERATOR "Visual Studio 15 2017") + set (SITE_OS_BITS "32") + set (SITE_COMPILER_NAME "vs2017") + set (SITE_COMPILER_VERSION "15") + elseif (${BUILD_GENERATOR} STREQUAL "VS201564") + set (CTEST_CMAKE_GENERATOR "Visual Studio 14 2015 Win64") set (SITE_OS_BITS "64") set (SITE_COMPILER_NAME "vs2015") set (SITE_COMPILER_VERSION "14") elseif (${BUILD_GENERATOR} STREQUAL "VS2015") + set (CTEST_CMAKE_GENERATOR "Visual Studio 14 2015") set (SITE_OS_BITS "32") set (SITE_COMPILER_NAME "vs2015") set (SITE_COMPILER_VERSION "14") elseif (${BUILD_GENERATOR} STREQUAL "VS201364") + set (CTEST_CMAKE_GENERATOR "Visual Studio 12 2013 Win64") set (SITE_OS_BITS "64") set (SITE_COMPILER_NAME "vs2013") set (SITE_COMPILER_VERSION "12") elseif (${BUILD_GENERATOR} STREQUAL "VS2013") + set (CTEST_CMAKE_GENERATOR "Visual Studio 12 2013") set (SITE_OS_BITS "32") set (SITE_COMPILER_NAME "vs2013") set (SITE_COMPILER_VERSION "12") elseif (${BUILD_GENERATOR} STREQUAL "VS201264") + set (CTEST_CMAKE_GENERATOR "Visual Studio 11 2012 Win64") set (SITE_OS_BITS "64") set (SITE_COMPILER_NAME "vs2012") set (SITE_COMPILER_VERSION "11") elseif (${BUILD_GENERATOR} STREQUAL "VS2012") + set (CTEST_CMAKE_GENERATOR "Visual Studio 11 2012") set (SITE_OS_BITS "32") set (SITE_COMPILER_NAME "vs2012") set (SITE_COMPILER_VERSION "11") + else () + message (FATAL_ERROR "Invalid BUILD_GENERATOR must be - Unix, VS2017, or VS201764, VS2015, VS201564, VS2013, VS201364") endif () ## Set the following to unique id your computer ## set (CTEST_SITE "WIN7${BUILD_GENERATOR}.XXXX") -- cgit v0.12