diff options
author | Allen Byrne <byrn@hdfgroup.org> | 2016-09-28 18:06:02 (GMT) |
---|---|---|
committer | Allen Byrne <byrn@hdfgroup.org> | 2016-09-28 18:06:02 (GMT) |
commit | 208cfdc941bd911253051dc496c087dae6012241 (patch) | |
tree | a91d11ade122596d7e7eb44f8468efd2a50d7d38 /tools/h5dump | |
parent | 50d3fc7a61f4b1dbe2ead376b778f5743060cc6e (diff) | |
download | hdf5-208cfdc941bd911253051dc496c087dae6012241.zip hdf5-208cfdc941bd911253051dc496c087dae6012241.tar.gz hdf5-208cfdc941bd911253051dc496c087dae6012241.tar.bz2 |
Merge/align from trunk(develop)
Diffstat (limited to 'tools/h5dump')
-rw-r--r-- | tools/h5dump/h5dump.c | 104 | ||||
-rw-r--r-- | tools/h5dump/h5dump.h | 19 | ||||
-rw-r--r-- | tools/h5dump/h5dump_ddl.c | 345 |
3 files changed, 236 insertions, 232 deletions
diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c index 5b953cb..9efb6db 100644 --- a/tools/h5dump/h5dump.c +++ b/tools/h5dump/h5dump.c @@ -620,10 +620,9 @@ parse_hsize_list(const char *h_list, subset_d *d) size_count++; last_digit = 1; - } - else { - last_digit = 0; } + else + last_digit = 0; if (size_count == 0) /* there aren't any integers to read */ @@ -635,7 +634,7 @@ parse_hsize_list(const char *h_list, subset_d *d) for (ptr = h_list; i < size_count && ptr && *ptr && *ptr != ';' && *ptr != ']'; ptr++) if(HDisdigit(*ptr)) { /* we should have an integer now */ - p_list[i++] = (hsize_t)HDatof(ptr); + p_list[i++] = (hsize_t)HDstrtoull(ptr, NULL, 0); while (HDisdigit(*ptr)) /* scroll to end of integer */ @@ -643,8 +642,6 @@ parse_hsize_list(const char *h_list, subset_d *d) } d->data = p_list; d->len = size_count; - - return; } /*------------------------------------------------------------------------- @@ -667,7 +664,7 @@ static struct subset_t * parse_subset_params(char *dset) { struct subset_t *s = NULL; - register char *brace; + char *brace; if (!disable_compact_subset && ((brace = HDstrrchr(dset, '[')) != NULL)) { *brace++ = '\0'; @@ -705,20 +702,21 @@ parse_subset_params(char *dset) * * Purpose: Parse a list of comma or space separated integers and fill * the packed_bits list and counter. The string being passed into this function - * should be at the start of the list you want to parse. + * should be at the start of the list you want to parse. * * Return: Success: SUCCEED * * Failure: FAIL * - * *------------------------------------------------------------------------- */ static int parse_mask_list(const char *h_list) { - int offset_value; - int length_value; + int soffset_value; + unsigned offset_value; + int slength_value; + unsigned length_value; unsigned long long temp_mask; const char *ptr = NULL; @@ -736,10 +734,11 @@ parse_mask_list(const char *h_list) error_msg("Bad mask list(%s)\n", h_list); return FAIL; } - offset_value = HDatoi(ptr); - if (offset_value < 0 || offset_value >= PACKED_BITS_SIZE_MAX) { - error_msg("Packed Bit offset value(%d) must be between 0 and %d\n", - offset_value, PACKED_BITS_SIZE_MAX - 1); + 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; } @@ -757,14 +756,15 @@ parse_mask_list(const char *h_list) error_msg("Bad mask list(%s)\n", h_list); return FAIL; } - length_value = HDatoi(ptr); - if (length_value <= 0) { - error_msg("Packed Bit length value(%d) must be positive.\n", length_value); + slength_value = HDatoi(ptr); + if (slength_value <= 0) { + error_msg("Packed Bit length value(%d) must be positive.\n", slength_value); return FAIL; } - if ((offset_value + length_value) > PACKED_BITS_SIZE_MAX){ - error_msg("Packed Bit offset+length value(%d) too large. Max is %d\n", - offset_value+length_value, PACKED_BITS_SIZE_MAX); + 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; } @@ -783,8 +783,8 @@ parse_mask_list(const char *h_list) /* 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 = ~0L; - if(length_value<8*sizeof(unsigned long long)) { + 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; } @@ -831,7 +831,7 @@ static void free_handler(struct handler_t *hand, int len) { int i; - + if(hand) { for (i = 0; i < len; i++) { if(hand[i].obj) { @@ -956,11 +956,15 @@ parse_start: goto done; break; case 'w': - h5tools_nCols = HDatoi(opt_arg); - if (h5tools_nCols <= 0) { - h5tools_nCols = 65535; + { + int sh5tools_nCols = HDatoi(opt_arg); + + if (sh5tools_nCols <= 0) + h5tools_nCols = 65535; + else + h5tools_nCols = (unsigned)sh5tools_nCols; + last_was_dset = FALSE; } - last_was_dset = FALSE; break; case 'N': display_all = 0; @@ -1159,12 +1163,10 @@ parse_start: usage(h5tools_getprogname()); goto error; } - if (HDstrcmp(opt_arg,":") == 0) { + if (HDstrcmp(opt_arg,":") == 0) xmlnsprefix = ""; - } - else { + else xmlnsprefix = opt_arg; - } h5tools_nCols = 0; break; /** end XML parameters **/ @@ -1187,7 +1189,7 @@ parse_start: * the two. */ s = last_dset->subset_info; - } + } else { last_dset->subset_info = s = (struct subset_t *)HDcalloc(1, sizeof(struct subset_t)); } @@ -1358,7 +1360,7 @@ main(int argc, const char *argv[]) /* Disable tools error reporting */ H5Eget_auto2(H5tools_ERR_STACK_g, &tools_func, &tools_edata); H5Eset_auto2(H5tools_ERR_STACK_g, NULL, NULL); - + if((hand = parse_command_line(argc, argv))==NULL) { goto done; } @@ -1444,12 +1446,12 @@ main(int argc, const char *argv[]) if (xml_dtd_uri == NULL) { if (useschema) { xml_dtd_uri = DEFAULT_XSD; - } + } else { xml_dtd_uri = DEFAULT_DTD; xmlnsprefix = ""; } - } + } else { if (useschema && HDstrcmp(xmlnsprefix,"")) { error_msg("Cannot set Schema URL for a qualified namespace--use -X or -U option with -D \n"); @@ -1486,7 +1488,7 @@ main(int argc, const char *argv[]) /* start to dump - display file header information */ if (!doxml) { begin_obj(h5tools_dump_header_format->filebegin, fname, h5tools_dump_header_format->fileblockbegin); - } + } else { PRINTVALSTREAM(rawoutstream, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); @@ -1495,7 +1497,7 @@ main(int argc, const char *argv[]) if (HDstrcmp(xmlnsprefix,"") == 0) { PRINTSTREAM(rawoutstream, "<HDF5-File xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"%s\">\n", xml_dtd_uri); - } + } else { /* TO DO: make -url option work in this case (may need new option) */ char *ns; @@ -1511,7 +1513,7 @@ main(int argc, const char *argv[]) "http://www.hdfgroup.org/HDF5/XML/schema/HDF5-File.xsd\">\n",xmlnsprefix,ns); HDfree(ns); } - } + } else { PRINTSTREAM(rawoutstream, "<!DOCTYPE HDF5-File PUBLIC \"HDF5-File.dtd\" \"%s\">\n", xml_dtd_uri); PRINTVALSTREAM(rawoutstream, "<HDF5-File>\n"); @@ -1570,7 +1572,7 @@ main(int argc, const char *argv[]) if (!doxml) { end_obj(h5tools_dump_header_format->fileend, h5tools_dump_header_format->fileblockend); PRINTVALSTREAM(rawoutstream, "\n"); - } + } else { PRINTSTREAM(rawoutstream, "</%sHDF5-File>\n", xmlnsprefix); } @@ -1591,7 +1593,7 @@ main(int argc, const char *argv[]) } } /* end while */ - if(hand) + if(hand) free_handler(hand, argc); /* To Do: clean up XML table */ @@ -1615,7 +1617,7 @@ done: fname = NULL; } - if(hand) + if(hand) free_handler(hand, argc); /* To Do: clean up XML table */ @@ -1668,20 +1670,20 @@ h5_fileaccess(void) if (!HDstrcmp(name, "sec2")) { /* Unix read() and write() system calls */ if (H5Pset_fapl_sec2(fapl)<0) return -1; - } + } else if (!HDstrcmp(name, "stdio")) { /* Standard C fread() and fwrite() system calls */ if (H5Pset_fapl_stdio(fapl)<0) return -1; - } + } else if (!HDstrcmp(name, "core")) { /* In-core temporary file with 1MB increment */ if (H5Pset_fapl_core(fapl, 1024*1024, FALSE)<0) return -1; - } + } else if (!HDstrcmp(name, "split")) { /* Split meta data and raw data each using default driver */ if (H5Pset_fapl_split(fapl, "-m.h5", H5P_DEFAULT, "-r.h5", H5P_DEFAULT) < 0) return -1; - } + } else if (!HDstrcmp(name, "multi")) { /* Multi-file driver, general case of the split driver */ H5FD_mem_t memb_map[H5FD_MEM_NTYPES]; @@ -1702,12 +1704,12 @@ h5_fileaccess(void) memb_map[mt] = mt; sprintf(sv[mt], "%%s-%c.h5", multi_letters[mt]); memb_name[mt] = sv[mt]; - memb_addr[mt] = MAX(mt-1,0)*(HADDR_MAX/10); + memb_addr[mt] = (haddr_t)MAX(mt - 1, 0) * (HADDR_MAX / 10); } if (H5Pset_fapl_multi(fapl, memb_map, memb_fapl, memb_name, memb_addr, FALSE) < 0) return -1; - } + } else if (!HDstrcmp(name, "family")) { hsize_t fam_size = 100*1024*1024; /*100 MB*/ @@ -1716,7 +1718,7 @@ h5_fileaccess(void) fam_size = (hsize_t)(HDstrtod(val, NULL) * 1024*1024); if (H5Pset_fapl_family(fapl, fam_size, H5P_DEFAULT)<0) return -1; - } + } else if (!HDstrcmp(name, "log")) { long log_flags = H5FD_LOG_LOC_IO; @@ -1726,12 +1728,12 @@ h5_fileaccess(void) if (H5Pset_fapl_log(fapl, NULL, (unsigned)log_flags, 0) < 0) return -1; - } + } else if (!HDstrcmp(name, "direct")) { /* Substitute Direct I/O driver with sec2 driver temporarily because * some output has sec2 driver as the standard. */ if (H5Pset_fapl_sec2(fapl)<0) return -1; - } + } else { /* Unknown driver */ return -1; diff --git a/tools/h5dump/h5dump.h b/tools/h5dump/h5dump.h index a1f5b22..e9b8233 100644 --- a/tools/h5dump/h5dump.h +++ b/tools/h5dump/h5dump.h @@ -39,11 +39,11 @@ typedef struct dump_functions_t { /* List of table structures. There is one table structure for each file */ typedef struct h5dump_table_items_t { - unsigned long fileno; /* File number that these tables refer to */ - hid_t oid; /* ID of an object in this file, held open so fileno is consistent */ - table_t *group_table; /* Table of groups */ - table_t *dset_table; /* Table of datasets */ - table_t *type_table; /* Table of datatypes */ + unsigned long fileno; /* File number that these tables refer to */ + hid_t oid; /* ID of an object in this file, held open so fileno is consistent */ + table_t *group_table; /* Table of groups */ + table_t *dset_table; /* Table of datasets */ + table_t *type_table; /* Table of datatypes */ } h5dump_table_items_t; typedef struct h5dump_table_list_t { size_t nalloc; @@ -53,7 +53,7 @@ typedef struct h5dump_table_list_t { h5dump_table_list_t table_list = {0, 0, NULL}; table_t *group_table = NULL, *dset_table = NULL, *type_table = NULL; -int dump_indent = 0; /*how far in to indent the line */ +unsigned dump_indent = 0; /*how far in to indent the line */ int unamedtype = 0; /* shared datatype with no name */ hbool_t hit_elink = FALSE; /* whether we have traversed an external link */ @@ -74,7 +74,6 @@ int display_fi = FALSE; /*file index */ int display_ai = TRUE; /*array index */ int display_escape = FALSE; /*escape non printable characters */ int display_region = FALSE; /*print region reference data */ -int enable_error_stack= FALSE; /* re-enable error stack */ int disable_compact_subset= FALSE; /* disable compact form of subset notation */ int display_packed_bits = FALSE; /*print 1-8 byte numbers as packed bits*/ int include_attrs = TRUE; /* Display attributes */ @@ -84,13 +83,13 @@ H5_index_t sort_by = H5_INDEX_NAME; /*sort_by [creation_order | name H5_iter_order_t sort_order = H5_ITER_INC; /*sort_order [ascending | descending] */ #define PACKED_BITS_MAX 8 /* Maximum number of packed-bits to display */ -#define PACKED_BITS_SIZE_MAX 8*sizeof(long long) /* Maximum bits size of integer types of packed-bits */ +#define PACKED_BITS_SIZE_MAX (8*sizeof(long long)) /* Maximum bits size of integer types of packed-bits */ /* mask list for packed bits */ unsigned long long packed_mask[PACKED_BITS_MAX]; /* packed bits are restricted to 8*sizeof(llong) bytes */ /* packed bits display parameters */ -int packed_offset[PACKED_BITS_MAX]; -int packed_length[PACKED_BITS_MAX]; +unsigned packed_offset[PACKED_BITS_MAX]; +unsigned packed_length[PACKED_BITS_MAX]; /* * The global table is set to either ddl_function_table or diff --git a/tools/h5dump/h5dump_ddl.c b/tools/h5dump/h5dump_ddl.c index 0324a52..c0b1833 100644 --- a/tools/h5dump/h5dump_ddl.c +++ b/tools/h5dump/h5dump_ddl.c @@ -26,12 +26,12 @@ typedef struct { hid_t fid; /* File ID being traversed */ - char *op_name; /* Object name wanted */ + const char *op_name; /* Object name wanted */ } trav_handle_udata_t; typedef struct { - char *path; /* Path of object being searched */ - char *op_name; /* Object name wanted */ + const char *path; /* Path of object being searched */ + const char *op_name; /* Object name wanted */ } trav_attr_udata_t; /* callback function used by H5Literate() */ @@ -59,7 +59,7 @@ dump_datatype(hid_t type) h5tool_format_t *outputformat = &h5tools_dataformat; HDmemset(&ctx, 0, sizeof(ctx)); - ctx.indent_level = dump_indent/COL; + ctx.indent_level = dump_indent / COL; ctx.cur_column = dump_indent; h5dump_type_table = type_table; @@ -88,9 +88,9 @@ dump_dataspace(hid_t space) h5tool_format_t *outputformat = &h5tools_dataformat; HDmemset(&ctx, 0, sizeof(ctx)); - ctx.indent_level = dump_indent/COL; + ctx.indent_level = dump_indent / COL; ctx.cur_column = dump_indent; - + h5tools_dump_dataspace(rawoutstream, outputformat, &ctx, space); } @@ -117,19 +117,19 @@ dump_attr_cb(hid_t oid, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED * h5tools_context_t ctx; /* print context */ h5tool_format_t *outputformat = &h5tools_dataformat; h5tool_format_t string_dataformat; - + hid_t attr_id; herr_t ret = SUCCEED; HDmemset(&ctx, 0, sizeof(ctx)); - ctx.indent_level = dump_indent/COL; + ctx.indent_level = dump_indent / COL; ctx.cur_column = dump_indent; - + attr_id = H5Aopen(oid, attr_name, H5P_DEFAULT); oid_output = display_oid; data_output = display_data; attr_data_output = display_attr_data; - + string_dataformat = *outputformat; if (fp_format) { @@ -137,7 +137,7 @@ dump_attr_cb(hid_t oid, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED * string_dataformat.fmt_float = fp_format; } - if (h5tools_nCols==0) { + if (h5tools_nCols == 0) { string_dataformat.line_ncols = 65535; string_dataformat.line_per_line = 1; } @@ -155,7 +155,7 @@ dump_attr_cb(hid_t oid, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED * h5tools_setstatus(EXIT_FAILURE); ret = FAIL; } - + return ret; } @@ -197,9 +197,9 @@ dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void H5_ATTR HDmemset(&buffer, 0, sizeof(h5tools_str_t)); HDmemset(&ctx, 0, sizeof(ctx)); - ctx.indent_level = dump_indent/COL; + ctx.indent_level = dump_indent / COL; ctx.cur_column = dump_indent; - + string_dataformat = *outputformat; if (fp_format) { @@ -207,7 +207,7 @@ dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void H5_ATTR string_dataformat.fmt_float = fp_format; } - if (h5tools_nCols==0) { + if (h5tools_nCols == 0) { string_dataformat.line_ncols = 65535; string_dataformat.line_per_line = 1; } @@ -222,8 +222,8 @@ dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void H5_ATTR if(!obj_path) { ret = FAIL; goto done; - } - + } + HDstrcpy(obj_path, prefix); HDstrcat(obj_path, "/"); HDstrcat(obj_path, name); @@ -310,7 +310,7 @@ dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void H5_ATTR ret = FAIL; H5Dclose(obj); goto done; - } + } else if(found_obj->displayed) { ctx.need_prefix = TRUE; h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); @@ -349,7 +349,7 @@ dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void H5_ATTR H5Dclose(obj); goto done; - } + } else { found_obj->displayed = TRUE; } @@ -357,7 +357,7 @@ dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void H5_ATTR dump_function_table->dump_dataset_function(obj, name, NULL); H5Dclose(obj); - } + } else { error_msg("unable to dump dataset \"%s\"\n", name); h5tools_setstatus(EXIT_FAILURE); @@ -370,7 +370,7 @@ dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void H5_ATTR error_msg("unable to dump datatype \"%s\"\n", name); h5tools_setstatus(EXIT_FAILURE); ret = FAIL; - } + } else { dump_function_table->dump_named_datatype_function(obj, name); H5Tclose(obj); @@ -408,7 +408,7 @@ dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void H5_ATTR 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 */ @@ -558,7 +558,7 @@ dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void H5_ATTR done: h5tools_str_close(&buffer); - + if(obj_path) HDfree(obj_path); return ret; @@ -648,9 +648,9 @@ dump_named_datatype(hid_t tid, const char *name) HDmemset(&buffer, 0, sizeof(h5tools_str_t)); HDmemset(&ctx, 0, sizeof(ctx)); - ctx.indent_level = dump_indent/COL; + ctx.indent_level = dump_indent / COL; ctx.cur_column = dump_indent; - + string_dataformat = *outputformat; if (fp_format) { @@ -658,7 +658,7 @@ dump_named_datatype(hid_t tid, const char *name) string_dataformat.fmt_float = fp_format; } - if (h5tools_nCols==0) { + if (h5tools_nCols == 0) { string_dataformat.line_ncols = 65535; string_dataformat.line_per_line = 1; } @@ -685,7 +685,7 @@ dump_named_datatype(hid_t tid, const char *name) } ctx.need_prefix = TRUE; - + /* Render the element */ h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "%s \"%s\" %s", @@ -718,7 +718,7 @@ dump_named_datatype(hid_t tid, const char *name) else found_obj->displayed = TRUE; } /* end if */ - + /* Render the element */ h5tools_str_reset(&buffer); h5tools_print_datatype(rawoutstream, &buffer, outputformat, &ctx, tid, FALSE); @@ -726,7 +726,7 @@ dump_named_datatype(hid_t tid, const char *name) if(H5Tget_class(tid) != H5T_COMPOUND) { h5tools_str_append(&buffer, ";"); } - + h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); /* print attributes */ @@ -811,9 +811,9 @@ dump_group(hid_t gid, const char *name) HDmemset(&buffer, 0, sizeof(h5tools_str_t)); HDmemset(&ctx, 0, sizeof(ctx)); - ctx.indent_level = dump_indent/COL; + ctx.indent_level = dump_indent / COL; ctx.cur_column = dump_indent; - + string_dataformat = *outputformat; if (fp_format) { @@ -821,7 +821,7 @@ dump_group(hid_t gid, const char *name) string_dataformat.fmt_float = fp_format; } - if (h5tools_nCols==0) { + if (h5tools_nCols == 0) { string_dataformat.line_ncols = 65535; string_dataformat.line_per_line = 1; } @@ -839,7 +839,7 @@ dump_group(hid_t gid, const char *name) h5tools_dump_header_format->groupbegin, name, h5tools_dump_header_format->groupblockbegin); 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; @@ -858,9 +858,8 @@ dump_group(hid_t gid, const char *name) } } /* end if */ - if(display_oid) { + if(display_oid) h5tools_dump_oid(rawoutstream, outputformat, &ctx, gid); - } h5tools_dump_comment(rawoutstream, outputformat, &ctx, gid); @@ -946,9 +945,9 @@ dump_dataset(hid_t did, const char *name, struct subset_t *sset) hsize_t curr_pos = 0; /* total data element position */ HDmemset(&ctx, 0, sizeof(ctx)); - ctx.indent_level = dump_indent/COL; + ctx.indent_level = dump_indent / COL; ctx.cur_column = dump_indent; - + string_dataformat = *outputformat; if (fp_format) { @@ -956,7 +955,7 @@ dump_dataset(hid_t did, const char *name, struct subset_t *sset) string_dataformat.fmt_float = fp_format; } - if (h5tools_nCols==0) { + if (h5tools_nCols == 0) { string_dataformat.line_ncols = 65535; string_dataformat.line_per_line = 1; } @@ -982,7 +981,7 @@ dump_dataset(hid_t did, const char *name, struct subset_t *sset) 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, "%s \"%s\" %s", @@ -994,7 +993,7 @@ dump_dataset(hid_t did, const char *name, struct subset_t *sset) dump_indent += COL; ctx.indent_level++; - + type = H5Dget_type(did); h5dump_type_table = type_table; h5tools_dump_datatype(rawoutstream, outputformat, &ctx, type); @@ -1016,19 +1015,20 @@ dump_dataset(hid_t did, const char *name, struct subset_t *sset) H5Pclose(dcpl_id); if(display_data) { - int data_loop = 1; - int i; + unsigned data_loop = 1; + unsigned u; + if(display_packed_bits) data_loop = packed_bits_num; - for(i=0; i<data_loop; i++) { + for(u = 0; u < data_loop; u++) { if(display_packed_bits) { ctx.need_prefix = TRUE; h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0); /* Render the element */ h5tools_str_reset(&buffer); - packed_data_mask = packed_mask[i]; - packed_data_offset = packed_offset[i]; - packed_data_length = packed_length[i]; + packed_data_mask = packed_mask[u]; + packed_data_offset = packed_offset[u]; + packed_data_length = packed_length[u]; h5tools_print_packed_bits(&buffer, type); h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); } @@ -1042,7 +1042,7 @@ dump_dataset(hid_t did, const char *name, struct subset_t *sset) h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "DATA{ not yet implemented.}"); h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - + ctx.indent_level--; break; @@ -1067,7 +1067,7 @@ dump_dataset(hid_t did, const char *name, struct subset_t *sset) HDassert(0); break; } /* end switch */ - } /* for(i=0;i<data_loop;i++) */ + } /* for(u=0; u<data_loop; u++) */ } H5Tclose(type); @@ -1079,7 +1079,7 @@ dump_dataset(hid_t did, const char *name, struct subset_t *sset) 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->datasetblockend)) { @@ -1124,7 +1124,7 @@ dump_data(hid_t obj_id, int obj_data, struct subset_t *sset, int display_index) string_dataformat.fmt_float = fp_format; } - if (h5tools_nCols==0) { + if (h5tools_nCols == 0) { string_dataformat.line_ncols = 65535; string_dataformat.line_per_line = 1; } @@ -1135,7 +1135,7 @@ dump_data(hid_t obj_id, int obj_data, struct subset_t *sset, int display_index) outputformat = &string_dataformat; HDmemset(&ctx, 0, sizeof(ctx)); - ctx.indent_level = dump_indent/COL; + ctx.indent_level = dump_indent / COL; ctx.cur_column = dump_indent; if(obj_data == DATASET_DATA) @@ -1189,7 +1189,7 @@ dump_fcpl(hid_t fid) fdriver=H5Pget_driver(fapl); H5Pclose(fapl); #endif - + /*------------------------------------------------------------------------- * SUPER_BLOCK *------------------------------------------------------------------------- @@ -1279,9 +1279,8 @@ dump_fcontents(hid_t fid) unsigned u; for (u = 0; u < type_table->nobjs; u++) { - if (!type_table->objs[u].recorded) { + if (!type_table->objs[u].recorded) PRINTSTREAM(rawoutstream, " %-10s /#"H5_PRINTF_HADDR_FMT"\n", "datatype", type_table->objs[u].objno); - } } } @@ -1295,54 +1294,54 @@ static herr_t attr_search(hid_t oid, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED *ainfo, void *_op_data) { herr_t ret = SUCCEED; - int i; - int j; - int k; - char *obj_op_name; + int j; + char *obj_op_name; char *obj_name; - trav_attr_udata_t *attr_data = (trav_attr_udata_t*)_op_data; - char *buf = attr_data->path; - char *op_name = attr_data->op_name; + trav_attr_udata_t *attr_data = (trav_attr_udata_t*)_op_data; + const char *buf = attr_data->path; + const char *op_name = attr_data->op_name; j = (int)HDstrlen(op_name) - 1; /* find the last / */ while(j >= 0) { - if (op_name[j] == '/' && (j==0 || (j>0 && op_name[j-1]!='\\'))) - break; - j--; + if(op_name[j] == '/' && (j == 0 || (j > 0 && op_name[j - 1] != '\\'))) + break; + j--; } obj_op_name = h5tools_str_replace(op_name + j + 1, "\\/", "/"); if(obj_op_name == NULL) { - h5tools_setstatus(EXIT_FAILURE); - ret = FAIL; + h5tools_setstatus(EXIT_FAILURE); + ret = FAIL; } else { - if(HDstrcmp(attr_name, obj_op_name)==0) { - /* object name */ - i = (int)HDstrlen(buf); - j = (int)HDstrlen(op_name); - k = (size_t)i + 1 + (size_t)j + 1 + 2; - obj_name = (char *)HDmalloc((size_t)k); - if(obj_name == NULL) { - h5tools_setstatus(EXIT_FAILURE); - ret = FAIL; - } - else { - HDmemset(obj_name, '\0', (size_t)k); - if(op_name[0] != '/') { - HDstrncat(obj_name, buf, (size_t)i + 1); - if(buf[i-1] != '/') - HDstrncat(obj_name, "/", (size_t)2); - } - HDstrncat(obj_name, op_name, (size_t)j + 1); - - handle_attributes(oid, obj_name, NULL, 0, NULL); - HDfree(obj_name); - } - } - HDfree(obj_op_name); + if(HDstrcmp(attr_name, obj_op_name)==0) { + size_t u, v, w; + + /* object name */ + u = HDstrlen(buf); + v = HDstrlen(op_name); + w = u + 1 + v + 1 + 2; + obj_name = (char *)HDmalloc(w); + if(obj_name == NULL) { + h5tools_setstatus(EXIT_FAILURE); + ret = FAIL; + } + else { + HDmemset(obj_name, '\0', w); + if(op_name[0] != '/') { + HDstrncat(obj_name, buf, u + 1); + if(buf[u - 1] != '/') + HDstrncat(obj_name, "/", (size_t)2); + } + HDstrncat(obj_name, op_name, v + 1); + + handle_attributes(oid, obj_name, NULL, 0, NULL); + HDfree(obj_name); + } + } + HDfree(obj_op_name); } return ret; } /* end attr_search() */ @@ -1350,31 +1349,34 @@ attr_search(hid_t oid, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED *a static herr_t obj_search(const char *path, const H5O_info_t *oi, const char H5_ATTR_UNUSED *already_visited, void *_op_data) { - trav_handle_udata_t *handle_data = (trav_handle_udata_t*)_op_data; - char *op_name = (char*)handle_data->op_name; - + trav_handle_udata_t *handle_data = (trav_handle_udata_t*)_op_data; + const char *op_name = handle_data->op_name; trav_attr_udata_t attr_data; - attr_data.path = (char*)path; + + attr_data.path = path; attr_data.op_name = op_name; H5Aiterate_by_name(handle_data->fid, path, H5_INDEX_NAME, H5_ITER_INC, NULL, attr_search, (void*)&attr_data, H5P_DEFAULT); - if(HDstrcmp(path, op_name)==0) { - switch(oi->type) { - case H5O_TYPE_GROUP: - handle_groups(handle_data->fid, path, NULL, 0, NULL); - break; - case H5O_TYPE_DATASET: - handle_datasets(handle_data->fid, path, NULL, 0, NULL); - break; - case H5O_TYPE_NAMED_DATATYPE: - handle_datatypes(handle_data->fid, path, NULL, 0, NULL); - break; - case H5O_TYPE_UNKNOWN: - case H5O_TYPE_NTYPES: - default: - error_msg("unknown object type value\n"); - h5tools_setstatus(EXIT_FAILURE); - } /* end switch */ + if(HDstrcmp(path, op_name) == 0) { + switch(oi->type) { + case H5O_TYPE_GROUP: + handle_groups(handle_data->fid, path, NULL, 0, NULL); + break; + + case H5O_TYPE_DATASET: + handle_datasets(handle_data->fid, path, NULL, 0, NULL); + break; + + case H5O_TYPE_NAMED_DATATYPE: + handle_datatypes(handle_data->fid, path, NULL, 0, NULL); + break; + + case H5O_TYPE_UNKNOWN: + case H5O_TYPE_NTYPES: + default: + error_msg("unknown object type value\n"); + h5tools_setstatus(EXIT_FAILURE); + } /* end switch */ } return 0; @@ -1383,49 +1385,48 @@ obj_search(const char *path, const H5O_info_t *oi, const char H5_ATTR_UNUSED *al static herr_t lnk_search(const char *path, const H5L_info_t *li, void *_op_data) { - int search_len; - int k; + size_t search_len; + size_t k; char *search_name; - trav_handle_udata_t *handle_data = (trav_handle_udata_t*)_op_data; - char *op_name = (char*)handle_data->op_name; + trav_handle_udata_t *handle_data = (trav_handle_udata_t*)_op_data; + const char *op_name = handle_data->op_name; search_len = HDstrlen(op_name); - if(search_len > 0 && op_name[0] != '/') { - k = 2; - } + if(search_len > 0 && op_name[0] != '/') + k = 2; else k = 1; - search_name = (char *)HDmalloc((size_t)(search_len + k)); + search_name = (char *)HDmalloc(search_len + k); if(search_name == NULL) { - error_msg("creating temporary link\n"); - h5tools_setstatus(EXIT_FAILURE); + error_msg("creating temporary link\n"); + h5tools_setstatus(EXIT_FAILURE); } else { - if (k == 2) { - HDstrcpy(search_name, "/"); - HDstrncat(search_name, op_name, (size_t)search_len + 1); - } - else - HDstrncpy(search_name, op_name, (size_t)search_len + 1); - search_name[search_len + k - 1] = '\0'; - - if(HDstrcmp(path, search_name) == 0) { - switch(li->type) { - case H5L_TYPE_SOFT: - case H5L_TYPE_EXTERNAL: - handle_links(handle_data->fid, op_name, NULL, 0, NULL); - break; - - case H5L_TYPE_HARD: - case H5L_TYPE_MAX: - case H5L_TYPE_ERROR: - default: - error_msg("unknown link type value\n"); - h5tools_setstatus(EXIT_FAILURE); - break; - } /* end switch() */ - } - HDfree(search_name); + if (k == 2) { + HDstrcpy(search_name, "/"); + HDstrncat(search_name, op_name, search_len + 1); + } + else + HDstrncpy(search_name, op_name, search_len + 1); + search_name[search_len + k - 1] = '\0'; + + if(HDstrcmp(path, search_name) == 0) { + switch(li->type) { + case H5L_TYPE_SOFT: + case H5L_TYPE_EXTERNAL: + handle_links(handle_data->fid, op_name, NULL, 0, NULL); + break; + + case H5L_TYPE_HARD: + case H5L_TYPE_MAX: + case H5L_TYPE_ERROR: + default: + error_msg("unknown link type value\n"); + h5tools_setstatus(EXIT_FAILURE); + break; + } /* end switch() */ + } + HDfree(search_name); } return 0; } /* end lnk_search() */ @@ -1452,7 +1453,7 @@ handle_paths(hid_t fid, const char *path_name, void H5_ATTR_UNUSED * data, int H hid_t gcpl_id; unsigned crt_order_flags; unsigned attr_crt_order_flags; - trav_handle_udata_t handle_udata; /* User data for traversal */ + trav_handle_udata_t handle_udata; /* User data for traversal */ if ((gcpl_id = H5Gget_create_plist(gid)) < 0) { error_msg("error in getting group creation property list ID\n"); @@ -1476,12 +1477,12 @@ handle_paths(hid_t fid, const char *path_name, void H5_ATTR_UNUSED * data, int H h5tools_setstatus(EXIT_FAILURE); } - handle_udata.fid = fid; - handle_udata.op_name = (char*)path_name; - if(h5trav_visit(fid, "/", TRUE, TRUE, obj_search, lnk_search, &handle_udata) < 0) { - error_msg("error traversing information\n"); - h5tools_setstatus(EXIT_FAILURE); - } + handle_udata.fid = fid; + handle_udata.op_name = path_name; + if(h5trav_visit(fid, "/", TRUE, TRUE, obj_search, lnk_search, &handle_udata) < 0) { + error_msg("error traversing information\n"); + h5tools_setstatus(EXIT_FAILURE); + } } } @@ -1505,8 +1506,8 @@ handle_paths(hid_t fid, const char *path_name, void H5_ATTR_UNUSED * data, int H void handle_attributes(hid_t fid, const char *attr, void H5_ATTR_UNUSED * data, int H5_ATTR_UNUSED pe, const char H5_ATTR_UNUSED *display_name) { - hid_t oid = -1; - hid_t attr_id = -1; + hid_t oid = -1; + hid_t attr_id = -1; char *obj_name = NULL; char *attr_name = NULL; int j; @@ -1523,7 +1524,7 @@ handle_attributes(hid_t fid, const char *attr, void H5_ATTR_UNUSED * data, int H /* find the last / */ while(j >= 0) { - if (attr[j] == '/' && (j==0 || (j>0 && attr[j-1]!='\\'))) + if (attr[j] == '/' && (j==0 || (j>0 && attr[j-1]!='\\'))) break; j--; } @@ -1538,7 +1539,7 @@ handle_attributes(hid_t fid, const char *attr, void H5_ATTR_UNUSED * data, int H dump_indent += COL; HDmemset(&ctx, 0, sizeof(ctx)); - ctx.indent_level = dump_indent/COL; + ctx.indent_level = dump_indent / COL; ctx.cur_column = dump_indent; string_dataformat = *outputformat; @@ -1548,7 +1549,7 @@ handle_attributes(hid_t fid, const char *attr, void H5_ATTR_UNUSED * data, int H string_dataformat.fmt_float = fp_format; } - if (h5tools_nCols==0) { + if (h5tools_nCols == 0) { string_dataformat.line_ncols = 65535; string_dataformat.line_per_line = 1; } @@ -1558,7 +1559,7 @@ handle_attributes(hid_t fid, const char *attr, void H5_ATTR_UNUSED * data, int H string_dataformat.do_escape = display_escape; outputformat = &string_dataformat; - attr_name = h5tools_str_replace(attr + j + 1, "\\/", "/"); + attr_name = h5tools_str_replace(attr + j + 1, "\\/", "/"); /* handle error case: cannot open the object with the attribute */ if((oid = H5Oopen(fid, obj_name, H5P_DEFAULT)) < 0) { @@ -1614,7 +1615,7 @@ handle_attributes(hid_t fid, const char *attr, void H5_ATTR_UNUSED * data, int H } /* end if */ HDfree(obj_name); - HDfree(attr_name); + HDfree(attr_name); dump_indent -= COL; return; @@ -1622,9 +1623,9 @@ error: h5tools_setstatus(EXIT_FAILURE); if(obj_name) HDfree(obj_name); - - if (attr_name) - HDfree(attr_name); + + if (attr_name) + HDfree(attr_name); H5E_BEGIN_TRY { H5Oclose(oid); @@ -1681,8 +1682,7 @@ handle_datasets(hid_t fid, const char *dset, void *data, int pe, const char *dis h5tools_setstatus(EXIT_FAILURE); return; } - else - ndims = ndims_res; + ndims = (unsigned)ndims_res; if(!sset->start.data || !sset->stride.data || !sset->count.data || !sset->block.data) { /* they didn't specify a ``stride'' or ``block''. default to 1 in all @@ -1739,7 +1739,7 @@ handle_datasets(hid_t fid, const char *dset, void *data, int pe, const char *dis h5tools_setstatus(EXIT_FAILURE); return; } - + /*------------------------------------------------------------------------- * check for block overlap *------------------------------------------------------------------------- @@ -1772,7 +1772,7 @@ handle_datasets(hid_t fid, const char *dset, void *data, int pe, const char *dis PRINTSTREAM(rawoutstream, "%s \"%s\"\n", HARDLINK, found_obj->objname); indentation(dump_indent); end_obj(h5tools_dump_header_format->datasetend, h5tools_dump_header_format->datasetblockend); - } + } else { found_obj->displayed = TRUE; dump_indent += COL; @@ -1871,11 +1871,11 @@ handle_links(hid_t fid, const char *links, void H5_ATTR_UNUSED * data, int H5_AT if(H5Lget_info(fid, links, &linfo, H5P_DEFAULT) < 0) { error_msg("unable to get link info from \"%s\"\n", links); h5tools_setstatus(EXIT_FAILURE); - } + } else if(linfo.type == H5L_TYPE_HARD) { error_msg("\"%s\" is a hard link\n", links); h5tools_setstatus(EXIT_FAILURE); - } + } else { char *buf = (char *)HDmalloc(linfo.u.val_size); PRINTVALSTREAM(rawoutstream, "\n"); @@ -1912,12 +1912,12 @@ handle_links(hid_t fid, const char *links, void H5_ATTR_UNUSED * data, int H5_AT PRINTSTREAM(rawoutstream, "TARGETFILE \"%s\"\n", elink_file); indentation(COL); PRINTSTREAM(rawoutstream, "TARGETPATH \"%s\"\n", elink_path); - } + } else { error_msg("h5dump error: unable to unpack external link value for \"%s\"\n", links); h5tools_setstatus(EXIT_FAILURE); } - } + } else { error_msg("h5dump error: unable to get external link value for \"%s\"\n", links); h5tools_setstatus(EXIT_FAILURE); @@ -2091,12 +2091,15 @@ dump_extlink(hid_t group, const char *linkname, const char *objname) case H5O_TYPE_GROUP: handle_groups(group, linkname, NULL, 0, objname); break; + case H5O_TYPE_DATASET: handle_datasets(group, linkname, NULL, 0, objname); break; + case H5O_TYPE_NAMED_DATATYPE: handle_datatypes(group, linkname, NULL, 0, objname); break; + case H5O_TYPE_UNKNOWN: case H5O_TYPE_NTYPES: default: |