summaryrefslogtreecommitdiffstats
path: root/tools/lib
diff options
context:
space:
mode:
authorPedro Vicente Nunes <pvn@hdfgroup.org>2003-10-30 21:51:32 (GMT)
committerPedro Vicente Nunes <pvn@hdfgroup.org>2003-10-30 21:51:32 (GMT)
commitcceba7e0c9904763e489a0106f697b6a9245f2de (patch)
treeb06ac68b00867f387c263136b5308ebdd41072bf /tools/lib
parent967c5d5684014e52e3b24e9c1f62e94796242d05 (diff)
downloadhdf5-cceba7e0c9904763e489a0106f697b6a9245f2de.zip
hdf5-cceba7e0c9904763e489a0106f697b6a9245f2de.tar.gz
hdf5-cceba7e0c9904763e489a0106f697b6a9245f2de.tar.bz2
[svn-r7796] Purpose:
h5diff improvment Description: changed a call to exit(1) for return -1 for user friendiness in the h5diff function in the case that H5Fopen fails Solution: Platforms tested: linux (small change ) Misc. update:
Diffstat (limited to 'tools/lib')
-rw-r--r--tools/lib/h5diff.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/tools/lib/h5diff.c b/tools/lib/h5diff.c
index c7dd9e5..a02af47 100644
--- a/tools/lib/h5diff.c
+++ b/tools/lib/h5diff.c
@@ -25,8 +25,7 @@
* Purpose: public function, can be called in an applicattion program.
* return differences between 2 HDF5 files
*
- * Return: An exit status of 0 means no differences were found, 1 means some
- * differences were found.
+ * Return: Number of differences found; -1 for error.
*
* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
*
@@ -45,8 +44,7 @@ int h5diff(const char *fname1,
trav_info_t *info1=NULL;
trav_info_t *info2=NULL;
hid_t file1_id, file2_id;
- int nfound;
-
+ int nfound=0;
/*-------------------------------------------------------------------------
* open the files first; if they are not valid, no point in continuing
@@ -60,16 +58,17 @@ int h5diff(const char *fname1,
if ((file1_id=H5Fopen(fname1,H5F_ACC_RDONLY,H5P_DEFAULT))<0 )
{
printf("h5diff: %s: No such file or directory\n", fname1 );
- exit(1);
+ nfound = -1;
}
if ((file2_id=H5Fopen(fname2,H5F_ACC_RDONLY,H5P_DEFAULT))<0 )
{
printf("h5diff: %s: No such file or directory\n", fname2 );
- exit(1);
+ nfound = -1;
}
/* enable error reporting */
} H5E_END_TRY;
-
+ if (nfound<0)
+ return -1;
/*-------------------------------------------------------------------------
* get the number of objects in the files
@@ -87,7 +86,10 @@ int h5diff(const char *fname1,
info1 = (trav_info_t*) malloc( nobjects1 * sizeof(trav_info_t));
info2 = (trav_info_t*) malloc( nobjects2 * sizeof(trav_info_t));
if (info1==NULL || info2==NULL)
- return 0;
+ {
+ nfound=-1;
+ goto out;
+ }
h5trav_getinfo( file1_id, info1 );
h5trav_getinfo( file2_id, info2 );
@@ -118,11 +120,15 @@ int h5diff(const char *fname1,
h5trav_freeinfo(info1,nobjects1);
h5trav_freeinfo(info2,nobjects2);
+
+out:
/* close */
- assert( (H5Fclose(file1_id)) >=0);
- assert( (H5Fclose(file2_id)) >=0);
+ H5Fclose(file1_id);
+ H5Fclose(file2_id);
return nfound;
+
+
}