Skip to content

Commit

Permalink
Eliminate "unknown" case from H5O__obj_type_real()
Browse files Browse the repository at this point in the history
Also minor optimizations and warning cleanups

Signed-off-by: Quincey Koziol <[email protected]>
  • Loading branch information
qkoziol committed Sep 26, 2024
1 parent ec57203 commit aef7eeb
Showing 1 changed file with 24 additions and 25 deletions.
49 changes: 24 additions & 25 deletions src/H5Oint.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ static const H5O_obj_class_t *const H5O_obj_class_g[] = {
* Failure: negative
*-------------------------------------------------------------------------
*/
herr_t
H5_ATTR_CONST herr_t
H5O_init(void)
{
herr_t ret_value = SUCCEED; /* Return value */
Expand Down Expand Up @@ -1617,13 +1617,10 @@ H5O__obj_type_real(const H5O_t *oh, H5O_type_t *obj_type)
/* Look up class for object header */
if (H5O__obj_class_real(oh, &obj_class) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to determine object class");
assert(obj_class);

if (obj_class)
/* Set object type */
*obj_type = obj_class->type;
else
/* Set type to "unknown" */
*obj_type = H5O_TYPE_UNKNOWN;
/* Set object type */
*obj_type = obj_class->type;

done:
FUNC_LEAVE_NOAPI(ret_value)
Expand Down Expand Up @@ -2077,7 +2074,6 @@ 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 = NULL; /* Class of object for header */
H5O_t *oh = NULL; /* Object header */
herr_t ret_value = SUCCEED; /* Return value */

Expand All @@ -2091,25 +2087,27 @@ H5O_get_info(const H5O_loc_t *loc, H5O_info2_t *oinfo, unsigned fields)
if (NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, false)))
HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header");

/* Get class for object */
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 */
if (H5O__reset_info2(oinfo) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't reset object data struct");

/* Get basic information, if requested */
if (fields & H5O_INFO_BASIC) {
H5O_type_t obj_type = H5O_TYPE_UNKNOWN; /* Type of object */

/* Retrieve the file's fileno */
H5F_GET_FILENO(loc->file, oinfo->fileno);

/* Set the object's address into the token */
if (H5VL_native_addr_to_token(loc->file, H5I_FILE, loc->addr, &oinfo->token) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTSERIALIZE, FAIL, "can't serialize address into object token");

/* Retrieve the type of the object */
oinfo->type = obj_class->type;
/* Get type of object */
if (H5O__obj_type_real(oh, &obj_type) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to determine object type");

/* Set the type of the object */
oinfo->type = obj_type;

/* Set the object's reference count */
oinfo->rc = oh->nlink;
Expand Down Expand Up @@ -2183,7 +2181,6 @@ 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 = NULL; /* Class of object for header */
H5O_t *oh = NULL; /* Object header */
herr_t ret_value = SUCCEED; /* Return value */

Expand All @@ -2197,10 +2194,6 @@ H5O_get_native_info(const H5O_loc_t *loc, H5O_native_info_t *oinfo, unsigned fie
if (NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, false)))
HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header");

/* Get class for object */
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 */
memset(oinfo, 0, sizeof(*oinfo));

Expand All @@ -2211,6 +2204,12 @@ H5O_get_native_info(const H5O_loc_t *loc, H5O_native_info_t *oinfo, unsigned fie

/* Get B-tree & heap metadata storage size, if requested */
if (fields & H5O_NATIVE_INFO_META_SIZE) {
const H5O_obj_class_t *obj_class = NULL; /* Class of object for header */

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

/* Check for 'bh_info' callback for this type of object */
if (obj_class->bh_info)
/* Call the object's class 'bh_info' routine */
Expand Down Expand Up @@ -2377,7 +2376,7 @@ H5O_obj_create(H5F_t *f, H5O_type_t obj_type, void *crt_info, H5G_loc_t *obj_loc
*
*-------------------------------------------------------------------------
*/
haddr_t
H5_ATTR_PURE haddr_t
H5O_get_oh_addr(const H5O_t *oh)
{
/* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */
Expand All @@ -2394,7 +2393,7 @@ H5O_get_oh_addr(const H5O_t *oh)
*
*-------------------------------------------------------------------------
*/
uint8_t
H5_ATTR_PURE uint8_t
H5O_get_oh_flags(const H5O_t *oh)
{
FUNC_ENTER_NOAPI_NOINIT_NOERR
Expand All @@ -2411,7 +2410,7 @@ H5O_get_oh_flags(const H5O_t *oh)
*
*-------------------------------------------------------------------------
*/
time_t
H5_ATTR_PURE time_t
H5O_get_oh_mtime(const H5O_t *oh)
{
FUNC_ENTER_NOAPI_NOINIT_NOERR
Expand All @@ -2425,7 +2424,7 @@ H5O_get_oh_mtime(const H5O_t *oh)
*
*-------------------------------------------------------------------------
*/
uint8_t
H5_ATTR_PURE uint8_t
H5O_get_oh_version(const H5O_t *oh)
{
FUNC_ENTER_NOAPI_NOINIT_NOERR
Expand Down Expand Up @@ -2843,7 +2842,7 @@ H5O_dec_rc_by_loc(const H5O_loc_t *loc)
*
*-------------------------------------------------------------------------
*/
H5AC_proxy_entry_t *
H5_ATTR_PURE H5AC_proxy_entry_t *
H5O_get_proxy(const H5O_t *oh)
{
FUNC_ENTER_NOAPI_NOINIT_NOERR
Expand Down Expand Up @@ -2949,7 +2948,7 @@ H5O__reset_info2(H5O_info2_t *oinfo)
*
*-------------------------------------------------------------------------
*/
bool
H5_ATTR_PURE bool
H5O_has_chksum(const H5O_t *oh)
{
FUNC_ENTER_NOAPI_NOINIT_NOERR
Expand Down

0 comments on commit aef7eeb

Please sign in to comment.