summaryrefslogtreecommitdiffstats
path: root/tools/src
diff options
context:
space:
mode:
Diffstat (limited to 'tools/src')
-rw-r--r--tools/src/h5copy/h5copy.c96
-rw-r--r--tools/src/h5dump/h5dump.c182
-rw-r--r--tools/src/h5dump/h5dump_ddl.c210
-rw-r--r--tools/src/h5dump/h5dump_xml.c457
-rw-r--r--tools/src/h5jam/h5jam.c13
-rw-r--r--tools/src/h5jam/h5unjam.c54
-rw-r--r--tools/src/h5ls/h5ls.c33
-rw-r--r--tools/src/h5repack/h5repack.c1
-rw-r--r--tools/src/h5repack/h5repack_copy.c2
-rw-r--r--tools/src/h5repack/h5repack_filters.c368
-rw-r--r--tools/src/h5repack/h5repack_refs.c8
11 files changed, 684 insertions, 740 deletions
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<H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t,mt)) {
- memb_fapl[mt] = H5P_DEFAULT;
- memb_map[mt] = mt;
- sprintf(sv[mt], "%%s-%c.h5", multi_letters[mt]);
- memb_name[mt] = sv[mt];
- memb_addr[mt] = (haddr_t)MAX(mt - 1, 0) * (HADDR_MAX / 10);
+ if(HDstrlen(multi_letters)==H5FD_MEM_NTYPES) {
+ for (mt=H5FD_MEM_DEFAULT; mt<H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t,mt)) {
+ memb_fapl[mt] = H5P_DEFAULT;
+ memb_map[mt] = mt;
+ sprintf(sv[mt], "%%s-%c.h5", multi_letters[mt]);
+ memb_name[mt] = sv[mt];
+ memb_addr[mt] = (haddr_t)MAX(mt - 1, 0) * (HADDR_MAX / 10);
+ }
+ }
+ else {
+ error_msg("Bad multi_letters list\n");
+ return FAIL;
}
if (H5Pset_fapl_multi(fapl, memb_map, memb_fapl, memb_name, memb_addr, FALSE) < 0)
@@ -1767,8 +1779,10 @@ h5_fileaccess(void)
static void
init_prefix(char **prfx, size_t prfx_len)
{
- HDassert(prfx_len > 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; u<data_loop; u++) */
@@ -1183,10 +1191,10 @@ dump_fcpl(hid_t fid)
size_t off_size; /* size of offsets in the file */
size_t len_size; /* size of lengths in the file */
H5F_fspace_strategy_t fs_strategy; /* file space strategy */
- hbool_t fs_persist; /* Persisting free-space or not */
- hsize_t fs_threshold; /* free-space section threshold */
- hsize_t fsp_size; /* file space page size */
- H5F_info2_t finfo; /* file information */
+ hbool_t fs_persist; /* Persisting free-space or not */
+ hsize_t fs_threshold; /* free-space section threshold */
+ hsize_t fsp_size; /* file space page size */
+ H5F_info2_t finfo; /* file information */
#ifdef SHOW_FILE_DRIVER
hid_t fapl; /* file access property list ID */
hid_t fdriver; /* file driver */
@@ -1980,8 +1988,6 @@ handle_links(hid_t fid, const char *links, void H5_ATTR_UNUSED * data, int H5_AT
case H5L_TYPE_ERROR:
case H5L_TYPE_MAX:
- HDassert(0);
- /* fall through */
case H5L_TYPE_HARD:
default:
begin_obj(h5tools_dump_header_format->udlinkbegin, 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, "</%sRequiredFilter>", 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, "</%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;
+ 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);
- 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, "</%sChunkedLayout>", 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, "</%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;
- HDfree(chsize);
+ /* 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;
+ 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; 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;
-}
+ 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; i<tmp.chunk.rank; i++)
- tmp.chunk.chunk_lengths[i]=options->chunk_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; i<tmp.chunk.rank; i++)
- tmp.chunk.chunk_lengths[i]=options->op_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; i<tmp.nfilters; i++)
- {
+ else {
+ tmp.nfilters = options->op_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; i<tmp.chunk.rank; i++)
- tmp.chunk.chunk_lengths[i]=options->chunk_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<obj.nfilters; i++)
- {
- switch (obj.filter[i].filtn)
- {
-
+ for (i = 0; i < obj.nfilters; i++) {
+ switch (obj.filter[i].filtn) {
/*-------------------------------------------------------------------------
- * H5Z_FILTER_NONE 0 , uncompress if compressed
- *-------------------------------------------------------------------------
- */
- case H5Z_FILTER_NONE:
- break;
-
- /*-------------------------------------------------------------------------
- * H5Z_FILTER_DEFLATE 1 , deflation like gzip
+ * H5Z_FILTER_NONE 0 , uncompress if compressed
*-------------------------------------------------------------------------
*/
+ case H5Z_FILTER_NONE:
+ break;
+
+ /*-------------------------------------------------------------------------
+ * H5Z_FILTER_DEFLATE 1 , deflation like gzip
+ *-------------------------------------------------------------------------
+ */
case H5Z_FILTER_DEFLATE:
{
- unsigned aggression; /* the deflate level */
+ unsigned aggression; /* the deflate level */
aggression = obj.filter[i].cd_values[0];
/* set up for deflated data */
- if(H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths)<0)
+ if (H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths) < 0)
return -1;
- if(H5Pset_deflate(dcpl_id,aggression)<0)
+ if (H5Pset_deflate(dcpl_id, aggression) < 0)
return -1;
}
break;
- /*-------------------------------------------------------------------------
- * H5Z_FILTER_SZIP 4 , szip compression
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * H5Z_FILTER_SZIP 4 , szip compression
+ *-------------------------------------------------------------------------
+ */
case H5Z_FILTER_SZIP:
{
- unsigned options_mask;
- unsigned pixels_per_block;
+ unsigned options_mask;
+ unsigned pixels_per_block;
- options_mask = obj.filter[i].cd_values[0];
+ options_mask = obj.filter[i].cd_values[0];
pixels_per_block = obj.filter[i].cd_values[1];
/* set up for szip data */
- if(H5Pset_chunk(dcpl_id,obj.chunk.rank,obj.chunk.chunk_lengths)<0)
+ if (H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths) < 0)
return -1;
- if (H5Pset_szip(dcpl_id,options_mask,pixels_per_block)<0)
+ if (H5Pset_szip(dcpl_id, options_mask, pixels_per_block) < 0)
return -1;
-
}
break;
- /*-------------------------------------------------------------------------
- * H5Z_FILTER_SHUFFLE 2 , shuffle the data
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * H5Z_FILTER_SHUFFLE 2 , shuffle the data
+ *-------------------------------------------------------------------------
+ */
case H5Z_FILTER_SHUFFLE:
- if(H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths)<0)
+ if (H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths) < 0)
return -1;
- if (H5Pset_shuffle(dcpl_id)<0)
+ if (H5Pset_shuffle(dcpl_id) < 0)
return -1;
break;
- /*-------------------------------------------------------------------------
- * H5Z_FILTER_FLETCHER32 3 , fletcher32 checksum of EDC
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * H5Z_FILTER_FLETCHER32 3 , fletcher32 checksum of EDC
+ *-------------------------------------------------------------------------
+ */
case H5Z_FILTER_FLETCHER32:
- if(H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths)<0)
+ if (H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths) < 0)
return -1;
- if (H5Pset_fletcher32(dcpl_id)<0)
+ if (H5Pset_fletcher32(dcpl_id) < 0)
return -1;
break;
- /*----------- -------------------------------------------------------------
- * H5Z_FILTER_NBIT , NBIT compression
- *-------------------------------------------------------------------------
- */
+ /*----------- -------------------------------------------------------------
+ * H5Z_FILTER_NBIT , NBIT compression
+ *-------------------------------------------------------------------------
+ */
case H5Z_FILTER_NBIT:
- if(H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths)<0)
+ if (H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths) < 0)
return -1;
- if (H5Pset_nbit(dcpl_id)<0)
+ if (H5Pset_nbit(dcpl_id) < 0)
return -1;
break;
- /*----------- -------------------------------------------------------------
- * H5Z_FILTER_SCALEOFFSET , scale+offset compression
- *-------------------------------------------------------------------------
- */
+ /*----------- -------------------------------------------------------------
+ * H5Z_FILTER_SCALEOFFSET , scale+offset compression
+ *-------------------------------------------------------------------------
+ */
case H5Z_FILTER_SCALEOFFSET:
{
H5Z_SO_scale_type_t scale_type;
- int scale_factor;
+ int scale_factor;
- scale_type = (H5Z_SO_scale_type_t)obj.filter[i].cd_values[0];
- scale_factor = (int)obj.filter[i].cd_values[1];
+ scale_type = (H5Z_SO_scale_type_t) obj.filter[i].cd_values[0];
+ scale_factor = (int) obj.filter[i].cd_values[1];
- if(H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths)<0)
+ if (H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths) < 0)
return -1;
- if (H5Pset_scaleoffset(dcpl_id,scale_type,scale_factor)<0)
+ if (H5Pset_scaleoffset(dcpl_id, scale_type, scale_factor) < 0)
return -1;
}
break;
default:
- {
- if (H5Pset_filter (dcpl_id, obj.filter[i].filtn, H5Z_FLAG_MANDATORY, obj.filter[i].cd_nelmts, obj.filter[i].cd_values)<0)
- return -1;
- if(H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths)<0)
- return -1;
- }
+ {
+ if (H5Pset_filter(dcpl_id, obj.filter[i].filtn,
+ H5Z_FLAG_MANDATORY, obj.filter[i].cd_nelmts,
+ obj.filter[i].cd_values) < 0)
+ return -1;
+ if (H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths) < 0)
+ return -1;
+ }
break;
} /* switch */
}/*i*/
-
}
/*obj.nfilters*/
@@ -461,31 +419,27 @@ int apply_filters(const char* name, /* object name from traverse list */
*-------------------------------------------------------------------------
*/
- if (obj.layout>=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
*-------------------------------------------------------------------------