summaryrefslogtreecommitdiffstats
path: root/src/H5Odtype.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5Odtype.c')
-rw-r--r--src/H5Odtype.c36
1 files changed, 25 insertions, 11 deletions
diff --git a/src/H5Odtype.c b/src/H5Odtype.c
index 0523e7c..805df2b 100644
--- a/src/H5Odtype.c
+++ b/src/H5Odtype.c
@@ -145,7 +145,7 @@ H5O_dtype_decode_helper(unsigned *ioflags/*in,out*/, const uint8_t **pp, H5T_t *
/* Version, class & flags */
UINT32DECODE(*pp, flags);
version = (flags>>4) & 0x0f;
- if(version < H5O_DTYPE_VERSION_1 || version > H5O_DTYPE_VERSION_3)
+ if(version < H5O_DTYPE_VERSION_1 || version > H5O_DTYPE_VERSION_LATEST)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTLOAD, FAIL, "bad version number for datatype message")
dt->shared->version = version;
dt->shared->type = (H5T_class_t)(flags & 0x0f);
@@ -438,16 +438,28 @@ H5O_dtype_decode_helper(unsigned *ioflags/*in,out*/, const uint8_t **pp, H5T_t *
/* Set reference type */
dt->shared->u.atomic.u.r.rtype = (H5R_type_t)(flags & 0x0f);
-
- /* Set extra information for object references, so the hobj_ref_t gets swizzled correctly */
- if(dt->shared->u.atomic.u.r.rtype == H5R_OBJECT) {
- /* Mark location this type as undefined for now. The caller function should
- * decide the location. */
- dt->shared->u.atomic.u.r.loc = H5T_LOC_BADLOC;
-
- /* This type needs conversion */
- dt->shared->force_conv = TRUE;
- } /* end if */
+ if(dt->shared->u.atomic.u.r.rtype <= H5R_BADTYPE
+ || dt->shared->u.atomic.u.r.rtype >= H5R_MAXTYPE)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, "invalid reference type");
+
+ /* Set generic flag */
+ if(dt->shared->u.atomic.u.r.rtype == H5R_OBJECT2
+ || dt->shared->u.atomic.u.r.rtype == H5R_DATASET_REGION2
+ || dt->shared->u.atomic.u.r.rtype == H5R_ATTR) {
+ dt->shared->u.atomic.u.r.opaque = TRUE;
+ dt->shared->u.atomic.u.r.version = (unsigned)((flags >> 4) & 0x0f);
+ if(dt->shared->u.atomic.u.r.version != H5R_ENCODE_VERSION)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, "reference version does not match");
+ } else
+ dt->shared->u.atomic.u.r.opaque = FALSE;
+
+ /* This type needs conversion */
+ dt->shared->force_conv = TRUE;
+
+ /* Mark location of this type as undefined for now. The caller
+ * function should decide the location. */
+ if(H5T_set_loc(dt, NULL, H5T_LOC_BADLOC) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid datatype location")
break;
case H5T_ENUM:
@@ -964,6 +976,8 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt)
case H5T_REFERENCE:
flags |= (dt->shared->u.atomic.u.r.rtype & 0x0f);
+ if(dt->shared->u.atomic.u.r.opaque)
+ flags = (unsigned)(flags | (((unsigned)dt->shared->u.atomic.u.r.version & 0x0f) << 4));
break;
case H5T_ENUM: