Fix several undefined behavior issues noted by UBsan (#6319)

Disable float16 support for undefined sanitizer workflow for now as it
causes a crash in UBSan
This commit is contained in:
jhendersonHDF
2026-03-27 16:08:19 -05:00
committed by GitHub
parent 2952bb9216
commit ff4eaf31d1
26 changed files with 241 additions and 188 deletions
+1
View File
@@ -414,6 +414,7 @@ jobs:
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_BUILD_JAVA:BOOL=OFF")
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_BUILD_CPP_LIB:BOOL=ON")
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_BUILD_FORTRAN:BOOL=OFF")
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_NONSTANDARD_FEATURE_FLOAT16:BOOL=OFF")
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_SANITIZERS:BOOL=ON")
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_USE_SANITIZER:STRING=Undefined")
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_ZLIB_SUPPORT:BOOL=OFF")
+11 -10
View File
@@ -72,7 +72,7 @@ typedef struct {
/* Local Prototypes */
/********************/
static herr_t H5A__close_cb(H5VL_object_t *attr_vol_obj, void **request);
static herr_t H5A__close_cb(void *attr_vol_obj, void **request);
static herr_t H5A__compact_build_table_cb(H5O_t *oh, H5O_mesg_t *mesg /*in,out*/, unsigned sequence,
void *_udata /*in,out*/);
static herr_t H5A__dense_build_table_cb(const H5A_t *attr, void *_udata);
@@ -124,10 +124,10 @@ H5FL_SEQ_DEFINE_STATIC(H5A_t_ptr);
/* Attribute ID class */
static const H5I_class_t H5I_ATTR_CLS[1] = {{
H5I_ATTR, /* ID class value */
0, /* Class flags */
0, /* # of reserved IDs for class */
(H5I_free_t)H5A__close_cb /* Callback routine for closing objects of this class */
H5I_ATTR, /* ID class value */
0, /* Class flags */
0, /* # of reserved IDs for class */
H5A__close_cb /* Callback routine for closing objects of this class */
}};
/* Flag indicating "top" of interface has been initialized */
@@ -1277,21 +1277,22 @@ H5A__shared_free(H5A_t *attr)
*-------------------------------------------------------------------------
*/
static herr_t
H5A__close_cb(H5VL_object_t *attr_vol_obj, void **request)
H5A__close_cb(void *attr_vol_obj, void **request)
{
herr_t ret_value = SUCCEED; /* Return value */
H5VL_object_t *attr_vol_obj_p = (H5VL_object_t *)attr_vol_obj;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
/* Sanity check */
assert(attr_vol_obj);
assert(attr_vol_obj_p);
/* Close the attribute */
if (H5VL_attr_close(attr_vol_obj, H5P_DATASET_XFER_DEFAULT, request) < 0)
if (H5VL_attr_close(attr_vol_obj_p, H5P_DATASET_XFER_DEFAULT, request) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "problem closing attribute");
/* Free the VOL object */
if (H5VL_free_object(attr_vol_obj) < 0)
if (H5VL_free_object(attr_vol_obj_p) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "unable to free VOL object");
done:
+11 -10
View File
@@ -84,7 +84,7 @@ static herr_t H5D__build_file_prefix(const H5D_t *dset, H5F_prefix_open_t prefix
static herr_t H5D__open_oid(H5D_t *dataset, hid_t dapl_id);
static herr_t H5D__init_storage(H5D_t *dset, bool full_overwrite, hsize_t old_dim[]);
static herr_t H5D__append_flush_setup(H5D_t *dset, hid_t dapl_id);
static herr_t H5D__close_cb(H5VL_object_t *dset_vol_obj, void **request);
static herr_t H5D__close_cb(void *dset_vol_obj, void **request);
static herr_t H5D__use_minimized_dset_headers(H5F_t *file, bool *minimize);
static herr_t H5D__prepare_minimized_oh(H5F_t *file, H5D_t *dset, H5O_loc_t *oloc);
static size_t H5D__calculate_minimum_header_size(H5F_t *file, H5D_t *dset, H5O_t *ohdr);
@@ -133,10 +133,10 @@ H5_WARN_LARGE_STACK_OBJECTS_ON
/* Dataset ID class */
static const H5I_class_t H5I_DATASET_CLS[1] = {{
H5I_DATASET, /* ID class value */
0, /* Class flags */
0, /* # of reserved IDs for class */
(H5I_free_t)H5D__close_cb /* Callback routine for closing objects of this class */
H5I_DATASET, /* ID class value */
0, /* Class flags */
0, /* # of reserved IDs for class */
H5D__close_cb /* Callback routine for closing objects of this class */
}};
/* Flag indicating "top" of interface has been initialized */
@@ -332,22 +332,23 @@ H5D_term_package(void)
*-------------------------------------------------------------------------
*/
static herr_t
H5D__close_cb(H5VL_object_t *dset_vol_obj, void **request)
H5D__close_cb(void *dset_vol_obj, void **request)
{
herr_t ret_value = SUCCEED; /* Return value */
H5VL_object_t *dset_vol_obj_p = (H5VL_object_t *)dset_vol_obj;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
/* Sanity check */
assert(dset_vol_obj);
assert(dset_vol_obj_p);
/* Close the dataset */
if (H5VL_dataset_close(dset_vol_obj, H5P_DATASET_XFER_DEFAULT, request) < 0)
if (H5VL_dataset_close(dset_vol_obj_p, H5P_DATASET_XFER_DEFAULT, request) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to close dataset");
done:
/* Free the VOL object */
if (H5VL_free_object(dset_vol_obj) < 0)
if (H5VL_free_object(dset_vol_obj_p) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "unable to free VOL object");
FUNC_LEAVE_NOAPI(ret_value)
+15 -6
View File
@@ -1264,12 +1264,21 @@ H5D__scatgath_write_select(H5D_io_info_t *io_info)
if ((H5T_BKG_YES == dset_info->type_info.need_bkg) &&
!H5D__SCATGATH_USE_CMPD_OPT_WRITE(dset_info, io_info->sel_pieces[i]->in_place_tconv)) {
/* Non-const write_buf[i]. Use pointer math here to avoid const warnings. When
* there's a background buffer write_buf[i] always points inside the non-const tconv
* buf so this is OK. */
void *tmp_write_buf =
(void *)((uint8_t *)io_info->tconv_buf +
((const uint8_t *)write_bufs[i] - (const uint8_t *)io_info->tconv_buf));
void *tmp_write_buf;
if (io_info->sel_pieces[i]->in_place_tconv) {
H5_flexible_const_ptr_t flex_buf = {.cvp = write_bufs[i]};
tmp_write_buf = flex_buf.vp;
}
else {
/* Non-const write_buf[i]. Use pointer math here to avoid const warnings. When
* there's a background buffer write_buf[i] always points inside the non-const tconv
* buf so this is OK. */
tmp_write_buf =
(void *)((uint8_t *)io_info->tconv_buf +
((const uint8_t *)write_bufs[i] - (const uint8_t *)io_info->tconv_buf));
}
/* Do the data transform before the type conversion (since
* transforms must be done in the memory type). */
+6 -6
View File
@@ -340,7 +340,7 @@ H5EA__lookup_elmt(const H5EA_t *ea, hsize_t idx, bool will_extend, unsigned thin
*thing = NULL;
*thing_elmt_buf = NULL;
*thing_elmt_idx = 0;
*thing_unprot_func = (H5EA__unprotect_func_t)NULL;
*thing_unprot_func = NULL;
/* Check if we should create the index block */
if (!H5_addr_defined(hdr->idx_blk_addr)) {
@@ -368,7 +368,7 @@ H5EA__lookup_elmt(const H5EA_t *ea, hsize_t idx, bool will_extend, unsigned thin
*thing = iblock;
*thing_elmt_buf = (uint8_t *)iblock->elmts;
*thing_elmt_idx = idx;
*thing_unprot_func = (H5EA__unprotect_func_t)H5EA__iblock_unprotect;
*thing_unprot_func = H5EA__iblock_unprotect;
} /* end if */
else {
unsigned sblk_idx; /* Which superblock does this index fall in? */
@@ -436,7 +436,7 @@ H5EA__lookup_elmt(const H5EA_t *ea, hsize_t idx, bool will_extend, unsigned thin
*thing = dblock;
*thing_elmt_buf = (uint8_t *)dblock->elmts;
*thing_elmt_idx = elmt_idx;
*thing_unprot_func = (H5EA__unprotect_func_t)H5EA__dblock_unprotect;
*thing_unprot_func = H5EA__dblock_unprotect;
} /* end if */
else {
size_t sblk_off; /* Offset of super block in index block array of super blocks */
@@ -569,7 +569,7 @@ H5EA__lookup_elmt(const H5EA_t *ea, hsize_t idx, bool will_extend, unsigned thin
*thing = dblk_page;
*thing_elmt_buf = (uint8_t *)dblk_page->elmts;
*thing_elmt_idx = elmt_idx;
*thing_unprot_func = (H5EA__unprotect_func_t)H5EA__dblk_page_unprotect;
*thing_unprot_func = H5EA__dblk_page_unprotect;
} /* end if */
else {
/* Protect data block */
@@ -593,7 +593,7 @@ H5EA__lookup_elmt(const H5EA_t *ea, hsize_t idx, bool will_extend, unsigned thin
*thing = dblock;
*thing_elmt_buf = (uint8_t *)dblock->elmts;
*thing_elmt_idx = elmt_idx;
*thing_unprot_func = (H5EA__unprotect_func_t)H5EA__dblock_unprotect;
*thing_unprot_func = H5EA__dblock_unprotect;
} /* end else */
} /* end else */
} /* end else */
@@ -608,7 +608,7 @@ done:
*thing = NULL;
*thing_elmt_buf = NULL;
*thing_elmt_idx = 0;
*thing_unprot_func = (H5EA__unprotect_func_t)NULL;
*thing_unprot_func = NULL;
} /* end if */
/* Check for updating array statistics */
+3 -2
View File
@@ -257,9 +257,10 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
H5EA__dblk_page_unprotect(H5EA_dblk_page_t *dblk_page, unsigned cache_flags)
H5EA__dblk_page_unprotect(void *_dblk_page, unsigned cache_flags)
{
herr_t ret_value = SUCCEED;
H5EA_dblk_page_t *dblk_page = (H5EA_dblk_page_t *)_dblk_page;
herr_t ret_value = SUCCEED;
FUNC_ENTER_PACKAGE
+3 -2
View File
@@ -336,9 +336,10 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
H5EA__dblock_unprotect(H5EA_dblock_t *dblock, unsigned cache_flags)
H5EA__dblock_unprotect(void *_dblock, unsigned cache_flags)
{
herr_t ret_value = SUCCEED;
H5EA_dblock_t *dblock = (H5EA_dblock_t *)_dblock;
herr_t ret_value = SUCCEED;
FUNC_ENTER_PACKAGE
+3 -2
View File
@@ -324,9 +324,10 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
H5EA__iblock_unprotect(H5EA_iblock_t *iblock, unsigned cache_flags)
H5EA__iblock_unprotect(void *_iblock, unsigned cache_flags)
{
herr_t ret_value = SUCCEED;
H5EA_iblock_t *iblock = (H5EA_iblock_t *)_iblock;
herr_t ret_value = SUCCEED;
FUNC_ENTER_PACKAGE
+3 -3
View File
@@ -406,7 +406,7 @@ H5_DLL herr_t H5EA__hdr_dest(H5EA_hdr_t *hdr);
H5_DLL H5EA_iblock_t *H5EA__iblock_alloc(H5EA_hdr_t *hdr);
H5_DLL haddr_t H5EA__iblock_create(H5EA_hdr_t *hdr, bool *stats_changed);
H5_DLL H5EA_iblock_t *H5EA__iblock_protect(H5EA_hdr_t *hdr, unsigned flags);
H5_DLL herr_t H5EA__iblock_unprotect(H5EA_iblock_t *iblock, unsigned cache_flags);
H5_DLL herr_t H5EA__iblock_unprotect(void *_iblock, unsigned cache_flags);
H5_DLL herr_t H5EA__iblock_delete(H5EA_hdr_t *hdr);
H5_DLL herr_t H5EA__iblock_dest(H5EA_iblock_t *iblock);
@@ -428,7 +428,7 @@ H5_DLL haddr_t H5EA__dblock_create(H5EA_hdr_t *hdr, void *parent, bool *stats_c
H5_DLL unsigned H5EA__dblock_sblk_idx(const H5EA_hdr_t *hdr, hsize_t idx);
H5_DLL H5EA_dblock_t *H5EA__dblock_protect(H5EA_hdr_t *hdr, void *parent, haddr_t dblk_addr,
size_t dblk_nelmts, unsigned flags);
H5_DLL herr_t H5EA__dblock_unprotect(H5EA_dblock_t *dblock, unsigned cache_flags);
H5_DLL herr_t H5EA__dblock_unprotect(void *_dblock, unsigned cache_flags);
H5_DLL herr_t H5EA__dblock_delete(H5EA_hdr_t *hdr, void *parent, haddr_t dblk_addr, size_t dblk_nelmts);
H5_DLL herr_t H5EA__dblock_dest(H5EA_dblock_t *dblock);
@@ -437,7 +437,7 @@ H5_DLL H5EA_dblk_page_t *H5EA__dblk_page_alloc(H5EA_hdr_t *hdr, H5EA_sblock_t *p
H5_DLL herr_t H5EA__dblk_page_create(H5EA_hdr_t *hdr, H5EA_sblock_t *parent, haddr_t addr);
H5_DLL H5EA_dblk_page_t *H5EA__dblk_page_protect(H5EA_hdr_t *hdr, H5EA_sblock_t *parent,
haddr_t dblk_page_addr, unsigned flags);
H5_DLL herr_t H5EA__dblk_page_unprotect(H5EA_dblk_page_t *dblk_page, unsigned cache_flags);
H5_DLL herr_t H5EA__dblk_page_unprotect(void *_dblk_page, unsigned cache_flags);
H5_DLL herr_t H5EA__dblk_page_dest(H5EA_dblk_page_t *dblk_page);
/* Debugging routines for dumping file structures */
+4 -4
View File
@@ -116,10 +116,10 @@ bool H5_PKG_INIT_VAR = false;
/* Event Set ID class */
static const H5I_class_t H5I_EVENTSET_CLS[1] = {{
H5I_EVENTSET, /* ID class value */
0, /* Class flags */
0, /* # of reserved IDs for class */
(H5I_free_t)H5ES__close_cb /* Callback routine for closing objects of this class */
H5I_EVENTSET, /* ID class value */
0, /* Class flags */
0, /* # of reserved IDs for class */
H5ES__close_cb /* Callback routine for closing objects of this class */
}};
/* Declare a static free list to manage H5ES_t structs */
+33 -28
View File
@@ -68,11 +68,11 @@ static herr_t H5E__copy_stack_entry(H5E_entry_t *dst_entry, const H5E_entry_t *s
static herr_t H5E__set_stack_entry(H5E_error2_t *err_entry, const char *file, const char *func, unsigned line,
hid_t cls_id, hid_t maj_id, hid_t min_id, const char *desc, va_list *ap);
static herr_t H5E__clear_entries(H5E_stack_t *estack, size_t nentries);
static herr_t H5E__unregister_class(H5E_cls_t *cls, void **request);
static herr_t H5E__unregister_class(void *cls, void **request);
static int H5E__close_msg_cb(void *obj_ptr, hid_t obj_id, void *udata);
static void H5E__free_msg(H5E_msg_t *msg);
static herr_t H5E__close_msg(H5E_msg_t *err, void **request);
static herr_t H5E__close_stack(H5E_stack_t *err_stack, void **request);
static herr_t H5E__close_msg(void *err, void **request);
static herr_t H5E__close_stack(void *err_stack, void **request);
/*********************/
/* Package Variables */
@@ -174,26 +174,26 @@ hid_t H5E_last_min_id_g = H5I_INVALID_HID;
/* Error class ID class */
static const H5I_class_t H5I_ERRCLS_CLS[1] = {{
H5I_ERROR_CLASS, /* ID class value */
0, /* Class flags */
0, /* # of reserved IDs for class */
(H5I_free_t)H5E__unregister_class /* Callback routine for closing objects of this class */
H5I_ERROR_CLASS, /* ID class value */
0, /* Class flags */
0, /* # of reserved IDs for class */
H5E__unregister_class /* Callback routine for closing objects of this class */
}};
/* Error message ID class */
static const H5I_class_t H5I_ERRMSG_CLS[1] = {{
H5I_ERROR_MSG, /* ID class value */
0, /* Class flags */
0, /* # of reserved IDs for class */
(H5I_free_t)H5E__close_msg /* Callback routine for closing objects of this class */
H5I_ERROR_MSG, /* ID class value */
0, /* Class flags */
0, /* # of reserved IDs for class */
H5E__close_msg /* Callback routine for closing objects of this class */
}};
/* Error stack ID class */
static const H5I_class_t H5I_ERRSTK_CLS[1] = {{
H5I_ERROR_STACK, /* ID class value */
0, /* Class flags */
0, /* # of reserved IDs for class */
(H5I_free_t)H5E__close_stack /* Callback routine for closing objects of this class */
H5I_ERROR_STACK, /* ID class value */
0, /* Class flags */
0, /* # of reserved IDs for class */
H5E__close_stack /* Callback routine for closing objects of this class */
}};
/* Library's error class */
@@ -519,21 +519,22 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
H5E__unregister_class(H5E_cls_t *cls, void H5_ATTR_UNUSED **request)
H5E__unregister_class(void *cls, void H5_ATTR_UNUSED **request)
{
herr_t ret_value = SUCCEED; /* Return value */
H5E_cls_t *cls_p = (H5E_cls_t *)cls;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
/* Check arguments */
assert(cls);
assert(cls_p);
/* Iterate over all the messages and delete those in this error class */
if (H5I_iterate(H5I_ERROR_MSG, H5E__close_msg_cb, cls, false) < 0)
if (H5I_iterate(H5I_ERROR_MSG, H5E__close_msg_cb, cls_p, false) < 0)
HGOTO_ERROR(H5E_ERROR, H5E_BADITER, FAIL, "unable to free all messages in this error class");
/* Free error class structure */
if (H5E__free_class(cls) < 0)
if (H5E__free_class(cls_p) < 0)
HGOTO_ERROR(H5E_ERROR, H5E_CANTRELEASE, FAIL, "unable to free error class");
done:
@@ -644,17 +645,19 @@ H5E__free_msg(H5E_msg_t *msg)
*-------------------------------------------------------------------------
*/
static herr_t
H5E__close_msg(H5E_msg_t *err, void H5_ATTR_UNUSED **request)
H5E__close_msg(void *err, void H5_ATTR_UNUSED **request)
{
H5E_msg_t *err_p = (H5E_msg_t *)err;
FUNC_ENTER_PACKAGE_NOERR
/* Check arguments */
assert(err);
assert(err_p);
/* Free resources, if application registered this message */
if (err->app_msg)
if (err_p->app_msg)
/* Free message */
H5E__free_msg(err);
H5E__free_msg(err_p);
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5E__close_msg() */
@@ -804,18 +807,20 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
H5E__close_stack(H5E_stack_t *estack, void H5_ATTR_UNUSED **request)
H5E__close_stack(void *estack, void H5_ATTR_UNUSED **request)
{
H5E_stack_t *estack_p = (H5E_stack_t *)estack;
FUNC_ENTER_PACKAGE_NOERR
/* Sanity check */
assert(estack);
assert(estack_p);
/* Release the stack's error information */
H5E__destroy_stack(estack);
H5E__destroy_stack(estack_p);
/* Free the stack structure */
estack = H5FL_FREE(H5E_stack_t, estack);
estack_p = H5FL_FREE(H5E_stack_t, estack_p);
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5E__close_stack() */
+13 -12
View File
@@ -52,7 +52,7 @@
/********************/
/* Local Prototypes */
/********************/
static herr_t H5FD__free_cls(H5FD_class_t *cls, void **request);
static herr_t H5FD__free_cls(void *cls, void **request);
static herr_t H5FD__query(const H5FD_t *f, unsigned long *flags /*out*/);
/*********************/
@@ -89,10 +89,10 @@ static unsigned long H5FD_file_serial_no_g;
/* File driver ID class */
static const H5I_class_t H5I_VFL_CLS[1] = {{
H5I_VFL, /* ID class value */
0, /* Class flags */
0, /* # of reserved IDs for class */
(H5I_free_t)H5FD__free_cls /* Callback routine for closing objects of this class */
H5I_VFL, /* ID class value */
0, /* Class flags */
0, /* # of reserved IDs for class */
H5FD__free_cls /* Callback routine for closing objects of this class */
}};
/*-------------------------------------------------------------------------
@@ -283,32 +283,33 @@ H5FD_term_package(void)
*-------------------------------------------------------------------------
*/
static herr_t
H5FD__free_cls(H5FD_class_t *cls, void H5_ATTR_UNUSED **request)
H5FD__free_cls(void *cls, void H5_ATTR_UNUSED **request)
{
herr_t ret_value = SUCCEED;
H5FD_class_t *cls_p = (H5FD_class_t *)cls;
herr_t ret_value = SUCCEED;
FUNC_ENTER_PACKAGE
/* Sanity checks */
assert(cls);
assert(cls_p);
/* If the file driver has a terminate callback, call it to give the file
* driver a chance to free singletons or other resources which will become
* invalid once the class structure is freed.
*/
if (cls->terminate) {
if (cls_p->terminate) {
/* Prepare & restore library for user callback */
H5_BEFORE_USER_CB(FAIL)
{
ret_value = cls->terminate();
ret_value = cls_p->terminate();
}
H5_AFTER_USER_CB(FAIL)
if (ret_value < 0)
HGOTO_ERROR(H5E_VFL, H5E_CANTCLOSEOBJ, FAIL, "virtual file driver '%s' did not terminate cleanly",
cls->name);
cls_p->name);
}
H5MM_xfree(cls);
H5MM_xfree(cls_p);
done:
FUNC_LEAVE_NOAPI(ret_value)
+11 -10
View File
@@ -71,7 +71,7 @@ typedef struct H5F_olist_t {
/* Local Prototypes */
/********************/
static herr_t H5F__close_cb(H5VL_object_t *file_vol_obj, void **request);
static herr_t H5F__close_cb(void *file_vol_obj, void **request);
static herr_t H5F__set_vol_conn(H5F_t *file);
static herr_t H5F__get_objects(const H5F_t *f, unsigned types, size_t max_index, hid_t *obj_id_list,
bool app_ref, size_t *obj_id_count_ptr);
@@ -117,10 +117,10 @@ H5FL_DEFINE(H5F_shared_t);
/* File ID class */
static const H5I_class_t H5I_FILE_CLS[1] = {{
H5I_FILE, /* ID class value */
0, /* Class flags */
0, /* # of reserved IDs for class */
(H5I_free_t)H5F__close_cb /* Callback routine for closing objects of this class */
H5I_FILE, /* ID class value */
0, /* Class flags */
0, /* # of reserved IDs for class */
H5F__close_cb /* Callback routine for closing objects of this class */
}};
/*-------------------------------------------------------------------------
@@ -236,22 +236,23 @@ H5F_term_package(void)
*-------------------------------------------------------------------------
*/
static herr_t
H5F__close_cb(H5VL_object_t *file_vol_obj, void **request)
H5F__close_cb(void *file_vol_obj, void **request)
{
herr_t ret_value = SUCCEED; /* Return value */
H5VL_object_t *file_vol_obj_p = (H5VL_object_t *)file_vol_obj;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
/* Sanity check */
assert(file_vol_obj);
assert(file_vol_obj_p);
/* Close the file */
if (H5VL_file_close(file_vol_obj, H5P_DATASET_XFER_DEFAULT, request) < 0)
if (H5VL_file_close(file_vol_obj_p, H5P_DATASET_XFER_DEFAULT, request) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "unable to close file");
/* Free the VOL object; it is unnecessary to unwrap the VOL
* object before freeing it, as the object was not wrapped */
if (H5VL_free_object(file_vol_obj) < 0)
if (H5VL_free_object(file_vol_obj_p) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "unable to free VOL object");
done:
+11 -10
View File
@@ -84,7 +84,7 @@ typedef struct {
static herr_t H5G__open_oid(H5G_t *grp);
static herr_t H5G__visit_cb(const H5O_link_t *lnk, void *_udata);
static herr_t H5G__close_cb(H5VL_object_t *grp_vol_obj, void **request);
static herr_t H5G__close_cb(void *grp_vol_obj, void **request);
/*********************/
/* Package Variables */
@@ -110,10 +110,10 @@ H5FL_DEFINE(H5_obj_t);
/* Group ID class */
static const H5I_class_t H5I_GROUP_CLS[1] = {{
H5I_GROUP, /* ID class value */
0, /* Class flags */
0, /* # of reserved IDs for class */
(H5I_free_t)H5G__close_cb /* Callback routine for closing objects of this class */
H5I_GROUP, /* ID class value */
0, /* Class flags */
0, /* # of reserved IDs for class */
H5G__close_cb /* Callback routine for closing objects of this class */
}};
/* Flag indicating "top" of interface has been initialized */
@@ -257,21 +257,22 @@ H5G_term_package(void)
*-------------------------------------------------------------------------
*/
static herr_t
H5G__close_cb(H5VL_object_t *grp_vol_obj, void **request)
H5G__close_cb(void *grp_vol_obj, void **request)
{
herr_t ret_value = SUCCEED; /* Return value */
H5VL_object_t *grp_vol_obj_p = (H5VL_object_t *)grp_vol_obj;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
/* Sanity check */
assert(grp_vol_obj);
assert(grp_vol_obj_p);
/* Close the group */
if (H5VL_group_close(grp_vol_obj, H5P_DATASET_XFER_DEFAULT, request) < 0)
if (H5VL_group_close(grp_vol_obj_p, H5P_DATASET_XFER_DEFAULT, request) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to close group");
/* Free the VOL object */
if (H5VL_free_object(grp_vol_obj) < 0)
if (H5VL_free_object(grp_vol_obj_p) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "unable to free VOL object");
done:
+12 -11
View File
@@ -38,7 +38,7 @@
/********************/
/* Local Prototypes */
/********************/
static herr_t H5M__close_cb(H5VL_object_t *map_vol_obj, void **request);
static herr_t H5M__close_cb(void *map_vol_obj, void **request);
#ifdef H5_HAVE_MAP_API
static hid_t H5M__create_api_common(hid_t loc_id, const char *name, hid_t key_type_id, hid_t val_type_id,
@@ -70,10 +70,10 @@ bool H5_PKG_INIT_VAR = false;
/* Map ID class */
static const H5I_class_t H5I_MAP_CLS[1] = {{
H5I_MAP, /* ID class value */
0, /* Class flags */
0, /* # of reserved IDs for class */
(H5I_free_t)H5M__close_cb /* Callback routine for closing objects of this class */
H5I_MAP, /* ID class value */
0, /* Class flags */
0, /* # of reserved IDs for class */
H5M__close_cb /* Callback routine for closing objects of this class */
}};
/* Flag indicating "top" of interface has been initialized */
@@ -207,26 +207,27 @@ H5M_term_package(void)
*-------------------------------------------------------------------------
*/
static herr_t
H5M__close_cb(H5VL_object_t *map_vol_obj, void **request)
H5M__close_cb(void *map_vol_obj, void **request)
{
H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */
herr_t ret_value = SUCCEED; /* Return value */
H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */
H5VL_object_t *map_vol_obj_p = (H5VL_object_t *)map_vol_obj;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
/* Sanity check */
assert(map_vol_obj);
assert(map_vol_obj_p);
/* Set up VOL callback arguments */
vol_cb_args.op_type = H5VL_MAP_CLOSE;
vol_cb_args.args = NULL;
/* Close the map */
if (H5VL_optional(map_vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, request) < 0)
if (H5VL_optional(map_vol_obj_p, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, request) < 0)
HGOTO_ERROR(H5E_MAP, H5E_CLOSEERROR, FAIL, "unable to close map");
/* Free the VOL object */
if (H5VL_free_object(map_vol_obj) < 0)
if (H5VL_free_object(map_vol_obj_p) < 0)
HGOTO_ERROR(H5E_MAP, H5E_CANTDEC, FAIL, "unable to free VOL object");
done:
+5 -1
View File
@@ -1490,7 +1490,7 @@ H5O__dtype_decode(H5F_t *f, H5O_t *open_oh, unsigned H5_ATTR_UNUSED mesg_flags,
{
bool skip;
H5T_t *dt = NULL;
const uint8_t *p_end = p + p_size - 1;
const uint8_t *p_end = NULL;
void *ret_value = NULL;
FUNC_ENTER_PACKAGE
@@ -1508,6 +1508,10 @@ H5O__dtype_decode(H5F_t *f, H5O_t *open_oh, unsigned H5_ATTR_UNUSED mesg_flags,
* as a signal to skip bounds checking.
*/
skip = (p_size == SIZE_MAX ? true : false);
if (skip)
p_end = p;
else
p_end = p + p_size - 1;
/* Indicate if the object header has a checksum, or if the
* H5F_RFIC_UNUSUAL_NUM_UNUSED_NUMERIC_BITS flag is set */
+8 -8
View File
@@ -393,18 +393,18 @@ H5FL_DEFINE_STATIC(H5P_genplist_t);
/* Generic Property Class ID class */
static const H5I_class_t H5I_GENPROPCLS_CLS[1] = {{
H5I_GENPROP_CLS, /* ID class value */
0, /* Class flags */
0, /* # of reserved IDs for class */
(H5I_free_t)H5P__close_class_cb /* Callback routine for closing objects of this class */
H5I_GENPROP_CLS, /* ID class value */
0, /* Class flags */
0, /* # of reserved IDs for class */
H5P__close_class_cb /* Callback routine for closing objects of this class */
}};
/* Generic Property List ID class */
static const H5I_class_t H5I_GENPROPLST_CLS[1] = {{
H5I_GENPROP_LST, /* ID class value */
0, /* Class flags */
0, /* # of reserved IDs for class */
(H5I_free_t)H5P__close_list_cb /* Callback routine for closing objects of this class */
H5I_GENPROP_LST, /* ID class value */
0, /* Class flags */
0, /* # of reserved IDs for class */
H5P__close_list_cb /* Callback routine for closing objects of this class */
}};
/*-------------------------------------------------------------------------
+8 -8
View File
@@ -83,18 +83,18 @@ H5FL_ARR_DEFINE(hsize_t, H5S_MAX_RANK);
/* Dataspace ID class */
static const H5I_class_t H5I_DATASPACE_CLS[1] = {{
H5I_DATASPACE, /* ID class value */
0, /* Class flags */
3, /* # of reserved IDs for class */
(H5I_free_t)H5S__close_cb /* Callback routine for closing objects of this class */
H5I_DATASPACE, /* ID class value */
0, /* Class flags */
3, /* # of reserved IDs for class */
H5S__close_cb /* Callback routine for closing objects of this class */
}};
/* Dataspace selection iterator ID class */
static const H5I_class_t H5I_SPACE_SEL_ITER_CLS[1] = {{
H5I_SPACE_SEL_ITER, /* ID class value */
0, /* Class flags */
0, /* # of reserved IDs for class */
(H5I_free_t)H5S__sel_iter_close_cb /* Callback routine for closing objects of this class */
H5I_SPACE_SEL_ITER, /* ID class value */
0, /* Class flags */
0, /* # of reserved IDs for class */
H5S__sel_iter_close_cb /* Callback routine for closing objects of this class */
}};
/* Flag indicating "top" of interface has been initialized */
+10 -5
View File
@@ -624,16 +624,21 @@ H5S__all_serialize(H5S_t *space, uint8_t **p)
static herr_t
H5S__all_deserialize(H5S_t **space, const uint8_t **p, const size_t p_size, bool skip)
{
uint32_t version; /* Version number */
H5S_t *tmp_space = NULL; /* Pointer to actual dataspace to use,
either *space or a newly allocated one */
herr_t ret_value = SUCCEED; /* return value */
const uint8_t *p_end = *p + p_size - 1; /* Pointer to last valid byte in buffer */
const uint8_t *p_end;
uint32_t version; /* Version number */
H5S_t *tmp_space = NULL; /* Pointer to actual dataspace to use, either *space or a newly allocated one */
herr_t ret_value = SUCCEED; /* return value */
FUNC_ENTER_PACKAGE
assert(p);
assert(*p);
if (skip)
p_end = *p;
else
p_end = *p + p_size - 1; /* Pointer to last valid byte in buffer */
/* As part of the efforts to push all selection-type specific coding
to the callbacks, the coding for the allocation of a null dataspace
is moved from H5S_select_deserialize() in H5Sselect.c.
+19 -13
View File
@@ -4240,19 +4240,20 @@ done:
static herr_t
H5S__hyper_deserialize(H5S_t **space, const uint8_t **p, const size_t p_size, bool skip)
{
H5S_t *tmp_space = NULL; /* Pointer to actual dataspace to use,
either *space or a newly allocated one */
hsize_t dims[H5S_MAX_RANK]; /* Dimension sizes */
hsize_t start[H5S_MAX_RANK]; /* hyperslab start information */
hsize_t block[H5S_MAX_RANK]; /* hyperslab block information */
uint32_t version; /* Version number */
uint8_t flags = 0; /* Flags */
uint8_t enc_size = 0; /* Encoded size of selection info */
unsigned rank; /* rank of points */
const uint8_t *pp; /* Local pointer for decoding */
unsigned u; /* Local counting variable */
herr_t ret_value = FAIL; /* return value */
const uint8_t *p_end = *p + p_size - 1; /* Pointer to last valid byte in buffer */
H5S_t *tmp_space = NULL; /* Pointer to actual dataspace to use,
either *space or a newly allocated one */
hsize_t dims[H5S_MAX_RANK]; /* Dimension sizes */
hsize_t start[H5S_MAX_RANK]; /* hyperslab start information */
hsize_t block[H5S_MAX_RANK]; /* hyperslab block information */
uint32_t version; /* Version number */
uint8_t flags = 0; /* Flags */
uint8_t enc_size = 0; /* Encoded size of selection info */
unsigned rank; /* rank of points */
const uint8_t *pp; /* Local pointer for decoding */
unsigned u; /* Local counting variable */
herr_t ret_value = FAIL; /* return value */
const uint8_t *p_end;
FUNC_ENTER_PACKAGE
/* Check args */
@@ -4260,6 +4261,11 @@ H5S__hyper_deserialize(H5S_t **space, const uint8_t **p, const size_t p_size, bo
pp = (*p);
assert(pp);
if (skip)
p_end = *p;
else
p_end = *p + p_size - 1; /* Pointer to last valid byte in buffer */
/* As part of the efforts to push all selection-type specific coding
to the callbacks, the coding for the allocation of a null dataspace
is moved from H5S_select_deserialize() in H5Sselect.c to here.
+1 -1
View File
@@ -396,7 +396,7 @@ H5_DLL herr_t H5S__hyper_project_intersection(H5S_t *src_space, H5S_t *dst_space
H5S_t *proj_space, bool share_space);
/* Operations on selection iterators */
H5_DLL herr_t H5S__sel_iter_close_cb(H5S_sel_iter_t *_sel_iter, void **request);
H5_DLL herr_t H5S__sel_iter_close_cb(void *_sel_iter, void **request);
/* Testing functions */
#ifdef H5S_TESTING
+8 -2
View File
@@ -1363,8 +1363,9 @@ H5S__point_deserialize(H5S_t **space, const uint8_t **p, const size_t p_size, bo
unsigned i, j; /* local counting variables */
size_t enc_type_size;
size_t coordinate_buffer_requirement;
herr_t ret_value = SUCCEED; /* Return value */
const uint8_t *p_end = *p + p_size - 1; /* Pointer to last valid byte in buffer */
herr_t ret_value = SUCCEED; /* Return value */
const uint8_t *p_end;
FUNC_ENTER_PACKAGE
/* Check args */
@@ -1372,6 +1373,11 @@ H5S__point_deserialize(H5S_t **space, const uint8_t **p, const size_t p_size, bo
pp = (*p);
assert(pp);
if (skip)
p_end = *p;
else
p_end = *p + p_size - 1; /* Pointer to last valid byte in buffer */
/* As part of the efforts to push all selection-type specific coding
to the callbacks, the coding for the allocation of a null dataspace
is moved from H5S_select_deserialize() in H5Sselect.c to here.
+13 -5
View File
@@ -523,14 +523,22 @@ H5S_select_valid(const H5S_t *space)
herr_t
H5S_select_deserialize(H5S_t **space, const uint8_t **p, const size_t p_size)
{
uint32_t sel_type; /* Pointer to the selection type */
herr_t ret_value = FAIL; /* Return value */
const uint8_t *p_end = *p + p_size - 1; /* Pointer to last valid byte in buffer */
bool skip = (p_size == SIZE_MAX ? true : false); /* If p_size is unknown, skip buffer checks */
uint32_t sel_type; /* Pointer to the selection type */
herr_t ret_value = FAIL; /* Return value */
const uint8_t *p_end = NULL; /* Pointer to last valid byte in buffer */
bool skip = false;
FUNC_ENTER_NOAPI(FAIL)
assert(space);
/* If p_size is unknown, skip buffer checks */
skip = (p_size == SIZE_MAX ? true : false);
if (skip)
p_end = *p;
else
p_end = *p + p_size - 1;
/* Selection-type specific coding is moved to the callbacks. */
/* Decode selection type */
@@ -3069,7 +3077,7 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
H5S__sel_iter_close_cb(H5S_sel_iter_t *_sel_iter, void H5_ATTR_UNUSED **request)
H5S__sel_iter_close_cb(void *_sel_iter, void H5_ATTR_UNUSED **request)
{
H5S_sel_iter_t *sel_iter = (H5S_sel_iter_t *)_sel_iter; /* The selection iterator to close */
herr_t ret_value = SUCCEED; /* Return value */
+14 -13
View File
@@ -485,7 +485,7 @@ static herr_t H5T__register_int(H5T_pers_t pers, const char *name, H5T_t *src, H
static herr_t H5T__register(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst, H5T_conv_func_t *conv);
static htri_t H5T__compiler_conv(H5T_t *src, H5T_t *dst);
static herr_t H5T__set_size(H5T_t *dt, size_t size);
static herr_t H5T__close_cb(H5T_t *dt, void **request);
static herr_t H5T__close_cb(void *dt, void **request);
static herr_t H5T__init_path_table(void);
static bool H5T__path_table_search(const H5T_t *src, const H5T_t *dst, int *idx, int *last_cmp);
static H5T_path_t *H5T__path_find_real(const H5T_t *src, const H5T_t *dst, const char *name,
@@ -767,10 +767,10 @@ H5FL_DEFINE_STATIC(H5T_path_t);
/* Datatype ID class */
static const H5I_class_t H5I_DATATYPE_CLS[1] = {{
H5I_DATATYPE, /* ID class value */
0, /* Class flags */
8, /* # of reserved IDs for class */
(H5I_free_t)H5T__close_cb /* Callback routine for closing objects of this class */
H5I_DATATYPE, /* ID class value */
0, /* Class flags */
8, /* # of reserved IDs for class */
H5T__close_cb /* Callback routine for closing objects of this class */
}};
/* Flag indicating "top" of interface has been initialized */
@@ -2480,31 +2480,32 @@ H5T_term_package(void)
*-------------------------------------------------------------------------
*/
static herr_t
H5T__close_cb(H5T_t *dt, void **request)
H5T__close_cb(void *dt, void **request)
{
H5T_t *dt_p = (H5T_t *)dt;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
/* Sanity check */
assert(dt);
assert(dt_p);
/* If this datatype is VOL-managed (i.e.: has a VOL object),
* close it through the VOL connector.
*/
if (NULL != dt->vol_obj) {
if (NULL != dt_p->vol_obj) {
/* Close the connector-managed datatype data */
if (H5VL_datatype_close(dt->vol_obj, H5P_DATASET_XFER_DEFAULT, request) < 0)
if (H5VL_datatype_close(dt_p->vol_obj, H5P_DATASET_XFER_DEFAULT, request) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL, "unable to close datatype");
/* Free the VOL object */
if (H5VL_free_object(dt->vol_obj) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "unable to free VOL object");
dt->vol_obj = NULL;
if (H5VL_free_object(dt_p->vol_obj) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDEC, FAIL, "unable to free VOL object");
dt_p->vol_obj = NULL;
} /* end if */
/* Close the datatype */
if (H5T_close(dt) < 0)
if (H5T_close(dt_p) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL, "unable to close datatype");
done:
+5 -7
View File
@@ -641,11 +641,10 @@ H5T__ref_mem_write(H5VL_object_t *src_file, const void *src_buf, size_t src_size
H5VL_object_t H5_ATTR_UNUSED *dst_file, void *dst_buf,
size_t H5_ATTR_NDEBUG_UNUSED dst_size, void H5_ATTR_UNUSED *bg_buf)
{
H5F_t *src_f = NULL;
hid_t file_id = H5I_INVALID_HID;
H5R_ref_priv_t *dst_ref = (H5R_ref_priv_t *)dst_buf;
H5R_ref_priv_t tmp_ref; /* Temporary reference to decode into */
herr_t ret_value = SUCCEED;
H5F_t *src_f = NULL;
hid_t file_id = H5I_INVALID_HID;
H5R_ref_priv_t tmp_ref; /* Temporary reference to decode into */
herr_t ret_value = SUCCEED;
FUNC_ENTER_PACKAGE
H5T_REF_LOG_DEBUG("");
@@ -655,7 +654,6 @@ H5T__ref_mem_write(H5VL_object_t *src_file, const void *src_buf, size_t src_size
assert(src_size);
assert(dst_buf);
assert(dst_size == H5T_REF_MEM_SIZE);
HDcompile_assert(sizeof(*dst_ref) == sizeof(tmp_ref));
/* Memory-to-memory conversion to support vlen conversion */
if (NULL == src_file) {
@@ -736,7 +734,7 @@ H5T__ref_mem_write(H5VL_object_t *src_file, const void *src_buf, size_t src_size
} /* end if */
/* Set output info */
H5MM_memcpy(dst_ref, &tmp_ref, sizeof(tmp_ref));
H5MM_memcpy(dst_buf, &tmp_ref, sizeof(tmp_ref));
done:
if ((file_id != H5I_INVALID_HID) && (H5I_dec_ref(file_id) < 0))
+10 -9
View File
@@ -97,7 +97,7 @@ static void *H5VL__wrap_obj(void *obj, H5I_type_t obj_type);
static H5VL_connector_t *H5VL__conn_create(H5VL_class_t *cls);
static herr_t H5VL__conn_find(H5PL_vol_key_t *key, H5VL_connector_t **connector);
static herr_t H5VL__conn_free(H5VL_connector_t *connector);
static herr_t H5VL__conn_free_id(H5VL_connector_t *connector, void H5_ATTR_UNUSED **request);
static herr_t H5VL__conn_free_id(void *connector, void H5_ATTR_UNUSED **request);
static void *H5VL__object(hid_t id, H5I_type_t obj_type);
static herr_t H5VL__free_vol_wrapper(H5VL_wrap_ctx_t *vol_wrap_ctx);
@@ -118,10 +118,10 @@ bool H5_PKG_INIT_VAR = false;
/* VOL ID class */
static const H5I_class_t H5I_VOL_CLS[1] = {{
H5I_VOL, /* ID class value */
0, /* Class flags */
0, /* # of reserved IDs for class */
(H5I_free_t)H5VL__conn_free_id /* Callback routine for closing objects of this class */
H5I_VOL, /* ID class value */
0, /* Class flags */
0, /* # of reserved IDs for class */
H5VL__conn_free_id /* Callback routine for closing objects of this class */
}};
/* Declare a free list to manage the H5VL_class_t struct */
@@ -1122,17 +1122,18 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
H5VL__conn_free_id(H5VL_connector_t *connector, void H5_ATTR_UNUSED **request)
H5VL__conn_free_id(void *connector, void H5_ATTR_UNUSED **request)
{
herr_t ret_value = SUCCEED; /* Return value */
H5VL_connector_t *connector_p = (H5VL_connector_t *)connector;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
/* Check arguments */
assert(connector);
assert(connector_p);
/* Decrement refcount on connector */
if (H5VL_conn_dec_rc(connector) < 0)
if (H5VL_conn_dec_rc(connector_p) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTDEC, FAIL, "unable to decrement ref count on VOL connector");
done: