Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove a call to H5E_clear_stack() in H5O code #4875

Merged
merged 6 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/H5Eint.c
Original file line number Diff line number Diff line change
Expand Up @@ -1673,6 +1673,15 @@ H5E__clear_entries(H5E_stack_t *estack, size_t nentries)
*
* Purpose: Clear the default error stack
*
* Note: This routine should _not_ be used inside general library
* code in general. It creates complex locking issues for
* threadsafe code. Generally, using a 'try' parameter or
* an 'exists' parameter should be used if an operation is
* being used to probe for information. Remember: failing
* to locate a record is not an error for a data structure,
* although it could be an error for the user of the data
* structure.
*
* Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
Expand Down
68 changes: 37 additions & 31 deletions src/H5Oint.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ static herr_t H5O__obj_type_real(const H5O_t *oh, H5O_type_t *obj_type);
static herr_t H5O__get_hdr_info_real(const H5O_t *oh, H5O_hdr_info_t *hdr);
static herr_t H5O__free_visit_visited(void *item, void *key, void *operator_data /*in,out*/);
static herr_t H5O__visit_cb(hid_t group, const char *name, const H5L_info2_t *linfo, void *_udata);
static const H5O_obj_class_t *H5O__obj_class_real(const H5O_t *oh);
static herr_t H5O__reset_info2(H5O_info2_t *oinfo);
static herr_t H5O__obj_class_real(const H5O_t *oh, const H5O_obj_class_t **cls);
static herr_t H5O__reset_info2(H5O_info2_t *oinfo);

/*********************/
/* Package Variables */
Expand Down Expand Up @@ -1594,37 +1594,39 @@ H5O_obj_type(const H5O_loc_t *loc, H5O_type_t *obj_type)
/*-------------------------------------------------------------------------
* Function: H5O__obj_type_real
*
* Purpose: Returns the type of object pointed to by `oh'.
* Purpose: On success, returns the type of object pointed to by `oh' or
* NULL in *obj_type. *obj_type not defined on failure.
*
* Return: Success: Non-negative
* Failure: Negative
* Return: Success: Non-negative
* Failure: Negative
*
*-------------------------------------------------------------------------
*/
static herr_t
H5O__obj_type_real(const H5O_t *oh, H5O_type_t *obj_type)
{
const H5O_obj_class_t *obj_class; /* Class of object for header */
const H5O_obj_class_t *obj_class = NULL; /* Class of object for header */
herr_t ret_value = SUCCEED;

FUNC_ENTER_PACKAGE_NOERR
FUNC_ENTER_PACKAGE

/* Sanity check */
assert(oh);
assert(obj_type);

/* Look up class for object header */
if (NULL == (obj_class = H5O__obj_class_real(oh))) {
/* Clear error stack from "failed" class lookup */
H5E_clear_stack();
if (H5O__obj_class_real(oh, &obj_class) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to determine object class");

/* Set type to "unknown" */
*obj_type = H5O_TYPE_UNKNOWN;
}
else
if (obj_class)
/* Set object type */
*obj_type = obj_class->type;
else
qkoziol marked this conversation as resolved.
Show resolved Hide resolved
/* Set type to "unknown" */
*obj_type = H5O_TYPE_UNKNOWN;

FUNC_LEAVE_NOAPI(SUCCEED)
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O__obj_type_real() */

/*-------------------------------------------------------------------------
Expand All @@ -1650,7 +1652,7 @@ H5O__obj_class(const H5O_loc_t *loc)
HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, NULL, "unable to load object header");

/* Test whether entry qualifies as a particular type of object */
if (NULL == (ret_value = H5O__obj_class_real(oh)))
if (H5O__obj_class_real(oh, &ret_value) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, NULL, "unable to determine object type");

done:
Expand All @@ -1663,37 +1665,41 @@ H5O__obj_class(const H5O_loc_t *loc)
/*-------------------------------------------------------------------------
* Function: H5O__obj_class_real
*
* Purpose: Returns the class of object pointed to by `oh'.
* Purpose: On success returns the class of object pointed to by `oh' or
* NULL in *cls. *cls not defined on failure.
*
* Return: Success: An object class
* Failure: NULL
* Return: Success: Non-negative
* Failure: Negative
*
*-------------------------------------------------------------------------
*/
static const H5O_obj_class_t *
H5O__obj_class_real(const H5O_t *oh)
static herr_t
H5O__obj_class_real(const H5O_t *oh, const H5O_obj_class_t **cls)
{
size_t i; /* Local index variable */
const H5O_obj_class_t *ret_value = NULL; /* Return value */
size_t i; /* Local index variable */
herr_t ret_value = SUCCEED;

FUNC_ENTER_PACKAGE

/* Sanity check */
assert(oh);
assert(cls);

/* Test whether entry qualifies as a particular type of object */
/* (Note: loop is in reverse order, to test specific objects first) */
for (i = NELMTS(H5O_obj_class_g); i > 0; --i) {
htri_t isa; /* Is entry a particular type? */

if ((isa = (H5O_obj_class_g[i - 1]->isa)(oh)) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to determine object type");
else if (isa)
HGOTO_DONE(H5O_obj_class_g[i - 1]);
HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to determine object type");
else if (isa) {
*cls = H5O_obj_class_g[i - 1];
break;
}
}

if (0 == i)
HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to determine object type");
HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to determine object type");

done:
FUNC_LEAVE_NOAPI(ret_value)
Expand Down Expand Up @@ -2071,7 +2077,7 @@ H5O__get_hdr_info_real(const H5O_t *oh, H5O_hdr_info_t *hdr)
herr_t
H5O_get_info(const H5O_loc_t *loc, H5O_info2_t *oinfo, unsigned fields)
{
const H5O_obj_class_t *obj_class; /* Class of object for header */
const H5O_obj_class_t *obj_class = NULL; /* Class of object for header */
H5O_t *oh = NULL; /* Object header */
herr_t ret_value = SUCCEED; /* Return value */

Expand All @@ -2086,7 +2092,7 @@ H5O_get_info(const H5O_loc_t *loc, H5O_info2_t *oinfo, unsigned fields)
HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header");

/* Get class for object */
if (NULL == (obj_class = H5O__obj_class_real(oh)))
if (H5O__obj_class_real(oh, &obj_class) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to determine object class");

/* Reset the object info structure */
Expand Down Expand Up @@ -2177,7 +2183,7 @@ H5O_get_info(const H5O_loc_t *loc, H5O_info2_t *oinfo, unsigned fields)
herr_t
H5O_get_native_info(const H5O_loc_t *loc, H5O_native_info_t *oinfo, unsigned fields)
{
const H5O_obj_class_t *obj_class; /* Class of object for header */
const H5O_obj_class_t *obj_class = NULL; /* Class of object for header */
H5O_t *oh = NULL; /* Object header */
herr_t ret_value = SUCCEED; /* Return value */

Expand All @@ -2192,7 +2198,7 @@ H5O_get_native_info(const H5O_loc_t *loc, H5O_native_info_t *oinfo, unsigned fie
HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header");

/* Get class for object */
if (NULL == (obj_class = H5O__obj_class_real(oh)))
if (H5O__obj_class_real(oh, &obj_class) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to determine object class");

/* Reset the object info structure */
Expand Down