summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDana Robinson <43805+derobins@users.noreply.github.com>2022-04-08 13:22:07 (GMT)
committerGitHub <noreply@github.com>2022-04-08 13:22:07 (GMT)
commit236297c00d630b391b2ee3b98e67b0b83d642a12 (patch)
tree4c047585c6c8878d3d592dc398536ccff27ee5ee /src
parent02d0208187af16137d01a3261961ab8fabd65d28 (diff)
downloadhdf5-236297c00d630b391b2ee3b98e67b0b83d642a12.zip
hdf5-236297c00d630b391b2ee3b98e67b0b83d642a12.tar.gz
hdf5-236297c00d630b391b2ee3b98e67b0b83d642a12.tar.bz2
1.12: Last round of normalizations for 1.12.2 (#1621)
Diffstat (limited to 'src')
-rw-r--r--src/H5.c35
-rw-r--r--src/H5A.c46
-rw-r--r--src/H5Dchunk.c34
-rw-r--r--src/H5Dcompact.c25
-rw-r--r--src/H5Dint.c6
-rw-r--r--src/H5M.c4
-rw-r--r--src/H5VMprivate.h4
-rw-r--r--src/H5system.c4
-rw-r--r--src/H5timer.c15
9 files changed, 105 insertions, 68 deletions
diff --git a/src/H5.c b/src/H5.c
index 23a02d0..df30ded 100644
--- a/src/H5.c
+++ b/src/H5.c
@@ -597,12 +597,13 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5get_free_list_sizes(size_t *reg_size, size_t *arr_size, size_t *blk_size, size_t *fac_size)
+H5get_free_list_sizes(size_t *reg_size /*out*/, size_t *arr_size /*out*/, size_t *blk_size /*out*/,
+ size_t *fac_size /*out*/)
{
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
- H5TRACE4("e", "*z*z*z*z", reg_size, arr_size, blk_size, fac_size);
+ H5TRACE4("e", "xxxx", reg_size, arr_size, blk_size, fac_size);
/* Call the free list function to actually get the sizes */
if (H5FL_get_free_list_sizes(reg_size, arr_size, blk_size, fac_size) < 0)
@@ -637,12 +638,12 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5get_alloc_stats(H5_alloc_stats_t *stats)
+H5get_alloc_stats(H5_alloc_stats_t *stats /*out*/)
{
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
- H5TRACE1("e", "*x", stats);
+ H5TRACE1("e", "x", stats);
/* Call the internal allocation stat routine to get the values */
if (H5MM_get_alloc_stats(stats) < 0)
@@ -797,12 +798,12 @@ H5__mpi_delete_cb(MPI_Comm H5_ATTR_UNUSED comm, int H5_ATTR_UNUSED keyval, void
*-------------------------------------------------------------------------
*/
herr_t
-H5get_libversion(unsigned *majnum, unsigned *minnum, unsigned *relnum)
+H5get_libversion(unsigned *majnum /*out*/, unsigned *minnum /*out*/, unsigned *relnum /*out*/)
{
herr_t ret_value = SUCCEED;
FUNC_ENTER_API(FAIL)
- H5TRACE3("e", "*Iu*Iu*Iu", majnum, minnum, relnum);
+ H5TRACE3("e", "xxx", majnum, minnum, relnum);
/* Set the version information */
if (majnum)
@@ -920,6 +921,7 @@ H5check_version(unsigned majnum, unsigned minnum, unsigned relnum)
} /* end if (H5_VERS_MAJOR != majnum || H5_VERS_MINOR != minnum) */
/* H5_VERS_RELEASE should be compatible, we will only add checks for exceptions */
+ /* Library develop release versions are incompatible by design */
if (H5_VERS_RELEASE != relnum) {
for (unsigned i = 0; i < VERS_RELEASE_EXCEPTIONS_SIZE; i++) {
/* Check for incompatible headers or incompatible library */
@@ -1024,7 +1026,7 @@ done:
/*-------------------------------------------------------------------------
* Function: H5close
*
- * Purpose: Terminate the library and release all resources.
+ * Purpose: Terminate the library and release all resources.
*
* Return: Non-negative on success/Negative on failure
*
@@ -1158,21 +1160,24 @@ H5free_memory(void *mem)
*-------------------------------------------------------------------------
*/
herr_t
-H5is_library_threadsafe(hbool_t *is_ts)
+H5is_library_threadsafe(hbool_t *is_ts /*out*/)
{
- FUNC_ENTER_API_NOINIT
- H5TRACE1("e", "*b", is_ts);
+ herr_t ret_value = SUCCEED; /* Return value */
- HDassert(is_ts);
+ FUNC_ENTER_API_NOINIT
+ H5TRACE1("e", "x", is_ts);
- /* At this time, it is impossible for this to fail. */
+ if (is_ts) {
#ifdef H5_HAVE_THREADSAFE
- *is_ts = TRUE;
+ *is_ts = TRUE;
#else /* H5_HAVE_THREADSAFE */
- *is_ts = FALSE;
+ *is_ts = FALSE;
#endif /* H5_HAVE_THREADSAFE */
+ }
+ else
+ ret_value = FAIL;
- FUNC_LEAVE_API_NOINIT(SUCCEED)
+ FUNC_LEAVE_API_NOINIT(ret_value)
} /* end H5is_library_threadsafe() */
#if defined(H5_HAVE_THREADSAFE) && defined(H5_BUILT_AS_DYNAMIC_LIB) && defined(H5_HAVE_WIN32_API) && \
diff --git a/src/H5A.c b/src/H5A.c
index 736d3cb..c1c0043 100644
--- a/src/H5A.c
+++ b/src/H5A.c
@@ -642,8 +642,8 @@ done:
herr_t
H5Awrite(hid_t attr_id, hid_t dtype_id, const void *buf)
{
- H5VL_object_t *vol_obj; /* Attribute object for ID */
- herr_t ret_value; /* Return value */
+ H5VL_object_t *vol_obj; /* Attribute object for ID */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE3("e", "ii*x", attr_id, dtype_id, buf);
@@ -685,13 +685,13 @@ done:
This function reads a complete attribute from disk.
--------------------------------------------------------------------------*/
herr_t
-H5Aread(hid_t attr_id, hid_t dtype_id, void *buf)
+H5Aread(hid_t attr_id, hid_t dtype_id, void *buf /*out*/)
{
- H5VL_object_t *vol_obj; /* Attribute object for ID */
- herr_t ret_value; /* Return value */
+ H5VL_object_t *vol_obj; /* Attribute object for ID */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
- H5TRACE3("e", "ii*x", attr_id, dtype_id, buf);
+ H5TRACE3("e", "iix", attr_id, dtype_id, buf);
/* Check arguments */
if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(attr_id, H5I_ATTR)))
@@ -849,14 +849,14 @@ done:
properly terminate the string.
--------------------------------------------------------------------------*/
ssize_t
-H5Aget_name(hid_t attr_id, size_t buf_size, char *buf)
+H5Aget_name(hid_t attr_id, size_t buf_size, char *buf /*out*/)
{
H5VL_object_t * vol_obj = NULL; /* Attribute object for ID */
H5VL_loc_params_t loc_params;
ssize_t ret_value = -1;
FUNC_ENTER_API((-1))
- H5TRACE3("Zs", "iz*s", attr_id, buf_size, buf);
+ H5TRACE3("Zs", "izx", attr_id, buf_size, buf);
/* check arguments */
if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(attr_id, H5I_ATTR)))
@@ -995,14 +995,14 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5Aget_info(hid_t attr_id, H5A_info_t *ainfo)
+H5Aget_info(hid_t attr_id, H5A_info_t *ainfo /*out*/)
{
H5VL_object_t * vol_obj;
H5VL_loc_params_t loc_params;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
- H5TRACE2("e", "i*x", attr_id, ainfo);
+ H5TRACE2("e", "ix", attr_id, ainfo);
/* Check args */
if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(attr_id, H5I_ATTR)))
@@ -1036,7 +1036,7 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5Aget_info_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, H5A_info_t *ainfo,
+H5Aget_info_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, H5A_info_t *ainfo /*out*/,
hid_t lapl_id)
{
H5VL_object_t * vol_obj;
@@ -1044,7 +1044,7 @@ H5Aget_info_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, H
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
- H5TRACE5("e", "i*s*s*xi", loc_id, obj_name, attr_name, ainfo, lapl_id);
+ H5TRACE5("e", "i*s*sxi", loc_id, obj_name, attr_name, ainfo, lapl_id);
/* Check args */
if (H5I_ATTR == H5I_get_type(loc_id))
@@ -1094,14 +1094,14 @@ done:
*/
herr_t
H5Aget_info_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n,
- H5A_info_t *ainfo, hid_t lapl_id)
+ H5A_info_t *ainfo /*out*/, hid_t lapl_id)
{
H5VL_object_t * vol_obj;
H5VL_loc_params_t loc_params;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
- H5TRACE7("e", "i*sIiIoh*xi", loc_id, obj_name, idx_type, order, n, ainfo, lapl_id);
+ H5TRACE7("e", "i*sIiIohxi", loc_id, obj_name, idx_type, order, n, ainfo, lapl_id);
/* Check args */
if (H5I_ATTR == H5I_get_type(loc_id))
@@ -1300,17 +1300,17 @@ done:
attribute.
--------------------------------------------------------------------------*/
herr_t
-H5Aiterate2(hid_t loc_id, H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx, H5A_operator2_t op,
- void *op_data)
+H5Aiterate2(hid_t loc_id, H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx /*in_out */,
+ H5A_operator2_t op, void *op_data)
{
- H5VL_object_t * vol_obj = NULL; /* object of loc_id */
+ H5VL_object_t * vol_obj = NULL; /* Object for loc_id */
H5VL_loc_params_t loc_params;
herr_t ret_value; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE6("e", "iIiIo*hx*x", loc_id, idx_type, order, idx, op, op_data);
- /* check arguments */
+ /* Check arguments */
if (H5I_ATTR == H5I_get_type(loc_id))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute")
if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N)
@@ -1318,10 +1318,11 @@ H5Aiterate2(hid_t loc_id, H5_index_t idx_type, H5_iter_order_t order, hsize_t *i
if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified")
+ /* Set the location access parameters */
loc_params.type = H5VL_OBJECT_BY_SELF;
loc_params.obj_type = H5I_get_type(loc_id);
- /* get the loc object */
+ /* Get the loc object */
if (NULL == (vol_obj = H5VL_vol_object(loc_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier")
@@ -1379,7 +1380,7 @@ done:
--------------------------------------------------------------------------*/
herr_t
H5Aiterate_by_name(hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5_iter_order_t order,
- hsize_t *idx, H5A_operator2_t op, void *op_data, hid_t lapl_id)
+ hsize_t *idx /*in_out */, H5A_operator2_t op, void *op_data, hid_t lapl_id)
{
H5VL_object_t * vol_obj = NULL; /* Object location */
H5VL_loc_params_t loc_params;
@@ -1402,6 +1403,7 @@ H5Aiterate_by_name(hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5_i
if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set access property list info")
+ /* Set the location access parameters */
loc_params.type = H5VL_OBJECT_BY_NAME;
loc_params.obj_type = H5I_get_type(loc_id);
loc_params.loc_data.loc_by_name.name = obj_name;
@@ -1511,7 +1513,7 @@ H5Adelete_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, hid
if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, TRUE) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set access property list info")
- /* Fill in location struct fields */
+ /* Set the location access parameters */
loc_params.type = H5VL_OBJECT_BY_NAME;
loc_params.loc_data.loc_by_name.name = obj_name;
loc_params.loc_data.loc_by_name.lapl_id = lapl_id;
@@ -1683,7 +1685,7 @@ done:
* Purpose: Checks if an attribute with a given name exists on an object.
*
* Return: Success: TRUE/FALSE
- * Failure: Negative
+ * Failure: Negative
*
* Programmer: Quincey Koziol
* Thursday, November 1, 2007
diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c
index f0fc3a4..e6bf26c 100644
--- a/src/H5Dchunk.c
+++ b/src/H5Dchunk.c
@@ -107,9 +107,9 @@
/*#define H5D_CHUNK_DEBUG */
/* Flags for the "edge_chunk_state" field below */
-#define H5D_RDCC_DISABLE_FILTERS 0x01u /* Disable filters on this chunk */
+#define H5D_RDCC_DISABLE_FILTERS 0x01U /* Disable filters on this chunk */
#define H5D_RDCC_NEWLY_DISABLED_FILTERS \
- 0x02u /* Filters have been disabled since \
+ 0x02U /* Filters have been disabled since \
* the last flush */
/******************/
@@ -322,13 +322,24 @@ static int H5D__chunk_dump_index_cb(const H5D_chunk_rec_t *chunk_rec, void *_uda
/*********************/
/* Chunked storage layout I/O ops */
-const H5D_layout_ops_t H5D_LOPS_CHUNK[1] = {
- {H5D__chunk_construct, H5D__chunk_init, H5D__chunk_is_space_alloc, H5D__chunk_is_data_cached,
- H5D__chunk_io_init, H5D__chunk_read, H5D__chunk_write,
+const H5D_layout_ops_t H5D_LOPS_CHUNK[1] = {{
+ H5D__chunk_construct, /* construct */
+ H5D__chunk_init, /* init */
+ H5D__chunk_is_space_alloc, /* is_space_alloc */
+ H5D__chunk_is_data_cached, /* is_data_cached */
+ H5D__chunk_io_init, /* io_init */
+ H5D__chunk_read, /* ser_read */
+ H5D__chunk_write, /* ser_write */
#ifdef H5_HAVE_PARALLEL
- H5D__chunk_collective_read, H5D__chunk_collective_write,
-#endif /* H5_HAVE_PARALLEL */
- NULL, NULL, H5D__chunk_flush, H5D__chunk_io_term, H5D__chunk_dest}};
+ H5D__chunk_collective_read, /* par_read */
+ H5D__chunk_collective_write, /* par_write */
+#endif
+ NULL, /* readvv */
+ NULL, /* writevv */
+ H5D__chunk_flush, /* flush */
+ H5D__chunk_io_term, /* io_term */
+ H5D__chunk_dest /* dest */
+}};
/*******************/
/* Local Variables */
@@ -595,8 +606,6 @@ H5D__get_chunk_storage_size(H5D_t *dset, const hsize_t *offset, hsize_t *storage
HDassert(offset);
HDassert(storage_size);
- *storage_size = 0;
-
/* Allocate dataspace and initialize it if it hasn't been. */
if (!(*layout->ops->is_space_alloc)(&layout->storage))
HGOTO_DONE(SUCCEED)
@@ -3603,7 +3612,7 @@ H5D__chunk_cache_prune(const H5D_t *dset, size_t size)
* traversing the list when pointer pN reaches wN percent of the original
* list. In other words, preemption method N gets to consider entries in
* approximate least recently used order w0 percent before method N+1
- * where 100% means that method N will run to completion before method N+1
+ * where 100% means the method N will run to completion before method N+1
* begins. The pointers participating in the list traversal are each
* given a chance at preemption before any of the pointers are advanced.
*/
@@ -6136,6 +6145,7 @@ H5D__chunk_copy_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata)
if (udata->chunk_in_cache) {
HDassert(H5F_addr_defined(chunk_rec->chunk_addr));
+ HDassert(ent);
HDassert(H5F_addr_defined(ent->chunk_block.offset));
H5_CHECKED_ASSIGN(nbytes, size_t, shared_fo->layout.u.chunk.size, uint32_t);
@@ -6417,7 +6427,7 @@ H5D__chunk_copy(H5F_t *f_src, H5O_storage_chunk_t *storage_src, H5O_layout_chunk
if (NULL == (buf_space = H5S_create_simple((unsigned)1, &buf_dim, NULL)))
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't create simple dataspace")
- /* Atomize */
+ /* Register */
if ((sid_buf = H5I_register(H5I_DATASPACE, buf_space, FALSE)) < 0) {
(void)H5S_close(buf_space);
HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace ID")
diff --git a/src/H5Dcompact.c b/src/H5Dcompact.c
index 8a2c770..b786936 100644
--- a/src/H5Dcompact.c
+++ b/src/H5Dcompact.c
@@ -71,13 +71,24 @@ static herr_t H5D__compact_dest(H5D_t *dset);
/*********************/
/* Compact storage layout I/O ops */
-const H5D_layout_ops_t H5D_LOPS_COMPACT[1] = {
- {H5D__compact_construct, NULL, H5D__compact_is_space_alloc, NULL, H5D__compact_io_init, H5D__contig_read,
- H5D__contig_write,
+const H5D_layout_ops_t H5D_LOPS_COMPACT[1] = {{
+ H5D__compact_construct, /* construct */
+ NULL, /* init */
+ H5D__compact_is_space_alloc, /* is_space_alloc */
+ NULL, /* is_data_cached */
+ H5D__compact_io_init, /* io_init */
+ H5D__contig_read, /* ser_read */
+ H5D__contig_write, /* ser_write */
#ifdef H5_HAVE_PARALLEL
- NULL, NULL,
-#endif /* H5_HAVE_PARALLEL */
- H5D__compact_readvv, H5D__compact_writevv, H5D__compact_flush, NULL, H5D__compact_dest}};
+ NULL, /* par_read */
+ NULL, /* par_write */
+#endif
+ H5D__compact_readvv, /* readvv */
+ H5D__compact_writevv, /* writevv */
+ H5D__compact_flush, /* flush */
+ NULL, /* io_term */
+ H5D__compact_dest /* dest */
+}};
/*******************/
/* Local Variables */
@@ -493,7 +504,7 @@ H5D__compact_copy(H5F_t *f_src, H5O_storage_compact_t *_storage_src, H5F_t *f_ds
if (NULL == (buf_space = H5S_create_simple((unsigned)1, &buf_dim, NULL)))
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't create simple dataspace")
- /* Atomize */
+ /* Register */
if ((buf_sid = H5I_register(H5I_DATASPACE, buf_space, FALSE)) < 0) {
H5S_close(buf_space);
HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace ID")
diff --git a/src/H5Dint.c b/src/H5Dint.c
index 6d3371d..53b691e 100644
--- a/src/H5Dint.c
+++ b/src/H5Dint.c
@@ -192,7 +192,7 @@ H5D__init_package(void)
FUNC_ENTER_PACKAGE
- /* Initialize the atom group for the dataset IDs */
+ /* Initialize the ID group for the dataset IDs */
if (H5I_register_type(H5I_DATASET_CLS) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize interface")
@@ -3854,7 +3854,7 @@ H5D__get_space(const H5D_t *dset)
if (NULL == (space = H5S_copy(dset->shared->space, FALSE, TRUE)))
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to get dataspace")
- /* Create an atom */
+ /* Create an ID */
if ((ret_value = H5I_register(H5I_DATASPACE, space, TRUE)) < 0)
HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace")
@@ -3901,7 +3901,7 @@ H5D__get_type(const H5D_t *dset)
if (H5T_lock(dt, FALSE) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to lock transient datatype")
- /* Create an atom */
+ /* Create an ID */
if (H5T_is_named(dt)) {
/* If this is a committed datatype, we need to recreate the
* two-level IDs, where the VOL object is a copy of the
diff --git a/src/H5M.c b/src/H5M.c
index e810e6d..cbb0dc3 100644
--- a/src/H5M.c
+++ b/src/H5M.c
@@ -353,7 +353,7 @@ H5Mcreate_anon(hid_t loc_id, hid_t key_type_id, hid_t val_type_id, hid_t mcpl_id
H5P_LINK_CREATE_DEFAULT, key_type_id, val_type_id, mcpl_id, mapl_id, &map) < 0)
HGOTO_ERROR(H5E_MAP, H5E_CANTINIT, H5I_INVALID_HID, "unable to create map")
- /* Get an atom for the map */
+ /* Get an ID for the map */
if ((ret_value = H5VL_register(H5I_MAP, map, vol_obj->connector, TRUE)) < 0)
HGOTO_ERROR(H5E_MAP, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register map")
@@ -415,7 +415,7 @@ H5Mopen(hid_t loc_id, const char *name, hid_t mapl_id)
mapl_id, &map) < 0)
HGOTO_ERROR(H5E_MAP, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open map")
- /* Register an atom for the map */
+ /* Register an ID for the map */
if ((ret_value = H5VL_register(H5I_MAP, map, vol_obj->connector, TRUE)) < 0)
HGOTO_ERROR(H5E_MAP, H5E_CANTREGISTER, H5I_INVALID_HID, "can't register map atom")
diff --git a/src/H5VMprivate.h b/src/H5VMprivate.h
index 0d3bd0f..e773bae 100644
--- a/src/H5VMprivate.h
+++ b/src/H5VMprivate.h
@@ -393,8 +393,8 @@ static const unsigned char LogTable256[] = {
static inline unsigned H5_ATTR_UNUSED
H5VM_log2_gen(uint64_t n)
{
- unsigned r; /* r will be log2(n) */
- register unsigned int t, tt, ttt; /* temporaries */
+ unsigned r; /* r will be log2(n) */
+ unsigned int t, tt, ttt; /* temporaries */
if ((ttt = (unsigned)(n >> 32)))
if ((tt = (unsigned)(n >> 48)))
diff --git a/src/H5system.c b/src/H5system.c
index 8c1fe15..7d15ee4 100644
--- a/src/H5system.c
+++ b/src/H5system.c
@@ -987,7 +987,7 @@ H5_nanosleep(uint64_t nanosec)
#else
- const uint64_t nanosec_per_sec = 1000 * 1000 * 1000;
+ const uint64_t nanosec_per_sec = 1000 * 1000L * 1000;
struct timespec sleeptime; /* Struct to hold time to sleep */
/* Set up time to sleep
@@ -1158,7 +1158,7 @@ H5_get_option(int argc, const char *const *argv, const char *opts, const struct
HDfree(arg);
}
else {
- register char *cp; /* pointer into current token */
+ char *cp; /* pointer into current token */
/* short command line option */
optchar = argv[H5_optind][sp];
diff --git a/src/H5timer.c b/src/H5timer.c
index b2cc5f0..b5dba97 100644
--- a/src/H5timer.c
+++ b/src/H5timer.c
@@ -193,17 +193,26 @@ H5_now_usec(void)
struct timespec ts;
HDclock_gettime(CLOCK_MONOTONIC, &ts);
- now = (uint64_t)(ts.tv_sec * (1000 * 1000)) + (uint64_t)(ts.tv_nsec / 1000);
+
+ /* Cast all values in this expression to uint64_t to ensure that all intermediate
+ * calculations are done in 64 bit, to prevent overflow */
+ now = ((uint64_t)ts.tv_sec * ((uint64_t)1000 * (uint64_t)1000)) +
+ ((uint64_t)ts.tv_nsec / (uint64_t)1000);
}
#elif defined(H5_HAVE_GETTIMEOFDAY)
{
struct timeval now_tv;
HDgettimeofday(&now_tv, NULL);
- now = (uint64_t)(now_tv.tv_sec * (1000 * 1000)) + (uint64_t)now_tv.tv_usec;
+
+ /* Cast all values in this expression to uint64_t to ensure that all intermediate
+ * calculations are done in 64 bit, to prevent overflow */
+ now = ((uint64_t)now_tv.tv_sec * ((uint64_t)1000 * (uint64_t)1000)) + (uint64_t)now_tv.tv_usec;
}
#else /* H5_HAVE_GETTIMEOFDAY */
- now = (uint64_t)(HDtime(NULL) * (1000 * 1000));
+ /* Cast all values in this expression to uint64_t to ensure that all intermediate calculations
+ * are done in 64 bit, to prevent overflow */
+ now = ((uint64_t)HDtime(NULL) * ((uint64_t)1000 * (uint64_t)1000));
#endif /* H5_HAVE_GETTIMEOFDAY */
return (now);