summaryrefslogtreecommitdiffstats
path: root/tools/lib/h5trav.c
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2020-02-29 20:03:20 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2020-02-29 20:03:20 (GMT)
commit2804716f648c42d6bd85e1d4a942f7df204c93f2 (patch)
tree664c6fbe21af3050a28ac998924d8766bf490caf /tools/lib/h5trav.c
parent3f4c3bd5ed61e604c5005f0322ae394dc2609cc4 (diff)
downloadhdf5-2804716f648c42d6bd85e1d4a942f7df204c93f2.zip
hdf5-2804716f648c42d6bd85e1d4a942f7df204c93f2.tar.gz
hdf5-2804716f648c42d6bd85e1d4a942f7df204c93f2.tar.bz2
Merge changes from other branches
Diffstat (limited to 'tools/lib/h5trav.c')
-rw-r--r--tools/lib/h5trav.c82
1 files changed, 39 insertions, 43 deletions
diff --git a/tools/lib/h5trav.c b/tools/lib/h5trav.c
index 2d07c15..683f12c 100644
--- a/tools/lib/h5trav.c
+++ b/tools/lib/h5trav.c
@@ -113,7 +113,7 @@ h5trav_set_verbose(int print_verbose)
*-------------------------------------------------------------------------
*/
-
+
/*-------------------------------------------------------------------------
* Function: trav_addr_add
*
@@ -139,7 +139,6 @@ trav_addr_add(trav_addr_t *visited, haddr_t addr, const char *path)
visited->objs[idx].path = HDstrdup(path);
} /* end trav_addr_add() */
-
/*-------------------------------------------------------------------------
* Function: trav_addr_visited
*
@@ -163,7 +162,6 @@ trav_addr_visited(trav_addr_t *visited, haddr_t addr)
return(NULL);
} /* end trav_addr_visited() */
-
/*-------------------------------------------------------------------------
* Function: traverse_cb
*
@@ -183,7 +181,7 @@ traverse_cb(hid_t loc_id, const char *path, const H5L_info_t *linfo,
if(udata->is_absolute) {
size_t base_len = HDstrlen(udata->base_grp_name);
size_t add_slash = base_len ? ((udata->base_grp_name)[base_len - 1] != '/') : 1;
- size_t new_name_len = base_len + add_slash + HDstrlen(path) + 1;
+ size_t new_name_len = base_len + add_slash + HDstrlen(path) + 1 + 3; /* Extra "+3" to quiet GCC warning - 2019/07/05, QAK */
if(NULL == (new_name = (char*)HDmalloc(new_name_len)))
return(H5_ITER_ERROR);
@@ -238,7 +236,7 @@ traverse_cb(hid_t loc_id, const char *path, const H5L_info_t *linfo,
return(H5_ITER_CONT);
} /* end traverse_cb() */
-
+
/*-------------------------------------------------------------------------
* Function: traverse
*
@@ -254,11 +252,11 @@ traverse(hid_t file_id, const char *grp_name, hbool_t visit_start,
hbool_t recurse, const trav_visitor_t *visitor)
{
H5O_info_t oinfo; /* Object info for starting group */
- int ret_value = SUCCEED;
+ int ret_value = 0;
/* Get info for starting object */
if(H5Oget_info_by_name(file_id, grp_name, &oinfo, H5P_DEFAULT) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Oget_info_by_name failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Oget_info_by_name failed");
/* Visit the starting object */
if(visit_start && visitor->visit_obj)
@@ -287,12 +285,12 @@ traverse(hid_t file_id, const char *grp_name, hbool_t visit_start,
if(recurse) {
/* Visit all links in group, recursively */
if(H5Lvisit_by_name(file_id, grp_name, trav_index_by, trav_index_order, traverse_cb, &udata, H5P_DEFAULT) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Lvisit_by_name failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Lvisit_by_name failed");
} /* end if */
else {
/* Iterate over links in group */
if(H5Literate_by_name(file_id, grp_name, trav_index_by, trav_index_order, NULL, traverse_cb, &udata, H5P_DEFAULT) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Literate_by_name failed");
+ H5TOOLS_GOTO_ERROR((-1), "H5Literate_by_name failed");
} /* end else */
/* Free visited addresses table */
@@ -310,7 +308,7 @@ done:
return ret_value;
}
-
+
/*-------------------------------------------------------------------------
* Function: trav_info_add
*
@@ -364,7 +362,7 @@ trav_fileinfo_add(trav_info_t *info, hid_t loc_id)
info->paths[idx].fileno = oinfo.fileno;
} /* end trav_fileinfo_add() */
-
+
/*-------------------------------------------------------------------------
* Function: trav_info_visit_obj
*
@@ -394,7 +392,7 @@ trav_info_visit_obj(const char *path, const H5O_info_t *oinfo,
return(0);
} /* end trav_info_visit_obj() */
-
+
/*-------------------------------------------------------------------------
* Function: trav_info_visit_lnk
*
@@ -413,7 +411,7 @@ trav_info_visit_lnk(const char *path, const H5L_info_t *linfo, void *udata)
return(0);
} /* end trav_info_visit_lnk() */
-
+
/*-------------------------------------------------------------------------
* Function: h5trav_getinfo
*
@@ -428,7 +426,7 @@ int
h5trav_getinfo(hid_t file_id, trav_info_t *info)
{
trav_visitor_t info_visitor; /* Visitor structure for trav_info_t's */
- int ret_value = SUCCEED;
+ int ret_value = 0;
/* Init visitor structure */
info_visitor.visit_obj = trav_info_visit_obj;
@@ -437,7 +435,7 @@ h5trav_getinfo(hid_t file_id, trav_info_t *info)
/* Traverse all objects in the file, visiting each object & link */
if(traverse(file_id, "/", TRUE, TRUE, &info_visitor) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "traverse failed");
+ H5TOOLS_GOTO_ERROR((-1), "traverse failed");
done:
return ret_value;
@@ -499,7 +497,7 @@ trav_info_init(const char *filename, hid_t fileid, trav_info_t **_info)
*_info = info;
} /* end trav_info_init() */
-
+
/*-------------------------------------------------------------------------
* Function: trav_info_free
*
@@ -534,7 +532,7 @@ trav_info_free(trav_info_t *info)
*-------------------------------------------------------------------------
*/
-
+
/*-------------------------------------------------------------------------
* Function: trav_table_visit_obj
*
@@ -561,7 +559,7 @@ trav_table_visit_obj(const char *path, const H5O_info_t *oinfo,
return 0;
} /* end trav_table_visit_obj() */
-
+
/*-------------------------------------------------------------------------
* Function: trav_table_visit_lnk
*
@@ -580,7 +578,7 @@ trav_table_visit_lnk(const char *path, const H5L_info_t H5_ATTR_UNUSED *linfo, v
return 0;
} /* end trav_table_visit_lnk() */
-
+
/*-------------------------------------------------------------------------
* Function: h5trav_gettable
*
@@ -594,7 +592,7 @@ int
h5trav_gettable(hid_t fid, trav_table_t *table)
{
trav_visitor_t table_visitor; /* Visitor structure for trav_table_t's */
- int ret_value = SUCCEED;
+ int ret_value = 0;
/* Init visitor structure */
table_visitor.visit_obj = trav_table_visit_obj;
@@ -603,7 +601,7 @@ h5trav_gettable(hid_t fid, trav_table_t *table)
/* Traverse all objects in the file, visiting each object & link */
if(traverse(fid, "/", TRUE, TRUE, &table_visitor) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "traverse failed");
+ H5TOOLS_GOTO_ERROR((-1), "traverse failed");
done:
return ret_value;
@@ -661,9 +659,7 @@ h5trav_getindext(const char *name, const trav_table_t *table)
*-------------------------------------------------------------------------
*/
static void
-trav_table_add(trav_table_t *table,
- const char *path,
- const H5O_info_t *oinfo)
+trav_table_add(trav_table_t *table, const char *path, const H5O_info_t *oinfo)
{
size_t new_obj;
@@ -718,9 +714,9 @@ trav_table_addlink(trav_table_t *table, haddr_t objno, const char *path)
table->objs[i].links[n].new_name = (char *)HDstrdup(path);
return;
- } /* end for */
+ } /* end if */
} /* end for */
- }
+ } /* end if */
}
@@ -832,8 +828,8 @@ trav_attr(hid_t
#ifdef H5TRAV_PRINT_SPACE
}
else {
- hid_t attr = -1;
- hid_t space = -1;
+ hid_t attr = H5I_INVALID_HID;
+ hid_t space = H5I_INVALID_HID;
hsize_t size[H5S_MAX_RANK];
int ndims;
int i;
@@ -880,7 +876,7 @@ trav_attr(hid_t
return(0);
}
-
+
/*-------------------------------------------------------------------------
* Function: trav_print_visit_obj
*
@@ -892,7 +888,7 @@ trav_attr(hid_t
*/
static int
trav_print_visit_obj(const char *path, const H5O_info_t *oinfo,
- const char *already_visited, void *udata)
+ const char *already_visited, void *udata)
{
trav_print_udata_t *print_udata = (trav_print_udata_t *)udata;
/* Print the name of the object */
@@ -937,7 +933,7 @@ trav_print_visit_obj(const char *path, const H5O_info_t *oinfo,
return(0);
} /* end trav_print_visit_obj() */
-
+
/*-------------------------------------------------------------------------
* Function: trav_print_visit_lnk
*
@@ -1001,7 +997,7 @@ trav_print_visit_lnk(const char *path, const H5L_info_t *linfo, void *udata)
return(0);
} /* end trav_print_visit_lnk() */
-
+
/*-------------------------------------------------------------------------
* Function: h5trav_print
*
@@ -1016,7 +1012,7 @@ h5trav_print(hid_t fid)
{
trav_print_udata_t print_udata; /* User data for traversal */
trav_visitor_t print_visitor; /* Visitor structure for printing objects */
- int ret_value = SUCCEED;
+ int ret_value = 0;
/* Init user data for printing */
print_udata.fid = fid;
@@ -1028,13 +1024,13 @@ h5trav_print(hid_t fid)
/* Traverse all objects in the file, visiting each object & link */
if(traverse(fid, "/", TRUE, TRUE, &print_visitor) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "traverse failed");
+ H5TOOLS_GOTO_ERROR(FAIL, "traverse failed");
done:
return ret_value;
}
-
+
/*-------------------------------------------------------------------------
* Function: h5trav_visit
*
@@ -1050,7 +1046,7 @@ h5trav_visit(hid_t fid, const char *grp_name, hbool_t visit_start,
void *udata)
{
trav_visitor_t visitor; /* Visitor structure for objects */
- int ret_value = SUCCEED;
+ int ret_value = 0;
/* Init visitor structure */
visitor.visit_obj = visit_obj;
@@ -1059,7 +1055,7 @@ h5trav_visit(hid_t fid, const char *grp_name, hbool_t visit_start,
/* Traverse all objects in the file, visiting each object & link */
if(traverse(fid, grp_name, visit_start, recurse, &visitor) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "traverse failed");
+ H5TOOLS_GOTO_ERROR((-1), "traverse failed");
done:
return ret_value;
@@ -1077,8 +1073,8 @@ done:
herr_t
symlink_visit_add(symlink_trav_t *visited, H5L_type_t type, const char *file, const char *path)
{
- herr_t ret_value = SUCCEED;
- size_t idx; /* Index of address to use */
+ size_t idx; /* Index of address to use */
+ herr_t ret_value = SUCCEED;
/* Allocate space if necessary */
if(visited->nused == visited->nalloc) {
@@ -1086,7 +1082,7 @@ symlink_visit_add(symlink_trav_t *visited, H5L_type_t type, const char *file, co
visited->nalloc = MAX(1, visited->nalloc * 2);
if(NULL == (tmp_ptr = HDrealloc(visited->objs, visited->nalloc * sizeof(symlink_trav_path_t))))
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "visited data structure realloc failed");
+ H5TOOLS_GOTO_ERROR(FAIL, "visited data structure realloc failed");
visited->objs = (symlink_trav_path_t *)tmp_ptr;
} /* end if */
@@ -1100,7 +1096,7 @@ symlink_visit_add(symlink_trav_t *visited, H5L_type_t type, const char *file, co
if(type == H5L_TYPE_EXTERNAL) {
if(NULL == (visited->objs[idx].file = HDstrdup(file))) {
visited->nused--;
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "visited data structure name allocation failed");
+ H5TOOLS_GOTO_ERROR(FAIL, "visited data structure name allocation failed");
} /* end if */
} /* end if */
@@ -1108,14 +1104,14 @@ symlink_visit_add(symlink_trav_t *visited, H5L_type_t type, const char *file, co
visited->nused--;
if(visited->objs[idx].file)
HDfree (visited->objs[idx].file);
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "visited data structure path allocation failed");
+ H5TOOLS_GOTO_ERROR(FAIL, "visited data structure path allocation failed");
} /* end if */
done:
return ret_value;
} /* end symlink_visit_add() */
-
+
/*-------------------------------------------------------------------------
* Function: symlink_is_visited
*