Add goto error for dataset read failure. Fixed comments

This commit is contained in:
Allen Byrne 2017-01-17 09:55:15 -06:00
parent 509b6c24a7
commit be260bbf75
2 changed files with 87 additions and 84 deletions

View File

@ -47,7 +47,7 @@ void do_print_objname (const char *OBJ, const char *path1, const char *path2, di
{
/* if verbose level is higher than 0, put space line before
* displaying any object or symbolic links. This improves
* readability of the output.
* readability of the output.
*/
if (opts->m_verbose_level >= 1)
parallel_print("\n");
@ -71,7 +71,7 @@ do_print_attrname (const char *attr, const char *path1, const char *path2)
* Function: print_warn
*
* Purpose: check print warning condition.
* Return:
* Return:
* 1 if verbose mode
* 0 if not verbos mode
* Programmer: Jonathan Kim
@ -146,7 +146,7 @@ static void print_incoming_data(void)
*
* Purpose: check if options are valid
*
* Return:
* Return:
* 1 : Valid
* 0 : Not valid
*
@ -189,10 +189,10 @@ out:
*
* Purpose: check if 'paths' are part of exclude path list
*
* Return:
* Return:
* 1 - excluded path
* 0 - not excluded path
*
*
* Programmer: Jonathan Kim
* Date: Aug 23, 2010
*------------------------------------------------------------------------*/
@ -221,11 +221,11 @@ static int is_exclude_path (char * path, h5trav_type_t type, diff_opt_t *options
{
size_t len_grp;
/* check if given path belong to an excluding group, if so
/* check if given path belong to an excluding group, if so
* exclude it as well.
* This verifies if /grp1/dset1 is only under /grp1, but
* not under /grp1xxx/ group.
*/
* not under /grp1xxx/ group.
*/
len_grp = HDstrlen(exclude_path_ptr->obj_path);
if (path[len_grp] == '/')
{
@ -236,15 +236,15 @@ static int is_exclude_path (char * path, h5trav_type_t type, diff_opt_t *options
}
}
/* exclude target is not group, just exclude the object */
else
else
{
ret_cmp = HDstrcmp(exclude_path_ptr->obj_path, path);
if (ret_cmp == 0) /* found matching object */
{
/* excluded non-group object */
ret = 1;
/* remember the type of this maching object.
* if it's group, it can be used for excluding its member
/* remember the type of this maching object.
* if it's group, it can be used for excluding its member
* objects in this while() loop */
exclude_path_ptr->obj_type = type;
break; /* while */
@ -339,7 +339,7 @@ static void build_match_list (const char *objname1, trav_info_t *info1, const ch
path2_lp = (info2->paths[curr2].path) + path2_offset;
type1_l = info1->paths[curr1].type;
type2_l = info2->paths[curr2].type;
/* criteria is string compare */
cmp = HDstrcmp(path1_lp, path2_lp);
@ -410,7 +410,7 @@ static void build_match_list (const char *objname1, trav_info_t *info1, const ch
if (!is_exclude_path(path2_lp, type2_l, options))
{
trav_table_addflags(infile, path2_lp, info2->paths[curr2].type, table);
}
}
curr2++;
} /* end while */
@ -424,8 +424,8 @@ static void build_match_list (const char *objname1, trav_info_t *info1, const ch
/*-------------------------------------------------------------------------
* Function: trav_grp_objs
*
* Purpose:
* Call back function from h5trav_visit().
* Purpose:
* Call back function from h5trav_visit().
*
* Programmer: Jonathan Kim
*
@ -437,22 +437,22 @@ static herr_t trav_grp_objs(const char *path, const H5O_info_t *oinfo,
trav_info_visit_obj(path, oinfo, already_visited, udata);
return 0;
}
}
/*-------------------------------------------------------------------------
* Function: trav_grp_symlinks
*
* Purpose:
* Call back function from h5trav_visit().
* Purpose:
* Call back function from h5trav_visit().
* Track and extra checkings while visiting all symbolic-links.
*
* Programmer: Jonathan Kim
*
* Date: Aug 16, 2010
*------------------------------------------------------------------------*/
static herr_t trav_grp_symlinks(const char *path, const H5L_info_t *linfo,
static herr_t trav_grp_symlinks(const char *path, const H5L_info_t *linfo,
void *udata)
{
{
trav_info_t *tinfo = (trav_info_t *)udata;
diff_opt_t *opts = (diff_opt_t *)tinfo->opts;
int ret;
@ -482,18 +482,18 @@ static herr_t trav_grp_symlinks(const char *path, const H5L_info_t *linfo,
tinfo->symlink_visited.dangle_link = TRUE;
trav_info_visit_lnk(path, linfo, tinfo);
if (opts->no_dangle_links)
opts->err_stat = 1; /* make dgangling link is error */
opts->err_stat = 1; /* make dangling link is error */
goto done;
}
/* check if already visit the target object */
if(symlink_is_visited( &(tinfo->symlink_visited), linfo->type, NULL, lnk_info.trg_path))
/* check if already visit the target object */
if(symlink_is_visited( &(tinfo->symlink_visited), linfo->type, NULL, lnk_info.trg_path))
goto done;
/* add this link as visited link */
if(symlink_visit_add( &(tinfo->symlink_visited), linfo->type, NULL, lnk_info.trg_path) < 0)
if(symlink_visit_add( &(tinfo->symlink_visited), linfo->type, NULL, lnk_info.trg_path) < 0)
goto done;
if(h5trav_visit(tinfo->fid, path, TRUE, TRUE,
trav_grp_objs,trav_grp_symlinks, tinfo) < 0)
{
@ -502,8 +502,8 @@ static herr_t trav_grp_symlinks(const char *path, const H5L_info_t *linfo,
goto done;
}
break;
case H5L_TYPE_EXTERNAL:
case H5L_TYPE_EXTERNAL:
ret = H5tools_get_symlink_info(tinfo->fid, path, &lnk_info, opts->follow_links);
/* error */
if (ret < 0)
@ -514,21 +514,21 @@ static herr_t trav_grp_symlinks(const char *path, const H5L_info_t *linfo,
tinfo->symlink_visited.dangle_link = TRUE;
trav_info_visit_lnk(path, linfo, tinfo);
if (opts->no_dangle_links)
opts->err_stat = 1; /* make dgangling link is error */
opts->err_stat = 1; /* make dangling link is error */
goto done;
}
if(H5Lunpack_elink_val(lnk_info.trg_path, linfo->u.val_size, NULL, &ext_fname, &ext_path) < 0)
if(H5Lunpack_elink_val(lnk_info.trg_path, linfo->u.val_size, NULL, &ext_fname, &ext_path) < 0)
goto done;
/* check if already visit the target object */
if(symlink_is_visited( &(tinfo->symlink_visited), linfo->type, ext_fname, ext_path))
/* check if already visit the target object */
if(symlink_is_visited( &(tinfo->symlink_visited), linfo->type, ext_fname, ext_path))
goto done;
/* add this link as visited link */
if(symlink_visit_add( &(tinfo->symlink_visited), linfo->type, ext_fname, ext_path) < 0)
if(symlink_visit_add( &(tinfo->symlink_visited), linfo->type, ext_fname, ext_path) < 0)
goto done;
if(h5trav_visit(tinfo->fid, path, TRUE, TRUE,
trav_grp_objs,trav_grp_symlinks, tinfo) < 0)
{
@ -548,11 +548,11 @@ static herr_t trav_grp_symlinks(const char *path, const H5L_info_t *linfo,
break;
} /* end of switch */
done:
done:
if (lnk_info.trg_path)
HDfree(lnk_info.trg_path);
return 0;
}
}
/*-------------------------------------------------------------------------
@ -630,7 +630,7 @@ hsize_t h5diff(const char *fname1,
H5E_BEGIN_TRY
{
/* open file 1 */
if((file1_id = h5tools_fopen(fname1, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, (size_t)0)) < 0)
if((file1_id = h5tools_fopen(fname1, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, (size_t)0)) < 0)
{
parallel_print("h5diff: <%s>: unable to open file\n", fname1);
options->err_stat = 1;
@ -639,7 +639,7 @@ hsize_t h5diff(const char *fname1,
/* open file 2 */
if((file2_id = h5tools_fopen(fname2, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, (size_t)0)) < 0)
if((file2_id = h5tools_fopen(fname2, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, (size_t)0)) < 0)
{
parallel_print("h5diff: <%s>: unable to open file\n", fname2);
options->err_stat = 1;
@ -704,14 +704,14 @@ hsize_t h5diff(const char *fname1,
else
{
/* check if link itself exist */
if(H5Lexists(file1_id, obj1fullname, H5P_DEFAULT) <= 0)
if(H5Lexists(file1_id, obj1fullname, H5P_DEFAULT) <= 0)
{
parallel_print ("Object <%s> could not be found in <%s>\n", obj1fullname, fname1);
options->err_stat = 1;
goto out;
}
/* get info from link */
if(H5Lget_info(file1_id, obj1fullname, &src_linfo1, H5P_DEFAULT) < 0)
if(H5Lget_info(file1_id, obj1fullname, &src_linfo1, H5P_DEFAULT) < 0)
{
parallel_print("Unable to get link info from <%s>\n", obj1fullname);
goto out;
@ -719,7 +719,7 @@ hsize_t h5diff(const char *fname1,
info1_lp = info1_obj;
/*
/*
* check the type of specified path for hard and symbolic links
*/
if(src_linfo1.type == H5L_TYPE_HARD)
@ -764,14 +764,14 @@ hsize_t h5diff(const char *fname1,
else
{
/* check if link itself exist */
if(H5Lexists(file2_id, obj2fullname, H5P_DEFAULT) <= 0)
if(H5Lexists(file2_id, obj2fullname, H5P_DEFAULT) <= 0)
{
parallel_print ("Object <%s> could not be found in <%s>\n", obj2fullname, fname2);
options->err_stat = 1;
goto out;
}
/* get info from link */
if(H5Lget_info(file2_id, obj2fullname, &src_linfo2, H5P_DEFAULT) < 0)
if(H5Lget_info(file2_id, obj2fullname, &src_linfo2, H5P_DEFAULT) < 0)
{
parallel_print("Unable to get link info from <%s>\n", obj2fullname);
goto out;
@ -779,7 +779,7 @@ hsize_t h5diff(const char *fname1,
info2_lp = info2_obj;
/*
/*
* check the type of specified path for hard and symbolic links
*/
if(src_linfo2.type == H5L_TYPE_HARD)
@ -811,7 +811,7 @@ hsize_t h5diff(const char *fname1,
obj2type = H5TRAV_TYPE_UDLINK;
trav_info_add(info2_obj, obj2fullname, obj2type);
}
}
}
}
/* if no object specified */
else
@ -830,7 +830,7 @@ hsize_t h5diff(const char *fname1,
l_ret2 = H5tools_get_symlink_info(file2_id, obj2fullname, &trg_linfo2, options->follow_links);
/*---------------------------------------------
* check for following symlinks
* check for following symlinks
*/
if (options->follow_links)
{
@ -915,7 +915,7 @@ hsize_t h5diff(const char *fname1,
}
}
}
else if(l_ret2 < 0) /* fail */
else if(l_ret2 < 0) /* fail */
{
parallel_print ("Object <%s> could not be found in <%s>\n", obj2fullname, fname2);
options->err_stat = 1;
@ -936,11 +936,11 @@ hsize_t h5diff(const char *fname1,
}
} /* end of if follow symlinks */
/*
/*
* If verbose options is not used, don't need to traverse through the list
* of objects in the group to display objects information,
* So use h5tools_is_obj_same() to improve performance by skipping
* comparing details of same objects.
* So use h5tools_is_obj_same() to improve performance by skipping
* comparing details of same objects.
*/
if(!(options->m_verbose || options->m_report))
@ -1087,10 +1087,10 @@ out:
/*-------------------------------------------------------------------------
* Function: diff_match
*
* Purpose:
* Compare common objects in given groups according to table structure.
* The table structure has flags which can be used to find common objects
* and will be compared.
* Purpose:
* Compare common objects in given groups according to table structure.
* The table structure has flags which can be used to find common objects
* and will be compared.
* Common object means same name (absolute path) objects in both location.
*
* Return: Number of differences found
@ -1126,7 +1126,7 @@ hsize_t diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1,
h5difftrace("diff_match start\n");
/*
/*
* if not root, prepare object name to be pre-appended to group path to
* make full path
*/
@ -1141,8 +1141,8 @@ hsize_t diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1,
* 2) the graph must match, i.e same names (absolute path)
* 3) objects with the same name must be of the same type
*-------------------------------------------------------------------------
*/
*/
/* not valid compare used when --exclude-path option is used */
if (!options->exclude_path)
{
@ -1152,7 +1152,7 @@ hsize_t diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1,
options->contents = 0;
}
}
/* objects in one file and not the other */
for( i = 0; i < table->nobjs; i++)
{
@ -1209,7 +1209,7 @@ hsize_t diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1,
#endif /* H5_HAVE_ASPRINTF */
/* get index to figure out type of the object in file1 */
while(info1->paths[idx1].path &&
while(info1->paths[idx1].path &&
(HDstrcmp(obj1_fullpath, info1->paths[idx1].path) != 0))
idx1++;
/* get index to figure out type of the object in file2 */
@ -1226,7 +1226,7 @@ hsize_t diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1,
if(!g_Parallel)
{
nfound += diff(file1_id, obj1_fullpath,
file2_id, obj2_fullpath,
file2_id, obj2_fullpath,
options, &argdata);
} /* end if */
#ifdef H5_HAVE_PARALLEL
@ -1244,7 +1244,7 @@ hsize_t diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1,
*/
/*Set up args to pass to worker task. */
if(HDstrlen(obj1_fullpath) > 255 ||
if(HDstrlen(obj1_fullpath) > 255 ||
HDstrlen(obj2_fullpath) > 255)
{
printf("The parallel diff only supports object names up to 255 characters\n");
@ -1401,7 +1401,7 @@ hsize_t diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1,
#endif /* H5_HAVE_PARALLEL */
if(obj1_fullpath)
HDfree(obj1_fullpath);
if(obj2_fullpath)
if(obj2_fullpath)
HDfree(obj2_fullpath);
} /* end if */
} /* end for */
@ -1568,14 +1568,14 @@ hsize_t diff(hid_t file1_id,
if(print_warn(options))
linkinfo1.opt.msg_mode = linkinfo2.opt.msg_mode = 1;
/* for symbolic links, take care follow symlink and no dangling link
/* for symbolic links, take care follow symlink and no dangling link
* options */
if (argdata->type[0] == H5TRAV_TYPE_LINK ||
if (argdata->type[0] == H5TRAV_TYPE_LINK ||
argdata->type[0] == H5TRAV_TYPE_UDLINK ||
argdata->type[1] == H5TRAV_TYPE_LINK ||
argdata->type[1] == H5TRAV_TYPE_LINK ||
argdata->type[1] == H5TRAV_TYPE_UDLINK )
{
/*
/*
* check dangling links for path1 and path2
*/
@ -1586,7 +1586,7 @@ hsize_t diff(hid_t file1_id,
{
if (options->no_dangle_links)
{
/* gangling link is error */
/* dangling link is error */
if(options->m_verbose)
parallel_print("Warning: <%s> is a dangling link.\n", path1);
goto out;
@ -1604,7 +1604,7 @@ hsize_t diff(hid_t file1_id,
{
if (options->no_dangle_links)
{
/* gangling link is error */
/* dangling link is error */
if(options->m_verbose)
parallel_print("Warning: <%s> is a dangling link.\n", path2);
goto out;
@ -1614,7 +1614,7 @@ hsize_t diff(hid_t file1_id,
}
else if (ret < 0)
goto out;
/* found dangling link */
if (is_dangle_link1 || is_dangle_link2)
goto out2;
@ -1637,7 +1637,7 @@ hsize_t diff(hid_t file1_id,
if (options->m_verbose||options->m_list_not_cmp)
{
parallel_print("Not comparable: <%s> is of type %s and <%s> is of type %s\n",
path1, get_type(argdata->type[0]),
path1, get_type(argdata->type[0]),
path2, get_type(argdata->type[1]));
}
options->not_cmp=1;
@ -1648,11 +1648,11 @@ hsize_t diff(hid_t file1_id,
}
else /* now both object types are same */
object_type = argdata->type[0];
/*
/*
* If both points to the same target object, skip comparing details inside
* of the objects to improve performance.
* Always check for the hard links, otherwise if follow symlink option is
* Always check for the hard links, otherwise if follow symlink option is
* specified.
*
* Perform this to match the outputs as bypassing.
@ -1672,7 +1672,7 @@ hsize_t diff(hid_t file1_id,
{
case H5TRAV_TYPE_DATASET:
do_print_objname("dataset", path1, path2, options);
break;
break;
case H5TRAV_TYPE_NAMED_DATATYPE:
do_print_objname("datatype", path1, path2, options);
break;
@ -1687,7 +1687,7 @@ hsize_t diff(hid_t file1_id,
do_print_objname("external link", path1, path2, options);
else
do_print_objname ("user defined link", path1, path2, options);
break;
break;
case H5TRAV_TYPE_UNKNOWN:
default:
parallel_print("Comparison not supported: <%s> and <%s> are of type %s\n",
@ -1735,14 +1735,14 @@ hsize_t diff(hid_t file1_id,
if (nfound)
{
do_print_objname("dataset", path1, path2, options);
print_found(nfound);
print_found(nfound);
}
}
/*---------------------------------------------------------
* compare attributes
* if condition refers to cases when the dataset is a
* if condition refers to cases when the dataset is a
* referenced object
*---------------------------------------------------------
*/
@ -1781,7 +1781,7 @@ hsize_t diff(hid_t file1_id,
/*-----------------------------------------------------------------
* compare attributes
* the if condition refers to cases when the dataset is a
* the if condition refers to cases when the dataset is a
* referenced object
*-----------------------------------------------------------------
*/
@ -1813,7 +1813,7 @@ hsize_t diff(hid_t file1_id,
/*-----------------------------------------------------------------
* compare attributes
* the if condition refers to cases when the dataset is a
* the if condition refers to cases when the dataset is a
* referenced object
*-----------------------------------------------------------------
*/
@ -1855,10 +1855,10 @@ hsize_t diff(hid_t file1_id,
case H5TRAV_TYPE_UDLINK:
{
/* Only external links will have a query function registered */
if(linkinfo1.linfo.type == H5L_TYPE_EXTERNAL && linkinfo2.linfo.type == H5L_TYPE_EXTERNAL)
if(linkinfo1.linfo.type == H5L_TYPE_EXTERNAL && linkinfo2.linfo.type == H5L_TYPE_EXTERNAL)
{
/* If the buffers are the same size, compare them */
if(linkinfo1.linfo.u.val_size == linkinfo2.linfo.u.val_size)
if(linkinfo1.linfo.u.val_size == linkinfo2.linfo.u.val_size)
{
ret = HDmemcmp(linkinfo1.trg_path, linkinfo2.trg_path, linkinfo1.linfo.u.val_size);
}
@ -1866,7 +1866,7 @@ hsize_t diff(hid_t file1_id,
ret = 1;
/* if "linkinfo1.trg_path" != "linkinfo2.trg_path" then the links
* are "different" extlinkinfo#.path is combination string of
* are "different" extlinkinfo#.path is combination string of
* file_name and obj_name
*/
nfound = (ret != 0) ? 1 : 0;
@ -1875,7 +1875,7 @@ hsize_t diff(hid_t file1_id,
do_print_objname("external link", path1, path2, options);
} /* end if */
else
else
{
/* If one or both of these links isn't an external link, we can only
* compare information from H5Lget_info since we don't have a query
@ -1884,7 +1884,7 @@ hsize_t diff(hid_t file1_id,
* If the link classes or the buffer length are not the
* same, the links are "different"
*/
if((linkinfo1.linfo.type != linkinfo2.linfo.type) ||
if((linkinfo1.linfo.type != linkinfo2.linfo.type) ||
(linkinfo1.linfo.u.val_size != linkinfo2.linfo.u.val_size))
nfound = 1;
else
@ -1922,7 +1922,7 @@ out:
out2:
/*-----------------------------------
* handle dangling link(s)
* handle dangling link(s)
*/
/* both path1 and path2 are dangling links */
if(is_dangle_link1 && is_dangle_link2)

View File

@ -89,6 +89,9 @@ hsize_t diff_dataset( hid_t file1_id,
obj2_name,
options);
}
else
goto error;
/*-------------------------------------------------------------------------
* close
*-------------------------------------------------------------------------