diff options
Diffstat (limited to 'hl/src/H5LT.c')
-rw-r--r-- | hl/src/H5LT.c | 305 |
1 files changed, 158 insertions, 147 deletions
diff --git a/hl/src/H5LT.c b/hl/src/H5LT.c index 0074d02..5d16d67 100644 --- a/hl/src/H5LT.c +++ b/hl/src/H5LT.c @@ -29,19 +29,19 @@ char *myinput; size_t indent = 0; -/* File Image operations - - A file image is a representation of an HDF5 file in a memory - buffer. In order to perform operations on an image in a similar way +/* File Image operations + + A file image is a representation of an HDF5 file in a memory + buffer. In order to perform operations on an image in a similar way to a file, the application buffer is copied to a FAPL buffer, which - in turn is copied to a VFD buffer. Buffer copying can decrease - performance, especially when using large file images. A solution to - this issue is to simulate the copying of the application buffer, - when actually the same buffer is used for the FAPL and the VFD. - This is implemented by using callbacks that simulate the standard - functions for memory management (additional callbacks are used for - the management of associated data structures). From the application - standpoint, a file handle can be obtained from a file image by using + in turn is copied to a VFD buffer. Buffer copying can decrease + performance, especially when using large file images. A solution to + this issue is to simulate the copying of the application buffer, + when actually the same buffer is used for the FAPL and the VFD. + This is implemented by using callbacks that simulate the standard + functions for memory management (additional callbacks are used for + the management of associated data structures). From the application + standpoint, a file handle can be obtained from a file image by using the API routine H5LTopen_file_image(). This function takes a flag argument that indicates the HDF5 library how to handle the given image; several flag values can be combined by using the bitwise OR operator. @@ -61,9 +61,9 @@ size_t indent = 0; well. The application is responsible to release the image buffer. */ -/* Data structure to pass application data to callbacks. */ +/* Data structure to pass application data to callbacks. */ typedef struct { - void *app_image_ptr; /* Pointer to application buffer */ + void *app_image_ptr; /* Pointer to application buffer */ size_t app_image_size; /* Size of application buffer */ void *fapl_image_ptr; /* Pointer to FAPL buffer */ size_t fapl_image_size; /* Size of FAPL buffer */ @@ -88,17 +88,17 @@ static herr_t udata_free(void *udata); /*------------------------------------------------------------------------- -* Function: image_malloc +* Function: image_malloc * * Purpose: Simulates malloc() function to avoid copying file images. * The application buffer is set to the buffer on only one FAPL. * Then the FAPL buffer can be copied to other FAPL buffers or -* to only one VFD buffer. +* to only one VFD buffer. * * Return: Address of "allocated" buffer, if successful. Otherwise, it returns * NULL. * -* Programmer: Christian Chilan +* Programmer: Christian Chilan * * Date: October 3, 2011 * @@ -109,23 +109,23 @@ image_malloc(size_t size, H5FD_file_image_op_t file_image_op, void *_udata) { H5LT_file_image_ud_t *udata = (H5LT_file_image_ud_t *)_udata; void * return_value = NULL; - + /* callback is only used if the application buffer is not actually copied */ - if (!(udata->flags & H5LT_FILE_IMAGE_DONT_COPY)) + if (!(udata->flags & H5LT_FILE_IMAGE_DONT_COPY)) goto out; switch ( file_image_op ) { /* the app buffer is "copied" to only one FAPL. Afterwards, FAPLs can be "copied" */ case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_SET: - if (udata->app_image_ptr == NULL) + if (udata->app_image_ptr == NULL) goto out; - if (udata->app_image_size != size) + if (udata->app_image_size != size) goto out; - if (udata->fapl_image_ptr != NULL) + if (udata->fapl_image_ptr != NULL) goto out; - if (udata->fapl_image_size != 0) + if (udata->fapl_image_size != 0) goto out; - if (udata->fapl_ref_count != 0) + if (udata->fapl_ref_count != 0) goto out; udata->fapl_image_ptr = udata->app_image_ptr; @@ -135,11 +135,11 @@ image_malloc(size_t size, H5FD_file_image_op_t file_image_op, void *_udata) break; case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_COPY: - if (udata->fapl_image_ptr == NULL) + if (udata->fapl_image_ptr == NULL) goto out; - if (udata->fapl_image_size != size) + if (udata->fapl_image_size != size) goto out; - if (udata->fapl_ref_count == 0) + if (udata->fapl_ref_count == 0) goto out; return_value = udata->fapl_image_ptr; @@ -151,17 +151,17 @@ image_malloc(size_t size, H5FD_file_image_op_t file_image_op, void *_udata) case H5FD_FILE_IMAGE_OP_FILE_OPEN: /* FAPL buffer is "copied" to only one VFD buffer */ - if (udata->vfd_image_ptr != NULL) + if (udata->vfd_image_ptr != NULL) goto out; - if (udata->vfd_image_size != 0) + if (udata->vfd_image_size != 0) goto out; - if (udata->vfd_ref_count != 0) + if (udata->vfd_ref_count != 0) goto out; - if (udata->fapl_image_ptr == NULL) + if (udata->fapl_image_ptr == NULL) goto out; - if (udata->fapl_image_size != size) + if (udata->fapl_image_size != size) goto out; - if (udata->fapl_ref_count == 0) + if (udata->fapl_ref_count == 0) goto out; udata->vfd_image_ptr = udata->fapl_image_ptr; @@ -189,15 +189,15 @@ out: /*------------------------------------------------------------------------- * Function: image_memcpy * -* Purpose: Simulates memcpy() function to avoid copying file images. +* Purpose: Simulates memcpy() function to avoid copying file images. * The image buffer can be set to only one FAPL buffer, and * "copied" to only one VFD buffer. The FAPL buffer can be -* "copied" to other FAPLs buffers. +* "copied" to other FAPLs buffers. * * Return: The address of the destination buffer, if successful. Otherwise, it * returns NULL. * -* Programmer: Christian Chilan +* Programmer: Christian Chilan * * Date: October 3, 2011 * @@ -210,31 +210,31 @@ image_memcpy(void *dest, const void *src, size_t size, H5FD_file_image_op_t file H5LT_file_image_ud_t *udata = (H5LT_file_image_ud_t *)_udata; /* callback is only used if the application buffer is not actually copied */ - if (!(udata->flags & H5LT_FILE_IMAGE_DONT_COPY)) + if (!(udata->flags & H5LT_FILE_IMAGE_DONT_COPY)) goto out; switch(file_image_op) { case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_SET: - if (dest != udata->fapl_image_ptr) + if (dest != udata->fapl_image_ptr) goto out; - if (src != udata->app_image_ptr) + if (src != udata->app_image_ptr) goto out; - if (size != udata->fapl_image_size) + if (size != udata->fapl_image_size) goto out; - if (size != udata->app_image_size) + if (size != udata->app_image_size) goto out; - if (udata->fapl_ref_count == 0) + if (udata->fapl_ref_count == 0) goto out; break; case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_COPY: - if (dest != udata->fapl_image_ptr) + if (dest != udata->fapl_image_ptr) goto out; - if (src != udata->fapl_image_ptr) + if (src != udata->fapl_image_ptr) goto out; - if (size != udata->fapl_image_size) + if (size != udata->fapl_image_size) goto out; - if (udata->fapl_ref_count < 2) + if (udata->fapl_ref_count < 2) goto out; break; @@ -242,17 +242,17 @@ image_memcpy(void *dest, const void *src, size_t size, H5FD_file_image_op_t file goto out; case H5FD_FILE_IMAGE_OP_FILE_OPEN: - if (dest != udata->vfd_image_ptr) + if (dest != udata->vfd_image_ptr) goto out; - if (src != udata->fapl_image_ptr) + if (src != udata->fapl_image_ptr) goto out; - if (size != udata->vfd_image_size) + if (size != udata->vfd_image_size) goto out; - if (size != udata->fapl_image_size) + if (size != udata->fapl_image_size) goto out; - if (udata->fapl_ref_count == 0) + if (udata->fapl_ref_count == 0) goto out; - if (udata->vfd_ref_count != 1) + if (udata->vfd_ref_count != 1) goto out; break; @@ -273,15 +273,15 @@ out: /*------------------------------------------------------------------------- -* Function: image_realloc +* Function: image_realloc * * Purpose: Reallocates the shared application image buffer and updates data -* structures that manage buffer "copying". -* +* structures that manage buffer "copying". +* * Return: Address of reallocated buffer, if successful. Otherwise, it returns -* NULL. +* NULL. * -* Programmer: Christian Chilan +* Programmer: Christian Chilan * * Date: October 3, 2011 * @@ -294,29 +294,29 @@ image_realloc(void *ptr, size_t size, H5FD_file_image_op_t file_image_op, void * void * return_value = NULL; /* callback is only used if the application buffer is not actually copied */ - if (!(udata->flags & H5LT_FILE_IMAGE_DONT_COPY)) + if (!(udata->flags & H5LT_FILE_IMAGE_DONT_COPY)) goto out; - /* realloc() is not allowed when the HDF5 library won't release the image + /* realloc() is not allowed when the HDF5 library won't release the image buffer because reallocation may change the address of the buffer. The new address cannot be communicated to the application to release it. */ - if (udata->flags & H5LT_FILE_IMAGE_DONT_RELEASE) - goto out; + if (udata->flags & H5LT_FILE_IMAGE_DONT_RELEASE) + goto out; /* realloc() is not allowed if the image is open in read-only mode */ - if (!(udata->flags & H5LT_FILE_IMAGE_OPEN_RW)) - goto out; + if (!(udata->flags & H5LT_FILE_IMAGE_OPEN_RW)) + goto out; if (file_image_op == H5FD_FILE_IMAGE_OP_FILE_RESIZE) { - if (udata->vfd_image_ptr != ptr) - goto out; + if (udata->vfd_image_ptr != ptr) + goto out; - if (udata->vfd_ref_count != 1) + if (udata->vfd_ref_count != 1) goto out; if (NULL == (udata->vfd_image_ptr = HDrealloc(ptr, size))) - goto out; - + goto out; + udata->vfd_image_size = size; return_value = udata->vfd_image_ptr; } /* end if */ @@ -337,9 +337,9 @@ out: * reference counters. Shared application buffer is actually * deallocated if there are no outstanding references. * -* Return: SUCCEED or FAIL +* Return: SUCCEED or FAIL * -* Programmer: Christian Chilan +* Programmer: Christian Chilan * * Date: October 3, 2011 * @@ -351,19 +351,19 @@ image_free(void *ptr, H5FD_file_image_op_t file_image_op, void *_udata) H5LT_file_image_ud_t *udata = (H5LT_file_image_ud_t *)_udata; /* callback is only used if the application buffer is not actually copied */ - if (!(udata->flags & H5LT_FILE_IMAGE_DONT_COPY)) + if (!(udata->flags & H5LT_FILE_IMAGE_DONT_COPY)) goto out; switch(file_image_op) { case H5FD_FILE_IMAGE_OP_PROPERTY_LIST_CLOSE: - if (udata->fapl_image_ptr != ptr) + if (udata->fapl_image_ptr != ptr) goto out; - if (udata->fapl_ref_count == 0) + if (udata->fapl_ref_count == 0) goto out; udata->fapl_ref_count--; - /* release the shared buffer only if indicated by the respective flag and there are no outstanding references */ + /* release the shared buffer only if indicated by the respective flag and there are no outstanding references */ if (udata->fapl_ref_count == 0 && udata->vfd_ref_count == 0 && !(udata->flags & H5LT_FILE_IMAGE_DONT_RELEASE)) { HDfree(udata->fapl_image_ptr); @@ -374,14 +374,14 @@ image_free(void *ptr, H5FD_file_image_op_t file_image_op, void *_udata) break; case H5FD_FILE_IMAGE_OP_FILE_CLOSE: - if (udata->vfd_image_ptr != ptr) + if (udata->vfd_image_ptr != ptr) goto out; - if (udata->vfd_ref_count != 1) + if (udata->vfd_ref_count != 1) goto out; udata->vfd_ref_count--; - /* release the shared buffer only if indicated by the respective flag and there are no outstanding references */ + /* release the shared buffer only if indicated by the respective flag and there are no outstanding references */ if (udata->fapl_ref_count == 0 && udata->vfd_ref_count == 0 && !(udata->flags & H5LT_FILE_IMAGE_DONT_RELEASE)) { HDfree(udata->vfd_image_ptr); @@ -410,7 +410,7 @@ out: /*------------------------------------------------------------------------- -* Function: udata_copy +* Function: udata_copy * * Purpose: Simulates the copying of the user data structure utilized in the * management of the "copying" of file images. @@ -418,7 +418,7 @@ out: * Return: Address of "newly allocated" structure, if successful. Otherwise, it * returns NULL. * -* Programmer: Christian Chilan +* Programmer: Christian Chilan * * Date: October 3, 2011 * @@ -430,9 +430,9 @@ udata_copy(void *_udata) H5LT_file_image_ud_t *udata = (H5LT_file_image_ud_t *)_udata; /* callback is only used if the application buffer is not actually copied */ - if (!(udata->flags & H5LT_FILE_IMAGE_DONT_COPY)) + if (!(udata->flags & H5LT_FILE_IMAGE_DONT_COPY)) goto out; - if (udata->ref_count == 0) + if (udata->ref_count == 0) goto out; udata->ref_count++; @@ -449,11 +449,11 @@ out: * * Purpose: Simulates deallocation of the user data structure utilized in the * management of the "copying" of file images. The data structure is -* actually deallocated when there are no outstanding references. +* actually deallocated when there are no outstanding references. * -* Return: SUCCEED or FAIL +* Return: SUCCEED or FAIL * -* Programmer: Christian Chilan +* Programmer: Christian Chilan * * Date: October 3, 2011 * @@ -465,9 +465,9 @@ udata_free(void *_udata) H5LT_file_image_ud_t *udata = (H5LT_file_image_ud_t *)_udata; /* callback is only used if the application buffer is not actually copied */ - if (!(udata->flags & H5LT_FILE_IMAGE_DONT_COPY)) + if (!(udata->flags & H5LT_FILE_IMAGE_DONT_COPY)) goto out; - if (udata->ref_count == 0) + if (udata->ref_count == 0) goto out; udata->ref_count--; @@ -479,7 +479,7 @@ udata_free(void *_udata) return(SUCCEED); -out: +out: return(FAIL); } /* end udata_free */ @@ -522,7 +522,7 @@ H5LT_make_dataset_numerical( hid_t loc_id, hid_t did = -1, sid = -1; /* check the arguments */ - if (dset_name == NULL) + if (dset_name == NULL) return -1; /* Create the data space for the dataset. */ @@ -801,7 +801,7 @@ herr_t H5LTmake_dataset_string(hid_t loc_id, size_t size; /* check the arguments */ - if (dset_name == NULL) + if (dset_name == NULL) return -1; /* create a string data type */ @@ -852,11 +852,11 @@ out: /*------------------------------------------------------------------------- * Function: H5LTopen_file_image * -* Purpose: Open a user supplied file image using the core file driver. +* Purpose: Open a user supplied file image using the core file driver. * * Return: File identifier, Failure: -1 * -* Programmer: Christian Chilan +* Programmer: Christian Chilan * * Date: October 3, 2011 * @@ -871,22 +871,22 @@ hid_t H5LTopen_file_image(void *buf_ptr, size_t buf_size, unsigned flags) size_t min_incr = 65536; /* Minimum buffer increment */ double buf_prcnt = 0.1f; /* Percentage of buffer size to set as increment */ - static long file_name_counter; - H5FD_file_image_callbacks_t callbacks = {&image_malloc, &image_memcpy, - &image_realloc, &image_free, - &udata_copy, &udata_free, + static long file_name_counter; + H5FD_file_image_callbacks_t callbacks = {&image_malloc, &image_memcpy, + &image_realloc, &image_free, + &udata_copy, &udata_free, (void *)NULL}; /* check arguments */ - if (buf_ptr == NULL) + if (buf_ptr == NULL) goto out; - if (buf_size == 0) + if (buf_size == 0) goto out; if (flags & (unsigned)~(H5LT_FILE_IMAGE_ALL)) goto out; /* Create FAPL to transmit file image */ - if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) goto out; /* set allocation increment to a percentage of the supplied buffer size, or @@ -898,7 +898,7 @@ hid_t H5LTopen_file_image(void *buf_ptr, size_t buf_size, unsigned flags) alloc_incr = min_incr; /* Configure FAPL to use the core file driver */ - if (H5Pset_fapl_core(fapl, alloc_incr, FALSE) < 0) + if (H5Pset_fapl_core(fapl, alloc_incr, FALSE) < 0) goto out; /* Set callbacks for file image ops ONLY if the file image is NOT copied */ @@ -932,10 +932,10 @@ hid_t H5LTopen_file_image(void *buf_ptr, size_t buf_size, unsigned flags) } /* end if */ /* Assign file image in user buffer to FAPL */ - if (H5Pset_file_image(fapl, buf_ptr, buf_size) < 0) + if (H5Pset_file_image(fapl, buf_ptr, buf_size) < 0) goto out; - /* set file open flags */ + /* set file open flags */ if (flags & H5LT_FILE_IMAGE_OPEN_RW) file_open_flags = H5F_ACC_RDWR; else @@ -943,17 +943,17 @@ hid_t H5LTopen_file_image(void *buf_ptr, size_t buf_size, unsigned flags) /* define a unique file name */ HDsnprintf(file_name, (sizeof(file_name) - 1), "file_image_%ld", file_name_counter++); - - /* Assign file image in FAPL to the core file driver */ - if ((file_id = H5Fopen(file_name, file_open_flags, fapl)) < 0) + + /* Assign file image in FAPL to the core file driver */ + if ((file_id = H5Fopen(file_name, file_open_flags, fapl)) < 0) goto out; /* Close FAPL */ - if (H5Pclose(fapl) < 0) + if (H5Pclose(fapl) < 0) goto out; - /* Return file identifier */ - return file_id; + /* Return file identifier */ + return file_id; out: H5E_BEGIN_TRY { @@ -983,7 +983,7 @@ H5LT_read_dataset_numerical(hid_t loc_id, const char *dset_name, hid_t tid, void hid_t did; /* check the arguments */ - if (dset_name == NULL) + if (dset_name == NULL) return -1; /* Open the dataset. */ @@ -1178,7 +1178,7 @@ herr_t H5LTread_dataset_string( hid_t loc_id, hid_t tid = -1; /* check the arguments */ - if (dset_name == NULL) + if (dset_name == NULL) return -1; /* Open the dataset. */ @@ -1231,7 +1231,7 @@ herr_t H5LTget_dataset_ndims( hid_t loc_id, hid_t sid = -1; /* check the arguments */ - if (dset_name == NULL) + if (dset_name == NULL) return -1; /* Open the dataset. */ @@ -1291,7 +1291,7 @@ herr_t H5LTget_dataset_info( hid_t loc_id, hid_t sid = -1; /* check the arguments */ - if (dset_name == NULL) + if (dset_name == NULL) return -1; /* open the dataset. */ @@ -1368,9 +1368,9 @@ find_dataset(hid_t loc_id, const char *name, const H5L_info_t *linfo, void *op_d int ret = 0; /* check the arguments */ - if (name == NULL) + if (name == NULL) return ret; - + /* Shut the compiler up */ loc_id = loc_id; linfo = linfo; @@ -1407,13 +1407,18 @@ find_dataset(hid_t loc_id, const char *name, const H5L_info_t *linfo, void *op_d * *------------------------------------------------------------------------- */ - +/* H5Literate wants a non-const pointer but we have a const pointer in the API + * call. It's safe to ignore this because we control the callback, don't + * modify the op_data buffer (i.e.: dset_name) during the traversal, and the + * library never modifies that buffer. + */ +H5_GCC_DIAG_OFF(cast-qual) herr_t H5LTfind_dataset( hid_t loc_id, const char *dset_name ) { return H5Literate(loc_id, H5_INDEX_NAME, H5_ITER_INC, 0, find_dataset, (void *)dset_name); } - +H5_GCC_DIAG_ON(cast-qual) /*------------------------------------------------------------------------- * @@ -1455,11 +1460,11 @@ herr_t H5LTset_attribute_string( hid_t loc_id, size_t attr_size; /* check the arguments */ - if (obj_name == NULL) + if (obj_name == NULL) return -1; - if (attr_name == NULL) + if (attr_name == NULL) return -1; - if (attr_data == NULL) + if (attr_data == NULL) return -1; /* Open the object */ @@ -1552,9 +1557,9 @@ herr_t H5LT_set_attribute_numerical( hid_t loc_id, int has_attr; /* check the arguments */ - if (obj_name == NULL) + if (obj_name == NULL) return -1; - if (attr_name == NULL) + if (attr_name == NULL) return -1; /* Open the object */ @@ -1969,7 +1974,7 @@ find_attr(hid_t loc_id, const char *name, const H5A_info_t *ainfo, int ret = H5_ITER_CONT; /* check the arguments */ - if (name == NULL) + if (name == NULL) return H5_ITER_CONT; /* Shut compiler up */ @@ -2033,13 +2038,18 @@ herr_t H5LTfind_attribute( hid_t loc_id, const char* attr_name ) * *------------------------------------------------------------------------- */ - +/* H5Aiterate wants a non-const pointer but we have a const pointer in the API + * call. It's safe to ignore this because we control the callback, don't + * modify the op_data buffer (i.e.: attr_name) during the traversal, and the + * library never modifies that buffer. + */ +H5_GCC_DIAG_OFF(cast-qual) herr_t H5LT_find_attribute( hid_t loc_id, const char* attr_name ) { return H5Aiterate2(loc_id, H5_INDEX_NAME, H5_ITER_INC, NULL, find_attr, (void *)attr_name); } - +H5_GCC_DIAG_ON(cast-qual) /*------------------------------------------------------------------------- @@ -2066,9 +2076,9 @@ herr_t H5LTget_attribute_ndims( hid_t loc_id, hid_t obj_id; /* check the arguments */ - if (obj_name == NULL) + if (obj_name == NULL) return -1; - if (attr_name == NULL) + if (attr_name == NULL) return -1; /* Open the object */ @@ -2139,9 +2149,9 @@ herr_t H5LTget_attribute_info( hid_t loc_id, hid_t obj_id; /* check the arguments */ - if (obj_name == NULL) + if (obj_name == NULL) return -1; - if (attr_name == NULL) + if (attr_name == NULL) return -1; /* Open the object */ @@ -2220,7 +2230,7 @@ hid_t H5LTtext_to_dtype(const char *text, H5LT_lang_t lang_type) hid_t type_id; /* check the arguments */ - if (text == NULL) + if (text == NULL) return -1; if(lang_type <= H5LT_LANG_ERR || lang_type >= H5LT_NO_LANG) @@ -2263,8 +2273,8 @@ out: * *------------------------------------------------------------------------- */ -static char* -realloc_and_append(hbool_t _no_user_buf, size_t *len, char *buf, char *str_to_add) +static char* +realloc_and_append(hbool_t _no_user_buf, size_t *len, char *buf, const char *str_to_add) { size_t size_str_to_add, size_str; @@ -2288,7 +2298,7 @@ realloc_and_append(hbool_t _no_user_buf, size_t *len, char *buf, char *str_to_ad /* find the size of the current buffer */ size_str = HDstrlen(buf); - /* Check to make sure the appended string does not + /* Check to make sure the appended string does not * extend past the allocated buffer; if it does then truncate the string */ if(size_str < *len - 1) { @@ -2360,7 +2370,6 @@ print_enum(hid_t type, char* str, size_t *str_len, hbool_t no_ubuf, size_t indt) { char **name = NULL; /*member names */ unsigned char *value = NULL; /*value array */ - unsigned char *copy = NULL; /*a pointer to value array */ int nmembs; /*number of members */ char tmp_str[TMP_LEN]; int nchars; /*number of output characters */ @@ -2418,17 +2427,15 @@ print_enum(hid_t type, char* str, size_t *str_len, hbool_t no_ubuf, size_t indt) nchars = HDsnprintf(tmp_str, TMP_LEN, "\"%s\"", name[i]); if(!(str = realloc_and_append(no_ubuf, str_len, str, tmp_str))) goto out; - HDsnprintf(tmp_str, TMP_LEN, "%*s ", MAX(0, 16 - nchars), ""); + HDmemset(tmp_str, ' ', (size_t)MAX(3, 19 - nchars) + 1); + tmp_str[MAX(3, 19 - nchars)] = '\0'; if(!(str = realloc_and_append(no_ubuf, str_len, str, tmp_str))) goto out; - /*On SGI Altix(cobalt), wrong values were printed out with "value+i*dst_size" - *strangely, unless use another pointer "copy".*/ - copy = value + (size_t)i * dst_size; if (H5T_SGN_NONE == H5Tget_sign(native)) - HDsnprintf(tmp_str, TMP_LEN, "%u", *((unsigned int*)((void *)copy))); + HDsnprintf(tmp_str, TMP_LEN, "%u", *((unsigned int *)((void *)(value + (size_t)i * dst_size)))); else - HDsnprintf(tmp_str, TMP_LEN, "%d", *((int*)((void *)copy))); + HDsnprintf(tmp_str, TMP_LEN, "%d", *((int *)((void *)(value + (size_t)i * dst_size)))); if(!(str = realloc_and_append(no_ubuf, str_len, str, tmp_str))) goto out; @@ -2450,8 +2457,12 @@ print_enum(hid_t type, char* str, size_t *str_len, hbool_t no_ubuf, size_t indt) out: if(0 == nmembs) { - HDsnprintf(tmp_str, TMP_LEN, "\n%*s <empty>", (int)(indt + 4), ""); + str = realloc_and_append(no_ubuf, str_len, str, "\n"); + HDassert((indt + 4) < TMP_LEN); + HDmemset(tmp_str, ' ', (indt + 4) + 1); + tmp_str[(indt + 4)] = '\0'; str = realloc_and_append(no_ubuf, str_len, str, tmp_str); + str = realloc_and_append(no_ubuf, str_len, str, " <empty>"); } /* end if */ /* Release resources */ @@ -2544,7 +2555,7 @@ char* H5LT_dtype_to_text(hid_t dtype, char *dt_str, H5LT_lang_t lang, size_t *sl if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, NULL))) goto out; - + if(lang != H5LT_DDL) { HDsnprintf(dt_str, *slen, "only DDL is supported for now"); goto out; @@ -3111,9 +3122,9 @@ herr_t H5LTget_attribute_string( hid_t loc_id, hid_t obj_id; /* check the arguments */ - if (obj_name == NULL) + if (obj_name == NULL) return -1; - if (attr_name == NULL) + if (attr_name == NULL) return -1; /* Open the object */ @@ -3121,9 +3132,9 @@ herr_t H5LTget_attribute_string( hid_t loc_id, return -1; /* Get the attribute */ - if ( H5LT_get_attribute_disk( obj_id, attr_name, data ) < 0 ) + if ( H5LT_get_attribute_disk( obj_id, attr_name, data ) < 0 ) { - H5Oclose(obj_id); + H5Oclose(obj_id); return -1; } @@ -3537,9 +3548,9 @@ static herr_t H5LT_get_attribute_mem(hid_t loc_id, hid_t attr_id = -1; /* check the arguments */ - if (obj_name == NULL) + if (obj_name == NULL) return -1; - if (attr_name == NULL) + if (attr_name == NULL) return -1; /* Open the object */ @@ -3779,7 +3790,7 @@ H5LTpath_valid(hid_t loc_id, const char *path, hbool_t check_object_valid) ret_value = FALSE; goto done; } - + /* Determine if link resolves to an actual object */ if((obj_exists = H5Oexists_by_name(loc_id, tmp_path, H5P_DEFAULT)) < 0) { ret_value = FAIL; |