diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2018-04-29 08:04:21 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2018-04-29 08:04:21 (GMT) |
commit | 01f196b31a03f072b685f998b0805c1f90322c2b (patch) | |
tree | 6e1cae004705ade1c870e4c6612a76b55be3c331 /src/H5Odtype.c | |
parent | da4b69097756158fdbfcbf52b5b552e2034d263d (diff) | |
parent | b3c5284692093953132c6c8227e0980b670bf4ad (diff) | |
download | hdf5-01f196b31a03f072b685f998b0805c1f90322c2b.zip hdf5-01f196b31a03f072b685f998b0805c1f90322c2b.tar.gz hdf5-01f196b31a03f072b685f998b0805c1f90322c2b.tar.bz2 |
Merge branch 'develop' of https://bitbucket.hdfgroup.org/scm/hdffv/hdf5 into merge_hyperslab_updates
Diffstat (limited to 'src/H5Odtype.c')
-rw-r--r-- | src/H5Odtype.c | 138 |
1 files changed, 70 insertions, 68 deletions
diff --git a/src/H5Odtype.c b/src/H5Odtype.c index 7ccf328..8060398 100644 --- a/src/H5Odtype.c +++ b/src/H5Odtype.c @@ -5,51 +5,48 @@ * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * - * the files COPYING and Copyright.html. COPYING can be found at the root * - * of the source code distribution tree; Copyright.html can be found at the * - * root level of an installed copy of the electronic HDF5 document set and * - * is linked from the top-level documents page. It can also be found at * - * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * - * access to either file, you may request a copy from help@hdfgroup.org. * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include "H5Omodule.h" /* This source code file is part of the H5O module */ #define H5T_FRIEND /*prevent warning from including H5Tpkg */ -#include "H5private.h" /* Generic Functions */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* Files */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Gprivate.h" /* Groups */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Opkg.h" /* Object headers */ -#include "H5Tpkg.h" /* Datatypes */ -#include "H5VMprivate.h" /* Vectors and arrays */ +#include "H5private.h" /* Generic Functions */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* Files */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Gprivate.h" /* Groups */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Opkg.h" /* Object headers */ +#include "H5Tpkg.h" /* Datatypes */ +#include "H5VMprivate.h" /* Vectors and arrays */ /* PRIVATE PROTOTYPES */ static herr_t H5O_dtype_encode(H5F_t *f, uint8_t *p, const void *mesg); -static void *H5O_dtype_decode(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, - unsigned mesg_flags, unsigned *ioflags, const uint8_t *p); +static void *H5O_dtype_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, + unsigned *ioflags, size_t p_size, const uint8_t *p); static void *H5O_dtype_copy(const void *_mesg, void *_dest); static size_t H5O_dtype_size(const H5F_t *f, const void *_mesg); -static herr_t H5O_dtype_reset(void *_mesg); +static herr_t H5O__dtype_reset(void *_mesg); static herr_t H5O__dtype_free(void *_mesg); static herr_t H5O_dtype_set_share(void *_mesg, const H5O_shared_t *sh); static htri_t H5O_dtype_can_share(const void *_mesg); static herr_t H5O_dtype_pre_copy_file(H5F_t *file_src, const void *mesg_src, hbool_t *deleted, const H5O_copy_t *cpy_info, void *_udata); -static void *H5O_dtype_copy_file(H5F_t *file_src, const H5O_msg_class_t *mesg_type, +static void *H5O__dtype_copy_file(H5F_t *file_src, const H5O_msg_class_t *mesg_type, void *native_src, H5F_t *file_dst, hbool_t *recompute_size, - H5O_copy_t *cpy_info, void *udata, hid_t dxpl_id); -static herr_t H5O_dtype_shared_post_copy_upd(const H5O_loc_t *src_oloc, - const void *mesg_src, H5O_loc_t *dst_oloc, void *mesg_dst, hid_t dxpl_id, + H5O_copy_t *cpy_info, void *udata); +static herr_t H5O__dtype_shared_post_copy_upd(const H5O_loc_t *src_oloc, + const void *mesg_src, H5O_loc_t *dst_oloc, void *mesg_dst, H5O_copy_t *cpy_info); - -static herr_t H5O_dtype_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, - FILE * stream, int indent, int fwidth); +static herr_t H5O__dtype_debug(H5F_t *f, const void *_mesg, FILE * stream, + int indent, int fwidth); /* Set up & include shared message "interface" info */ #define H5O_SHARED_TYPE H5O_MSG_DTYPE @@ -59,17 +56,17 @@ static herr_t H5O_dtype_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, #define H5O_SHARED_ENCODE_REAL H5O_dtype_encode #define H5O_SHARED_SIZE H5O_dtype_shared_size #define H5O_SHARED_SIZE_REAL H5O_dtype_size -#define H5O_SHARED_DELETE H5O_dtype_shared_delete +#define H5O_SHARED_DELETE H5O__dtype_shared_delete #undef H5O_SHARED_DELETE_REAL -#define H5O_SHARED_LINK H5O_dtype_shared_link +#define H5O_SHARED_LINK H5O__dtype_shared_link #undef H5O_SHARED_LINK_REAL -#define H5O_SHARED_COPY_FILE H5O_dtype_shared_copy_file -#define H5O_SHARED_COPY_FILE_REAL H5O_dtype_copy_file +#define H5O_SHARED_COPY_FILE H5O__dtype_shared_copy_file +#define H5O_SHARED_COPY_FILE_REAL H5O__dtype_copy_file #define H5O_SHARED_POST_COPY_FILE H5O_dtype_shared_post_copy_file #undef H5O_SHARED_POST_COPY_FILE_REAL -#define H5O_SHARED_POST_COPY_FILE_UPD H5O_dtype_shared_post_copy_upd +#define H5O_SHARED_POST_COPY_FILE_UPD H5O__dtype_shared_post_copy_upd #define H5O_SHARED_DEBUG H5O_dtype_shared_debug -#define H5O_SHARED_DEBUG_REAL H5O_dtype_debug +#define H5O_SHARED_DEBUG_REAL H5O__dtype_debug #include "H5Oshared.h" /* Shared Object Header Message Callbacks */ /* Macros to check for the proper version of a datatype */ @@ -101,14 +98,14 @@ const H5O_msg_class_t H5O_MSG_DTYPE[1] = {{ H5O_dtype_shared_encode, /* encode message */ H5O_dtype_copy, /* copy the native value */ H5O_dtype_shared_size, /* size of raw message */ - H5O_dtype_reset, /* reset method */ + H5O__dtype_reset, /* reset method */ H5O__dtype_free, /* free method */ - H5O_dtype_shared_delete, /* file delete method */ - H5O_dtype_shared_link, /* link method */ + H5O__dtype_shared_delete, /* file delete method */ + H5O__dtype_shared_link, /* link method */ H5O_dtype_set_share, /* set share method */ H5O_dtype_can_share, /* can share method */ H5O_dtype_pre_copy_file, /* pre copy native value to file */ - H5O_dtype_shared_copy_file, /* copy native value to file */ + H5O__dtype_shared_copy_file, /* copy native value to file */ H5O_dtype_shared_post_copy_file, /* post copy native value to file */ NULL, /* get creation index */ NULL, /* set creation index */ @@ -362,7 +359,7 @@ H5O_dtype_decode_helper(H5F_t *f, unsigned *ioflags/*in,out*/, const uint8_t **p } /* end if */ /* Close the base type for the array */ - H5T_close(temp_type); + (void)H5T_close_real(temp_type); /* Make the array type the type that is set for the field */ temp_type = array_dt; @@ -1082,9 +1079,8 @@ done: Decode a message and return a pointer to a memory struct with the decoded information USAGE - void *H5O_dtype_decode(f, dxpl_id, mesg_flags, p) + void *H5O_dtype_decode(f, mesg_flags, p) H5F_t *f; IN: pointer to the HDF5 file struct - hid_t dxpl_id; IN: DXPL for any I/O unsigned mesg_flags; IN: Message flags to influence decoding const uint8 *p; IN: the raw information buffer RETURNS @@ -1095,8 +1091,8 @@ done: function using malloc() and is returned to the caller. --------------------------------------------------------------------------*/ static void * -H5O_dtype_decode(H5F_t *f, hid_t H5_ATTR_UNUSED dxpl_id, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, - unsigned *ioflags/*in,out*/, const uint8_t *p) +H5O_dtype_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, + unsigned *ioflags/*in,out*/, size_t H5_ATTR_UNUSED p_size, const uint8_t *p) { H5T_t *dt = NULL; void *ret_value = NULL; /* Return value */ @@ -1346,7 +1342,7 @@ H5O_dtype_size(const H5F_t *f, const void *_mesg) /*------------------------------------------------------------------------- - * Function: H5O_dtype_reset + * Function: H5O__dtype_reset * * Purpose: Frees resources within a message, but doesn't free * the message itself. @@ -1356,22 +1352,20 @@ H5O_dtype_size(const H5F_t *f, const void *_mesg) * Programmer: Robb Matzke * Tuesday, December 9, 1997 * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t -H5O_dtype_reset(void *_mesg) +H5O__dtype_reset(void *_mesg) { H5T_t *dt = (H5T_t *) _mesg; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR if(dt) H5T__free(dt); FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5O_dtype_reset() */ +} /* end H5O__dtype_reset() */ /*------------------------------------------------------------------------- @@ -1397,7 +1391,7 @@ H5O__dtype_free(void *mesg) HDassert(mesg); /* Release the datatype */ - if(H5T_close((H5T_t *)mesg) < 0) + if(H5T_close_real((H5T_t *)mesg) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to free datatype") done: @@ -1518,7 +1512,7 @@ done: */ static herr_t H5O_dtype_pre_copy_file(H5F_t *file_src, const void *mesg_src, - hbool_t H5_ATTR_UNUSED *deleted, const H5O_copy_t H5_ATTR_UNUSED *cpy_info, + hbool_t H5_ATTR_UNUSED *deleted, const H5O_copy_t *cpy_info, void *_udata) { const H5T_t *dt_src = (const H5T_t *)mesg_src; /* Source datatype */ @@ -1530,6 +1524,13 @@ H5O_dtype_pre_copy_file(H5F_t *file_src, const void *mesg_src, /* check args */ HDassert(file_src); HDassert(dt_src); + HDassert(cpy_info); + HDassert(cpy_info->file_dst); + + /* Check to ensure that the version of the message to be copied does not exceed + the message version as indicated by the destination file's high bound */ + if(dt_src->shared->version > H5O_dtype_ver_bounds[H5F_HIGH_BOUND(cpy_info->file_dst)]) + HGOTO_ERROR(H5E_OHDR, H5E_BADRANGE, FAIL, "datatype message version out of bounds") /* If the user data is non-NULL, assume we are copying a dataset * and check if we need to make a copy of the datatype for later in @@ -1554,7 +1555,7 @@ done: /*------------------------------------------------------------------------- - * Function: H5O_dtype_copy_file + * Function: H5O__dtype_copy_file * * Purpose: Copy a native datatype message from one file to another. * @@ -1567,14 +1568,14 @@ done: *------------------------------------------------------------------------- */ static void * -H5O_dtype_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const H5O_msg_class_t *mesg_type, +H5O__dtype_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const H5O_msg_class_t *mesg_type, void *native_src, H5F_t *file_dst, hbool_t H5_ATTR_UNUSED *recompute_size, - H5O_copy_t H5_ATTR_UNUSED *cpy_info, void H5_ATTR_UNUSED *udata, hid_t H5_ATTR_UNUSED dxpl_id) + H5O_copy_t H5_ATTR_UNUSED *cpy_info, void H5_ATTR_UNUSED *udata) { H5T_t *dst_mesg; /* Destination datatype */ void *ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Perform a normal copy of the object header message */ if(NULL == (dst_mesg = (H5T_t *)H5O_dtype_copy(native_src, NULL))) @@ -1589,12 +1590,13 @@ H5O_dtype_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const H5O_msg_class_t *mesg_ done: if(NULL == ret_value) H5O_msg_free(mesg_type->id, dst_mesg); + FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_dtype_copy_file() */ +} /* end H5O__dtype_copy_file() */ /*------------------------------------------------------------------------- - * Function: H5O_dtype_shared_post_copy_upd + * Function: H5O__dtype_shared_post_copy_upd * * Purpose: Update a message after the shared message operations * during the post-copy loop @@ -1607,14 +1609,14 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5O_dtype_shared_post_copy_upd(const H5O_loc_t H5_ATTR_UNUSED *src_oloc, +H5O__dtype_shared_post_copy_upd(const H5O_loc_t H5_ATTR_UNUSED *src_oloc, const void H5_ATTR_UNUSED *mesg_src, H5O_loc_t H5_ATTR_UNUSED *dst_oloc, void *mesg_dst, - hid_t H5_ATTR_UNUSED dxpl_id, H5O_copy_t H5_ATTR_UNUSED *cpy_info) + H5O_copy_t H5_ATTR_UNUSED *cpy_info) { H5T_t *dt_dst = (H5T_t *)mesg_dst; /* Destination datatype */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC if(dt_dst->sh_loc.type == H5O_SHARE_TYPE_COMMITTED) { HDassert(H5T_committed(dt_dst)); @@ -1628,16 +1630,16 @@ H5O_dtype_shared_post_copy_upd(const H5O_loc_t H5_ATTR_UNUSED *src_oloc, done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_dtype_shared_post_copy_upd */ +} /* end H5O__dtype_shared_post_copy_upd */ /*-------------------------------------------------------------------------- NAME - H5O_dtype_debug + H5O__dtype_debug PURPOSE Prints debugging information for a message USAGE - void *H5O_dtype_debug(f, mesg, stream, indent, fwidth) + void *H5O__dtype_debug(f, mesg, stream, indent, fwidth) H5F_t *f; IN: pointer to the HDF5 file struct const void *mesg; IN: Pointer to the source simple datatype struct @@ -1651,8 +1653,8 @@ done: parameter. --------------------------------------------------------------------------*/ static herr_t -H5O_dtype_debug(H5F_t *f, hid_t dxpl_id, const void *mesg, FILE *stream, - int indent, int fwidth) +H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent, + int fwidth) { const H5T_t *dt = (const H5T_t*)mesg; const char *s; @@ -1660,7 +1662,7 @@ H5O_dtype_debug(H5F_t *f, hid_t dxpl_id, const void *mesg, FILE *stream, unsigned i; size_t k; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* check args */ HDassert(f); @@ -1744,13 +1746,13 @@ H5O_dtype_debug(H5F_t *f, hid_t dxpl_id, const void *mesg, FILE *stream, HDfprintf(stream, "%*s%-*s %lu\n", indent+3, "", MAX(0, fwidth-3), "Byte offset:", (unsigned long)(dt->shared->u.compnd.memb[i].offset)); - H5O_dtype_debug(f, dxpl_id, dt->shared->u.compnd.memb[i].type, stream, + H5O__dtype_debug(f, dt->shared->u.compnd.memb[i].type, stream, indent + 3, MAX(0, fwidth - 3)); } /* end for */ } /* end if */ else if(H5T_ENUM == dt->shared->type) { HDfprintf(stream, "%*s%s\n", indent, "", "Base type:"); - H5O_dtype_debug(f, dxpl_id, dt->shared->parent, stream, indent+3, MAX(0, fwidth-3)); + H5O__dtype_debug(f, dt->shared->parent, stream, indent+3, MAX(0, fwidth-3)); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Number of members:", dt->shared->u.enumer.nmembs); @@ -1980,7 +1982,7 @@ H5O_dtype_debug(H5F_t *f, hid_t dxpl_id, const void *mesg, FILE *stream, HDfprintf(stream, "%s%u", (i ? ", " : ""), (unsigned)dt->shared->u.array.dim[i]); HDfprintf(stream, "}\n"); HDfprintf(stream, "%*s%s\n", indent, "", "Base type:"); - H5O_dtype_debug(f, dxpl_id, dt->shared->parent, stream, indent + 3, MAX(0, fwidth - 3)); + H5O__dtype_debug(f, dt->shared->parent, stream, indent + 3, MAX(0, fwidth - 3)); } /* end else if */ else { switch (dt->shared->u.atomic.order) { @@ -2164,5 +2166,5 @@ H5O_dtype_debug(H5F_t *f, hid_t dxpl_id, const void *mesg, FILE *stream, } /* end else */ FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5O_dtype_debug() */ +} /* end H5O__dtype_debug() */ |