summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJerome Soumagne <jsoumagne@hdfgroup.org>2019-12-05 23:25:22 (GMT)
committerJerome Soumagne <jsoumagne@hdfgroup.org>2019-12-05 23:25:22 (GMT)
commit107bcbd3dfff51895c99ea3ff71afa0ce693a956 (patch)
tree0f267b01ff7617ee44c904fc6ad7cbd4d13303f9 /src
parent5efd80f6ec558845e7438a7407888de56da63588 (diff)
parent7b03a1c03633d695b487642e54f897c715f8622e (diff)
downloadhdf5-107bcbd3dfff51895c99ea3ff71afa0ce693a956.zip
hdf5-107bcbd3dfff51895c99ea3ff71afa0ce693a956.tar.gz
hdf5-107bcbd3dfff51895c99ea3ff71afa0ce693a956.tar.bz2
Merge pull request #2076 in HDFFV/hdf5 from ~JSOUMAGNE/hdf5:type_fixes to develop
* commit '7b03a1c03633d695b487642e54f897c715f8622e': Fix H5VL_token_t type and fix H5VL_loc_by_token to use H5VL_token_t * Change hdset_reg_ref_t and H5R_ref_t from arrays of unsigned char to structs containing those arrays. Encapsulating the arrays in this way makes it easier to write and think about pointers to these types, casts to/from these types, etc.
Diffstat (limited to 'src')
-rw-r--r--src/H5O.c4
-rw-r--r--src/H5Ocopy_ref.c8
-rw-r--r--src/H5R.c16
-rw-r--r--src/H5Rdeprec.c12
-rw-r--r--src/H5Rint.c20
-rw-r--r--src/H5Rpublic.h8
-rw-r--r--src/H5VLconnector.h6
-rw-r--r--src/H5VLnative_object.c2
8 files changed, 41 insertions, 35 deletions
diff --git a/src/H5O.c b/src/H5O.c
index 7e5694a..3938413 100644
--- a/src/H5O.c
+++ b/src/H5O.c
@@ -290,11 +290,11 @@ H5Oopen_by_addr(hid_t loc_id, haddr_t addr)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid VOL object")
/* This is a native specific routine that requires serialization of the token */
- p = obj_token;
+ p = (uint8_t *)&obj_token;
H5F_addr_encode(f, &p, addr);
loc_params.type = H5VL_OBJECT_BY_TOKEN;
- loc_params.loc_data.loc_by_token.token = obj_token;
+ loc_params.loc_data.loc_by_token.token = &obj_token;
loc_params.obj_type = vol_obj_type;
/* Open the object */
diff --git a/src/H5Ocopy_ref.c b/src/H5Ocopy_ref.c
index 20b8454..b835f8e 100644
--- a/src/H5Ocopy_ref.c
+++ b/src/H5Ocopy_ref.c
@@ -185,7 +185,7 @@ H5O__copy_expand_ref_object1(H5O_loc_t *src_oloc, const void *buf_src,
/* Set up for the object copy for the reference */
if(H5R__decode_token_obj_compat(src_buf, &buf_size, &tmp_token, token_size) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, FAIL, "unable to decode src object address")
- p = tmp_token;
+ p = (uint8_t *)&tmp_token;
H5F_addr_decode(src_oloc->file, (const uint8_t **)&p, &src_oloc->addr);
if(!H5F_addr_defined(src_oloc->addr) || src_oloc->addr == 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "undefined reference pointer")
@@ -196,7 +196,7 @@ H5O__copy_expand_ref_object1(H5O_loc_t *src_oloc, const void *buf_src,
HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy object")
/* Set the object reference info for the destination file */
- p = tmp_token;
+ p = (uint8_t *)&tmp_token;
H5F_addr_encode(dst_oloc->file, &p, dst_oloc->addr);
if(H5R__encode_token_obj_compat((const H5VL_token_t *)&tmp_token, token_size, dst_buf, &buf_size) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, FAIL, "unable to encode dst object address")
@@ -371,7 +371,7 @@ H5O__copy_expand_ref_object2(H5O_loc_t *src_oloc, hid_t tid_src, H5T_t *dt_src,
/* Get src object address */
if(H5R__get_obj_token(ref, &tmp_token, &token_size) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to get object token")
- p = tmp_token;
+ p = (uint8_t *)&tmp_token;
H5F_addr_decode(src_oloc->file, (const uint8_t **)&p, &src_oloc->addr);
/* Attempt to copy object from source to destination file */
@@ -379,7 +379,7 @@ H5O__copy_expand_ref_object2(H5O_loc_t *src_oloc, hid_t tid_src, H5T_t *dt_src,
HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy object")
/* Set dst object address */
- p = tmp_token;
+ p = (uint8_t *)&tmp_token;
H5F_addr_encode(dst_oloc->file, &p, dst_oloc->addr);
if(H5R__set_obj_token(ref, (const H5VL_token_t *)&tmp_token, token_size) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "unable to set object token")
diff --git a/src/H5R.c b/src/H5R.c
index 70d4749..2c4c713 100644
--- a/src/H5R.c
+++ b/src/H5R.c
@@ -130,7 +130,7 @@ H5Rcreate_object(hid_t loc_id, const char *name, hid_t oapl_id, H5R_ref_t *ref_p
loc_params.obj_type = obj_type;
/* Get the object token */
- if(H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_LOOKUP, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, obj_token) < 0)
+ if(H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_LOOKUP, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &obj_token) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to retrieve object token")
/* Create the reference (do not pass filename, since file_id is attached) */
@@ -223,7 +223,7 @@ H5Rcreate_region(hid_t loc_id, const char *name, hid_t space_id,
loc_params.obj_type = obj_type;
/* Get the object token */
- if(H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_LOOKUP, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, obj_token) < 0)
+ if(H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_LOOKUP, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &obj_token) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to retrieve object token")
/* Create the reference (do not pass filename, since file_id is attached) */
@@ -312,7 +312,7 @@ H5Rcreate_attr(hid_t loc_id, const char *name, const char *attr_name,
loc_params.obj_type = obj_type;
/* Get the object token */
- if(H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_LOOKUP, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, obj_token) < 0)
+ if(H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_LOOKUP, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &obj_token) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to retrieve object token")
/* Create the reference (do not pass filename, since file_id is attached) */
@@ -511,7 +511,7 @@ H5Ropen_object(const H5R_ref_t *ref_ptr, hid_t rapl_id, hid_t oapl_id)
/* Set location parameters */
loc_params.type = H5VL_OBJECT_BY_TOKEN;
- loc_params.loc_data.loc_by_token.token = obj_token;
+ loc_params.loc_data.loc_by_token.token = &obj_token;
loc_params.obj_type = H5I_get_type(loc_id);
/* Open object by token */
@@ -583,7 +583,7 @@ H5Ropen_region(const H5R_ref_t *ref_ptr, hid_t rapl_id, hid_t oapl_id)
/* Set location parameters */
loc_params.type = H5VL_OBJECT_BY_TOKEN;
- loc_params.loc_data.loc_by_token.token = obj_token;
+ loc_params.loc_data.loc_by_token.token = &obj_token;
loc_params.obj_type = H5I_get_type(loc_id);
/* Open object by token */
@@ -675,7 +675,7 @@ H5Ropen_attr(const H5R_ref_t *ref_ptr, hid_t rapl_id, hid_t aapl_id)
/* Set location parameters */
loc_params.type = H5VL_OBJECT_BY_TOKEN;
- loc_params.loc_data.loc_by_token.token = obj_token;
+ loc_params.loc_data.loc_by_token.token = &obj_token;
loc_params.obj_type = H5I_get_type(loc_id);
/* Open object by token */
@@ -765,7 +765,7 @@ H5Rget_obj_type3(const H5R_ref_t *ref_ptr, hid_t rapl_id, H5O_type_t *obj_type)
/* Set location parameters */
loc_params.type = H5VL_OBJECT_BY_TOKEN;
- loc_params.loc_data.loc_by_token.token = obj_token;
+ loc_params.loc_data.loc_by_token.token = &obj_token;
loc_params.obj_type = H5I_get_type(loc_id);
/* Retrieve object's type */
@@ -873,7 +873,7 @@ H5Rget_obj_name(const H5R_ref_t *ref_ptr, hid_t rapl_id, char *buf, size_t size)
/* Set location parameters */
loc_params.type = H5VL_OBJECT_BY_TOKEN;
- loc_params.loc_data.loc_by_token.token = obj_token;
+ loc_params.loc_data.loc_by_token.token = &obj_token;
loc_params.obj_type = H5I_get_type(loc_id);
/* Retrieve object's name */
diff --git a/src/H5Rdeprec.c b/src/H5Rdeprec.c
index 63be3f8..ad3c219 100644
--- a/src/H5Rdeprec.c
+++ b/src/H5Rdeprec.c
@@ -128,7 +128,7 @@ H5Rget_obj_type1(hid_t id, H5R_type_t ref_type, const void *ref)
/* Set location parameters */
loc_params.type = H5VL_OBJECT_BY_TOKEN;
- loc_params.loc_data.loc_by_token.token = obj_token;
+ loc_params.loc_data.loc_by_token.token = &obj_token;
loc_params.obj_type = vol_obj_type;
/* Retrieve object's type */
@@ -188,7 +188,7 @@ H5Rdereference1(hid_t obj_id, H5R_type_t ref_type, const void *ref)
/* Set location parameters */
loc_params.type = H5VL_OBJECT_BY_TOKEN;
- loc_params.loc_data.loc_by_token.token = obj_token;
+ loc_params.loc_data.loc_by_token.token = &obj_token;
loc_params.obj_type = vol_obj_type;
/* Dereference */
@@ -262,7 +262,7 @@ H5Rcreate(void *ref, hid_t loc_id, const char *name, H5R_type_t ref_type,
loc_params.obj_type = vol_obj_type;
/* Get the object token */
- if(H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_LOOKUP, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, obj_token) < 0)
+ if(H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_LOOKUP, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &obj_token) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to retrieve object token")
/* Get the file for the object */
@@ -357,7 +357,7 @@ H5Rget_obj_type2(hid_t id, H5R_type_t ref_type, const void *ref,
/* Set location parameters */
loc_params.type = H5VL_OBJECT_BY_TOKEN;
- loc_params.loc_data.loc_by_token.token = obj_token;
+ loc_params.loc_data.loc_by_token.token = &obj_token;
loc_params.obj_type = vol_obj_type;
/* Retrieve object's type */
@@ -421,7 +421,7 @@ H5Rdereference2(hid_t obj_id, hid_t oapl_id, H5R_type_t ref_type,
/* Set location parameters */
loc_params.type = H5VL_OBJECT_BY_TOKEN;
- loc_params.loc_data.loc_by_token.token = obj_token;
+ loc_params.loc_data.loc_by_token.token = &obj_token;
loc_params.obj_type = vol_obj_type;
/* Open object by token */
@@ -554,7 +554,7 @@ H5Rget_name(hid_t id, H5R_type_t ref_type, const void *ref, char *name,
/* Set location parameters */
loc_params.type = H5VL_OBJECT_BY_TOKEN;
- loc_params.loc_data.loc_by_token.token = obj_token;
+ loc_params.loc_data.loc_by_token.token = &obj_token;
loc_params.obj_type = vol_obj_type;
/* Retrieve object's name */
diff --git a/src/H5Rint.c b/src/H5Rint.c
index 558c095..9879865 100644
--- a/src/H5Rint.c
+++ b/src/H5Rint.c
@@ -258,7 +258,7 @@ H5R__create_object(const H5VL_token_t *obj_token, size_t token_size,
HDassert(ref);
/* Create new reference */
- H5MM_memcpy(ref->ref.obj.token, obj_token, token_size);
+ H5MM_memcpy(&ref->ref.obj.token, obj_token, token_size);
ref->ref.obj.filename = NULL;
ref->loc_id = H5I_INVALID_HID;
ref->type = (uint8_t)H5R_OBJECT2;
@@ -300,7 +300,7 @@ H5R__create_region(const H5VL_token_t *obj_token, size_t token_size,
HDassert(ref);
/* Create new reference */
- H5MM_memcpy(ref->ref.obj.token, obj_token, token_size);
+ H5MM_memcpy(&ref->ref.obj.token, obj_token, token_size);
ref->ref.obj.filename = NULL;
if(NULL == (ref->ref.reg.space = H5S_copy(space, FALSE, TRUE)))
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCOPY, FAIL, "unable to copy dataspace")
@@ -355,7 +355,7 @@ H5R__create_attr(const H5VL_token_t *obj_token, size_t token_size,
HGOTO_ERROR(H5E_REFERENCE, H5E_ARGS, FAIL, "attribute name too long (%d > %d)", (int)HDstrlen(attr_name), H5R_MAX_STRING_LEN)
/* Create new reference */
- H5MM_memcpy(ref->ref.obj.token, obj_token, token_size);
+ H5MM_memcpy(&ref->ref.obj.token, obj_token, token_size);
ref->ref.obj.filename = NULL;
if(NULL == (ref->ref.attr.name = HDstrdup(attr_name)))
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCOPY, FAIL, "Cannot copy attribute name")
@@ -602,7 +602,7 @@ H5R__equal(const H5R_ref_priv_t *ref1, const H5R_ref_priv_t *ref2)
/* Compare object addresses */
if(ref1->token_size != ref2->token_size)
HGOTO_DONE(FALSE);
- if(0 != HDmemcmp(ref1->ref.obj.token, ref2->ref.obj.token, ref1->token_size))
+ if(0 != HDmemcmp(&ref1->ref.obj.token, &ref2->ref.obj.token, ref1->token_size))
HGOTO_DONE(FALSE);
/* Compare filenames */
@@ -659,7 +659,7 @@ H5R__copy(const H5R_ref_priv_t *src_ref, H5R_ref_priv_t *dst_ref)
HDassert((src_ref != NULL) && (dst_ref != NULL));
- H5MM_memcpy(dst_ref->ref.obj.token, src_ref->ref.obj.token, src_ref->token_size);
+ H5MM_memcpy(&dst_ref->ref.obj.token, &src_ref->ref.obj.token, src_ref->token_size);
dst_ref->encode_size = src_ref->encode_size;
dst_ref->type = src_ref->type;
dst_ref->token_size = src_ref->token_size;
@@ -729,7 +729,7 @@ H5R__get_obj_token(const H5R_ref_priv_t *ref, H5VL_token_t *obj_token,
if(obj_token) {
if(0 == ref->token_size)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCOPY, FAIL, "NULL token size")
- H5MM_memcpy(obj_token, ref->ref.obj.token, ref->token_size);
+ H5MM_memcpy(obj_token, &ref->ref.obj.token, ref->token_size);
}
if(token_size)
*token_size = ref->token_size;
@@ -761,7 +761,7 @@ H5R__set_obj_token(H5R_ref_priv_t *ref, const H5VL_token_t *obj_token,
HDassert(token_size);
HDassert(token_size <= H5VL_MAX_TOKEN_SIZE);
- H5MM_memcpy(ref->ref.obj.token, obj_token, ref->token_size);
+ H5MM_memcpy(&ref->ref.obj.token, obj_token, ref->token_size);
ref->token_size = token_size;
FUNC_LEAVE_NOAPI(ret_value)
@@ -1702,13 +1702,13 @@ H5R__decode_token_region_compat(H5F_t *f, const unsigned char *buf,
/* Get object address */
p = (const uint8_t *)data;
- H5MM_memcpy(token, p, token_size);
+ H5MM_memcpy(&token, p, token_size);
p += token_size;
if(space_ptr) {
H5O_loc_t oloc; /* Object location */
H5S_t *space = NULL;
- const uint8_t *q = token;
+ const uint8_t *q = (const uint8_t *)&token;
/* Initialize the object location */
H5O_loc_reset(&oloc);
@@ -1726,7 +1726,7 @@ H5R__decode_token_region_compat(H5F_t *f, const unsigned char *buf,
*space_ptr = space;
}
if(obj_token)
- H5MM_memcpy(obj_token, token, token_size);
+ H5MM_memcpy(obj_token, &token, token_size);
done:
H5MM_free(data);
diff --git a/src/H5Rpublic.h b/src/H5Rpublic.h
index 585cb85..a13d54b 100644
--- a/src/H5Rpublic.h
+++ b/src/H5Rpublic.h
@@ -70,14 +70,18 @@ typedef haddr_t hobj_ref_t;
* machine (8 bytes currently) plus an int.
* Note! This type can only be used with the "native" HDF5 VOL connector.
*/
-typedef unsigned char hdset_reg_ref_t[H5R_DSET_REG_REF_BUF_SIZE];
+typedef struct {
+ char __data[H5R_DSET_REG_REF_BUF_SIZE];
+} hdset_reg_ref_t;
/**
* Opaque reference type. The same reference type is used for object,
* dataset region and attribute references. This is the type that
* should always be used with the current reference API.
*/
-typedef unsigned char H5R_ref_t[H5R_REF_BUF_SIZE];
+typedef struct {
+ char __data[H5R_REF_BUF_SIZE];
+} H5R_ref_t;
/********************/
/* Public Variables */
diff --git a/src/H5VLconnector.h b/src/H5VLconnector.h
index f0925bf..373eb44 100644
--- a/src/H5VLconnector.h
+++ b/src/H5VLconnector.h
@@ -52,7 +52,9 @@
/* type for tokens. Token are unique and permanent identifiers that are
* used to reference HDF5 objects. */
-typedef unsigned char H5VL_token_t[H5VL_MAX_TOKEN_SIZE];
+typedef struct {
+ char __data[H5VL_MAX_TOKEN_SIZE];
+} H5VL_token_t;
/* types for attribute GET callback */
typedef enum H5VL_attr_get_t {
@@ -213,7 +215,7 @@ typedef struct H5VL_loc_by_idx {
} H5VL_loc_by_idx_t;
typedef struct H5VL_loc_by_token {
- void *token;
+ H5VL_token_t *token;
} H5VL_loc_by_token_t;
/* Structure to hold parameters for object locations.
diff --git a/src/H5VLnative_object.c b/src/H5VLnative_object.c
index dfa4eab..6a22b05 100644
--- a/src/H5VLnative_object.c
+++ b/src/H5VLnative_object.c
@@ -287,7 +287,7 @@ H5VL__native_object_specific(void *obj, const H5VL_loc_params_t *loc_params, H5V
/* Lookup object */
case H5VL_OBJECT_LOOKUP:
{
- void *token = va_arg(arguments, void *);
+ H5VL_token_t *token = va_arg(arguments, H5VL_token_t *);
HDassert(token);