summaryrefslogtreecommitdiffstats
path: root/src/H5Rint.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5Rint.c')
-rw-r--r--src/H5Rint.c93
1 files changed, 62 insertions, 31 deletions
diff --git a/src/H5Rint.c b/src/H5Rint.c
index 2a21179..566c656 100644
--- a/src/H5Rint.c
+++ b/src/H5Rint.c
@@ -319,12 +319,12 @@ H5R__create_region(const H5VL_token_t *obj_token, size_t token_size,
ref->encode_size);
done:
- if(ret_value < 0) {
+ if(ret_value < 0)
if(ref->ref.reg.space) {
H5S_close(ref->ref.reg.space);
ref->ref.reg.space = NULL;
- }
- }
+ } /* end if */
+
FUNC_LEAVE_NOAPI(ret_value)
} /* H5R__create_region */
@@ -374,8 +374,11 @@ H5R__create_attr(const H5VL_token_t *obj_token, size_t token_size,
ref->ref.attr.name, ref->encode_size);
done:
- if(ret_value < 0)
- ref->ref.attr.name = H5MM_xfree(ref->ref.attr.name);
+ if(ret_value < 0) {
+ H5MM_xfree(ref->ref.attr.name);
+ ref->ref.attr.name = NULL;
+ } /* end if */
+
FUNC_LEAVE_NOAPI(ret_value)
} /* H5R__create_attr */
@@ -398,19 +401,24 @@ H5R__destroy(H5R_ref_priv_t *ref)
HDassert(ref != NULL);
- ref->ref.obj.filename = H5MM_xfree(ref->ref.obj.filename);
+ H5MM_xfree(ref->ref.obj.filename);
+ ref->ref.obj.filename = NULL;
switch(ref->type) {
case H5R_OBJECT2:
break;
+
case H5R_DATASET_REGION2:
if(H5S_close(ref->ref.reg.space) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTFREE, FAIL, "Cannot close dataspace")
ref->ref.reg.space = NULL;
break;
+
case H5R_ATTR:
- ref->ref.attr.name = H5MM_xfree(ref->ref.attr.name);
+ H5MM_xfree(ref->ref.attr.name);
+ ref->ref.attr.name = NULL;
break;
+
case H5R_OBJECT1:
case H5R_DATASET_REGION1:
break;
@@ -418,6 +426,7 @@ H5R__destroy(H5R_ref_priv_t *ref)
case H5R_MAXTYPE:
HDassert("invalid reference type" && 0);
HGOTO_ERROR(H5E_REFERENCE, H5E_UNSUPPORTED, FAIL, "internal error (invalid reference type)")
+
default:
HDassert("unknown reference type" && 0);
HGOTO_ERROR(H5E_REFERENCE, H5E_UNSUPPORTED, FAIL, "internal error (unknown reference type)")
@@ -501,11 +510,11 @@ H5R__get_loc_id(const H5R_ref_priv_t *ref)
hid_t
H5R__reopen_file(H5R_ref_priv_t *ref, hid_t fapl_id)
{
- void *new_file = NULL;
- H5VL_connector_prop_t connector_prop;
- unsigned flags = H5F_ACC_RDWR; /* Must open file read-write to allow for object modifications */
- H5P_genplist_t *plist;
- H5VL_object_t *vol_obj = NULL; /* VOL object for file */
+ H5P_genplist_t *plist; /* Property list for FAPL */
+ void *new_file = NULL; /* File object opened */
+ H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */
+ H5VL_object_t *vol_obj = NULL; /* VOL object for file */
+ hbool_t supported; /* Whether 'post open' operation is supported by VOL connector */
hid_t ret_value = H5I_INVALID_HID;
FUNC_ENTER_PACKAGE
@@ -529,7 +538,8 @@ H5R__reopen_file(H5R_ref_priv_t *ref, hid_t fapl_id)
HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set VOL connector info in API context")
/* Open the file */
- if(NULL == (new_file = H5VL_file_open(&connector_prop, H5R_REF_FILENAME(ref), flags, fapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)))
+ /* (Must open file read-write to allow for object modifications) */
+ if(NULL == (new_file = H5VL_file_open(&connector_prop, H5R_REF_FILENAME(ref), H5F_ACC_RDWR, fapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)))
HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, H5I_INVALID_HID, "unable to open file")
/* Get an ID for the file */
@@ -540,9 +550,13 @@ H5R__reopen_file(H5R_ref_priv_t *ref, hid_t fapl_id)
if(NULL == (vol_obj = H5VL_vol_object(ret_value)))
HGOTO_ERROR(H5E_FILE, H5E_CANTGET, H5I_INVALID_HID, "invalid object identifier")
- /* Make the post open callback */
- if(H5VL_file_specific(vol_obj, H5VL_FILE_POST_OPEN, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, H5I_INVALID_HID, "unable to make file post open callback")
+ /* Make the 'post open' callback */
+ supported = FALSE;
+ if(H5VL_introspect_opt_query(vol_obj, H5VL_SUBCLS_FILE, H5VL_NATIVE_FILE_POST_OPEN, &supported) < 0)
+ HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, H5I_INVALID_HID, "can't check for 'post open' operation")
+ if(supported)
+ if(H5VL_file_optional(vol_obj, H5VL_NATIVE_FILE_POST_OPEN, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0)
+ HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, H5I_INVALID_HID, "unable to make file 'post open' callback")
/* Attach loc_id to reference */
if(H5R__set_loc_id((H5R_ref_priv_t *)ref, ret_value, FALSE) < 0)
@@ -570,7 +584,7 @@ H5R__get_type(const H5R_ref_priv_t *ref)
FUNC_ENTER_PACKAGE_NOERR
HDassert(ref != NULL);
- ret_value = ref->type;
+ ret_value = (H5R_type_t)ref->type;
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5R__get_type() */
@@ -762,7 +776,7 @@ H5R__set_obj_token(H5R_ref_priv_t *ref, const H5VL_token_t *obj_token,
HDassert(token_size <= H5VL_MAX_TOKEN_SIZE);
H5MM_memcpy(&ref->ref.obj.token, obj_token, ref->token_size);
- ref->token_size = token_size;
+ ref->token_size = (uint8_t)token_size;
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5R__set_obj_token() */
@@ -922,7 +936,7 @@ H5R__encode(const char *filename, const H5R_ref_priv_t *ref, unsigned char *buf,
*p++ = (uint8_t)flags;
buf_size = *nalloc - H5R_ENCODE_HEADER_SIZE;
- }
+ } /* end if */
encode_size += H5R_ENCODE_HEADER_SIZE;
/* Encode object token */
@@ -937,31 +951,34 @@ H5R__encode(const char *filename, const H5R_ref_priv_t *ref, unsigned char *buf,
* - avoid duplicating VOL info on each reference
* - must query terminal VOL connector to avoid passthrough confusion
*/
- if(flags & H5R_IS_EXTERNAL) {
+ if(flags & H5R_IS_EXTERNAL)
/* Encode file name */
H5R_ENCODE(H5R__encode_string, filename, p, buf_size, encode_size,
"Cannot encode filename");
- }
switch(ref->type) {
case H5R_OBJECT2:
break;
+
case H5R_DATASET_REGION2:
/* Encode dataspace */
H5R_ENCODE(H5R__encode_region, ref->ref.reg.space, p, buf_size,
encode_size, "Cannot encode region");
break;
+
case H5R_ATTR:
/* Encode attribute name */
H5R_ENCODE(H5R__encode_string, ref->ref.attr.name, p, buf_size,
encode_size, "Cannot encode attribute name");
break;
+
case H5R_OBJECT1:
case H5R_DATASET_REGION1:
case H5R_BADTYPE:
case H5R_MAXTYPE:
HDassert("invalid reference type" && 0);
HGOTO_ERROR(H5E_REFERENCE, H5E_UNSUPPORTED, FAIL, "internal error (invalid reference type)")
+
default:
HDassert("unknown reference type" && 0);
HGOTO_ERROR(H5E_REFERENCE, H5E_UNSUPPORTED, FAIL, "internal error (unknown reference type)")
@@ -1053,7 +1070,7 @@ H5R__decode(const unsigned char *buf, size_t *nbytes, H5R_ref_priv_t *ref)
ref->loc_id = H5I_INVALID_HID;
/* Set encoding size */
- ref->encode_size = decode_size;
+ ref->encode_size = (uint32_t)decode_size;
H5R_LOG_DEBUG("Decoded reference, filename=%s, obj_addr=%s, encode size=%u",
ref->ref.obj.filename, H5R__print_token(ref->ref.obj.token),
@@ -1136,7 +1153,7 @@ H5R__decode_obj_token(const unsigned char *buf, size_t *nbytes,
/* Decode token */
H5MM_memcpy(obj_token, p, *token_size);
- *nbytes = *token_size + H5_SIZEOF_UINT8_T;
+ *nbytes = (size_t)*token_size + H5_SIZEOF_UINT8_T;
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -1184,7 +1201,7 @@ H5R__encode_region(H5S_t *space, unsigned char *buf, size_t *nalloc)
/* Serialize the selection */
if(H5S_SELECT_SERIALIZE(space, (unsigned char **)&p) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTENCODE, FAIL, "can't serialize selection")
- }
+ } /* end if */
*nalloc = (size_t)buf_size + 2 * H5_SIZEOF_UINT32_T;
done:
@@ -1322,7 +1339,7 @@ H5R__decode_string(const unsigned char *buf, size_t *nbytes, char **string_ptr)
HDassert(string_len <= H5R_MAX_STRING_LEN);
/* Allocate the string */
- if(NULL == (string = H5MM_malloc(string_len + 1)))
+ if(NULL == (string = (char *)H5MM_malloc(string_len + 1)))
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTALLOC, FAIL, "Cannot allocate string")
/* Copy the string */
@@ -1364,13 +1381,13 @@ H5R__encode_heap(H5F_t *f, unsigned char *buf, size_t *nalloc,
uint8_t *p = (uint8_t *)buf;
/* Write the reference information to disk (allocates space also) */
- if(H5HG_insert(f, data_size, (void *)data, &hobjid) < 0)
+ if(H5HG_insert(f, data_size, data, &hobjid) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_WRITEERROR, FAIL, "Unable to write reference information")
/* Encode the heap information */
H5F_addr_encode(f, &p, hobjid.addr);
UINT32ENCODE(p, hobjid.idx);
- }
+ } /* end if */
*nalloc = buf_size;
done:
@@ -1490,6 +1507,19 @@ H5R__decode_token_compat(H5VL_object_t *vol_obj, H5I_type_t type, H5R_type_t ref
FUNC_ENTER_PACKAGE
+#ifndef NDEBUG
+{
+ hbool_t is_native = FALSE; /* Whether the src file is using the native VOL connector */
+
+ /* Check if using native VOL connector */
+ if(H5VL_object_is_native(vol_obj, &is_native) < 0)
+ HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "can't query if file uses native VOL connector")
+
+ /* Must use native VOL connector for this operation */
+ HDassert(is_native);
+}
+#endif /* NDEBUG */
+
/* Get the file for the object */
if((file_id = H5F_get_file_id(vol_obj, type, FALSE)) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
@@ -1499,7 +1529,7 @@ H5R__decode_token_compat(H5VL_object_t *vol_obj, H5I_type_t type, H5R_type_t ref
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier")
/* Get container info */
- if(H5VL_file_get(vol_obj_file, H5VL_FILE_GET_CONT_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &cont_info) < 0)
+ if(H5VL_file_get((const H5VL_object_t *)vol_obj_file, H5VL_FILE_GET_CONT_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &cont_info) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to get container info")
if(ref_type == H5R_OBJECT1) {
@@ -1508,18 +1538,19 @@ H5R__decode_token_compat(H5VL_object_t *vol_obj, H5I_type_t type, H5R_type_t ref
/* Get object address */
if(H5R__decode_token_obj_compat(buf, &buf_size, obj_token, cont_info.token_size) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, FAIL, "unable to get object token")
- } else {
+ } /* end if */
+ else {
size_t buf_size = H5R_DSET_REG_REF_BUF_SIZE;
H5F_t *f = NULL;
/* Retrieve file from VOL object */
- if(NULL == (f = (H5F_t *)H5VL_object_data(vol_obj_file)))
+ if(NULL == (f = (H5F_t *)H5VL_object_data((const H5VL_object_t *)vol_obj_file)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid VOL object")
/* Get object address */
if(H5R__decode_token_region_compat(f, buf, &buf_size, obj_token, cont_info.token_size, NULL) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, FAIL, "unable to get object address")
- }
+ } /* end else */
done:
if(file_id != H5I_INVALID_HID && H5I_dec_ref(file_id) < 0)