summaryrefslogtreecommitdiffstats
path: root/src/H5Ocopy_ref.c
diff options
context:
space:
mode:
authorJerome Soumagne <jsoumagne@hdfgroup.org>2019-10-11 06:19:42 (GMT)
committerJerome Soumagne <jsoumagne@hdfgroup.org>2019-10-11 22:40:40 (GMT)
commit294e4faab724c26985867fe8ede684967da8a698 (patch)
treee7456e1777fd52f0280f0cea36795b03e4ec23d3 /src/H5Ocopy_ref.c
parent1cac341502d8acb296f41db38d31b7eb8021ffdb (diff)
downloadhdf5-294e4faab724c26985867fe8ede684967da8a698.zip
hdf5-294e4faab724c26985867fe8ede684967da8a698.tar.gz
hdf5-294e4faab724c26985867fe8ede684967da8a698.tar.bz2
Fix encode and decode of tokens in H5VLnative
Fix encode and decode of deprecated object reference addresses Make H5Rdeprec.c use tokens instead of haddr_t Fix H5Oopen_by_addr() to serialize addr to token
Diffstat (limited to 'src/H5Ocopy_ref.c')
-rw-r--r--src/H5Ocopy_ref.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/H5Ocopy_ref.c b/src/H5Ocopy_ref.c
index e8212d6bb..3b18073 100644
--- a/src/H5Ocopy_ref.c
+++ b/src/H5Ocopy_ref.c
@@ -165,6 +165,7 @@ H5O__copy_expand_ref_object1(H5O_loc_t *src_oloc, const void *buf_src,
const unsigned char zeros[H5R_OBJ_REF_BUF_SIZE] = { 0 };
size_t buf_size = H5R_OBJ_REF_BUF_SIZE;
size_t i; /* Local index variable */
+ size_t token_size = H5F_SIZEOF_ADDR(src_oloc->file);
herr_t ret_value = SUCCEED;
FUNC_ENTER_STATIC
@@ -173,6 +174,8 @@ H5O__copy_expand_ref_object1(H5O_loc_t *src_oloc, const void *buf_src,
for(i = 0; i < ref_count; i++) {
const unsigned char *src_buf = (const unsigned char *)&src_ref[i];
unsigned char *dst_buf = (unsigned char *)&dst_ref[i];
+ H5VL_token_t tmp_token = { 0 };
+ uint8_t *p;
/* If data is not initialized, copy zeros and skip */
if(0 == HDmemcmp(src_buf, zeros, buf_size)) {
@@ -181,8 +184,10 @@ 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_addr_obj_compat(src_buf, &buf_size, &src_oloc->addr) < 0)
+ 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;
+ 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")
dst_oloc->addr = HADDR_UNDEF;
@@ -192,7 +197,9 @@ 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 */
- if(H5R__encode_addr_obj_compat(dst_oloc->addr, dst_buf, &buf_size) < 0)
+ p = 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")
} /* end for */
@@ -306,6 +313,7 @@ H5O__copy_expand_ref_object2(H5O_loc_t *src_oloc, hid_t tid_src, H5T_t *dt_src,
void *reclaim_buf = NULL; /* Buffer for reclaiming data */
H5S_t *buf_space = NULL; /* Dataspace describing buffer */
hsize_t buf_dim[1] = {ref_count}; /* Dimension for buffer */
+ size_t token_size = H5F_SIZEOF_ADDR(src_oloc->file);
herr_t ret_value = SUCCEED;
FUNC_ENTER_STATIC
@@ -358,18 +366,23 @@ H5O__copy_expand_ref_object2(H5O_loc_t *src_oloc, hid_t tid_src, H5T_t *dt_src,
for(i = 0; i < ref_count; i++) {
H5R_ref_t *ref_ptr = (H5R_ref_t *)conv_buf;
H5R_ref_priv_t *ref = (H5R_ref_priv_t *)&ref_ptr[i];
- size_t token_size = sizeof(src_oloc->addr);
+ H5VL_token_t tmp_token = { 0 };
+ uint8_t *p;
/* Get src object address */
- if(H5R__get_obj_token(ref, (H5VL_token_t *)&src_oloc->addr, &token_size) < 0)
+ 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;
+ H5F_addr_decode(src_oloc->file, (const uint8_t **)&p, &src_oloc->addr);
/* Attempt to copy object from source to destination file */
if(H5O__copy_obj_by_ref(src_oloc, dst_oloc, dst_root_loc, cpy_info) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy object")
/* Set dst object address */
- if(H5R__set_obj_token(ref, (const H5VL_token_t *)&dst_oloc->addr, token_size) < 0)
+ p = 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")
if(H5R__set_loc_id(ref, dst_loc_id, TRUE) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "unable to set destination loc id")