diff options
author | Vailin Choi <vchoi@hdfgroup.org> | 2008-10-09 21:27:11 (GMT) |
---|---|---|
committer | Vailin Choi <vchoi@hdfgroup.org> | 2008-10-09 21:27:11 (GMT) |
commit | c30c0a0cbb5ecf08870a634fd11c80719d7990e9 (patch) | |
tree | c49466e59d59de110209446212fcb528923bf7cf /tools/h5stat/h5stat.c | |
parent | 8091a4a0b1b43141de8323b54f5156a701eeadd0 (diff) | |
download | hdf5-c30c0a0cbb5ecf08870a634fd11c80719d7990e9.zip hdf5-c30c0a0cbb5ecf08870a634fd11c80719d7990e9.tar.gz hdf5-c30c0a0cbb5ecf08870a634fd11c80719d7990e9.tar.bz2 |
[svn-r15834] Fixes 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.
Diffstat (limited to 'tools/h5stat/h5stat.c')
-rw-r--r-- | tools/h5stat/h5stat.c | 29 |
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); |