summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorVailin Choi <vchoi@hdfgroup.org>2008-10-08 18:52:23 (GMT)
committerVailin Choi <vchoi@hdfgroup.org>2008-10-08 18:52:23 (GMT)
commitda42cfa2c453e6664d35ee84cc0d4ca9abbc6779 (patch)
tree2a93ddc0e07e1a64433e679ada476a7742e7a770 /tools
parente16277e5bc3610b05c75b65ad7572257f73a3d8e (diff)
downloadhdf5-da42cfa2c453e6664d35ee84cc0d4ca9abbc6779.zip
hdf5-da42cfa2c453e6664d35ee84cc0d4ca9abbc6779.tar.gz
hdf5-da42cfa2c453e6664d35ee84cc0d4ca9abbc6779.tar.bz2
[svn-r15819] Modifications for bug #1253:
1. Fixed segmentation fault in print_group_info() 2. Call print_statistics() in main() when objects/links are successfully traversed; otherwise, return warning message. line, and those below, will be ignored-- M h5stat/h5stat.c
Diffstat (limited to 'tools')
-rw-r--r--tools/h5stat/h5stat.c29
1 files changed, 22 insertions, 7 deletions
diff --git a/tools/h5stat/h5stat.c b/tools/h5stat/h5stat.c
index 5a9d3f1..e95a9ee 100644
--- a/tools/h5stat/h5stat.c
+++ b/tools/h5stat/h5stat.c
@@ -882,6 +882,9 @@ print_file_metadata(const iter_t *iter)
* Saturday, August 12, 2006
*
* Modifications:
+ * bug #1253; Oct 6th 2008; Vailin Choi
+ * Fixed segmentation fault: print iter->group_bins[0] when
+ * there is iter->group_nbins
*
*-------------------------------------------------------------------------
*/
@@ -904,7 +907,7 @@ print_group_info(const iter_t *iter)
printf("Group bins:\n");
total = 0;
- if(iter->group_bins[0] > 0) {
+ if((iter->group_nbins > 0) && (iter->group_bins[0] > 0)) {
printf("\t# of groups of size 0: %lu\n", iter->group_bins[0]);
total = iter->group_bins[0];
} /* end if */
@@ -1165,6 +1168,15 @@ print_statistics(const char *name, const iter_t *iter)
print_file_statistics(iter);
}
+/*-------------------------------------------------------------------------
+ *
+ * Modifications:
+ * bug #1253; Oct 6th 2008; Vailin Choi
+ * Call print_statistics() when objects/links are successfully traversed.
+ * Otherwise, return warning message.
+ *
+ *-------------------------------------------------------------------------
+ */
int
main(int argc, const char *argv[])
@@ -1175,7 +1187,6 @@ main(int argc, const char *argv[])
struct handler_t *hand;
H5F_info_t finfo;
-
/* Disable error reporting */
H5Eset_auto2(H5E_DEFAULT, NULL, NULL);
@@ -1216,17 +1227,21 @@ main(int argc, const char *argv[])
u = 0;
while(hand[u].obj) {
- h5trav_visit(fid, hand[u].obj, TRUE, TRUE, obj_stats, lnk_stats, &iter);
- print_statistics(hand[u].obj, &iter);
+ if (h5trav_visit(fid, hand[u].obj, TRUE, TRUE, obj_stats, lnk_stats, &iter) < 0)
+ warn_msg(progname, "Unable to traverse object \"%s\"\n", hand[u].obj);
+ else
+ print_statistics(hand[u].obj, &iter);
u++;
} /* end while */
} /* end if */
else {
- h5trav_visit(fid, "/", TRUE, TRUE, obj_stats, lnk_stats, &iter);
- print_statistics("/", &iter);
+ if (h5trav_visit(fid, "/", TRUE, TRUE, obj_stats, lnk_stats, &iter) < 0)
+ warn_msg(progname, "Unable to traverse objects/links in file \"%s\"\n", fname);
+ else
+ print_statistics("/", &iter);
} /* end else */
- free(hand);
+ if (hand) free(hand);
if(H5Fclose(fid) < 0) {
error_msg(progname, "unable to close file \"%s\"\n", fname);