diff --git a/java/src/jni/h5aImp.c b/java/src/jni/h5aImp.c index 132e0709f5d..54c862eff6c 100644 --- a/java/src/jni/h5aImp.c +++ b/java/src/jni/h5aImp.c @@ -1107,12 +1107,12 @@ Java_hdf_hdf5lib_H5_H5Awrite_1string(JNIEnv *env, jclass clss, jlong attr_id, jl JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5AreadVL(JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jobjectArray buf) { - jbyte *readBuf = NULL; + void *readBuf = NULL; hsize_t dims[H5S_MAX_RANK]; hid_t sid = H5I_INVALID_HID; size_t typeSize; H5T_class_t type_class; - jsize vl_array_len; + jsize vl_array_len = 0; htri_t vl_data_class; herr_t status = FAIL; htri_t is_variable = 0; @@ -1136,7 +1136,7 @@ Java_hdf_hdf5lib_H5_H5AreadVL(JNIEnv *env, jclass clss, jlong attr_id, jlong mem if (NULL == (readBuf = calloc((size_t)vl_array_len, typeSize))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Aread: failed to allocate raw VL read buffer"); - if ((status = H5Aread((hid_t)attr_id, (hid_t)mem_type_id, (void *)readBuf)) < 0) + if ((status = H5Aread((hid_t)attr_id, (hid_t)mem_type_id, readBuf)) < 0) H5_LIBRARY_ERROR(ENVONLY); if ((type_class = H5Tget_class((hid_t)mem_type_id)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -1173,12 +1173,12 @@ Java_hdf_hdf5lib_H5_H5AreadVL(JNIEnv *env, jclass clss, jlong attr_id, jlong mem JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5AwriteVL(JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jobjectArray buf) { - jbyte *writeBuf = NULL; + void *writeBuf = NULL; hsize_t dims[H5S_MAX_RANK]; hid_t sid = H5I_INVALID_HID; size_t typeSize; H5T_class_t type_class; - jsize vl_array_len; + jsize vl_array_len = 0; htri_t vl_data_class; herr_t status = FAIL; htri_t is_variable = 0; diff --git a/java/src/jni/h5dImp.c b/java/src/jni/h5dImp.c index c7e91dc8603..f6318b222d4 100644 --- a/java/src/jni/h5dImp.c +++ b/java/src/jni/h5dImp.c @@ -185,7 +185,7 @@ Java_hdf_hdf5lib_H5_H5Dread(JNIEnv *env, jclass clss, jlong dataset_id, jlong me jbyte *readBuf = NULL; size_t typeSize; H5T_class_t type_class; - jsize vl_array_len; // Only used by vl_data_class types + jsize vl_array_len = 0; // Only used by vl_data_class types htri_t vl_data_class; herr_t status = FAIL; @@ -266,7 +266,7 @@ Java_hdf_hdf5lib_H5_H5Dwrite(JNIEnv *env, jclass clss, jlong dataset_id, jlong m jbyte *writeBuf = NULL; size_t typeSize; H5T_class_t type_class; - jsize vl_array_len; // Only used by vl_data_class types + jsize vl_array_len = 0; // Only used by vl_data_class types htri_t vl_data_class; herr_t status = FAIL; @@ -1134,7 +1134,7 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5DreadVL(JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id, jlong file_space_id, jlong xfer_plist_id, jobjectArray buf) { - jbyte *readBuf = NULL; + void *readBuf = NULL; size_t typeSize; H5T_class_t type_class; jsize vl_array_len; @@ -1164,7 +1164,7 @@ Java_hdf_hdf5lib_H5_H5DreadVL(JNIEnv *env, jclass clss, jlong dataset_id, jlong H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5DreadVL: failed to allocate raw VL read buffer"); if ((status = H5Dread((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, (hid_t)file_space_id, - (hid_t)xfer_plist_id, (void *)readBuf)) < 0) + (hid_t)xfer_plist_id, readBuf)) < 0) H5_LIBRARY_ERROR(ENVONLY); if ((type_class = H5Tget_class((hid_t)mem_type_id)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -1194,7 +1194,7 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5DwriteVL(JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id, jlong file_space_id, jlong xfer_plist_id, jobjectArray buf) { - jbyte *writeBuf = NULL; + void *writeBuf = NULL; size_t typeSize; H5T_class_t type_class; jsize vl_array_len; // Only used by vl_data_class types diff --git a/java/src/jni/h5eImp.c b/java/src/jni/h5eImp.c index 82d7da5980e..d52a4f72cd0 100644 --- a/java/src/jni/h5eImp.c +++ b/java/src/jni/h5eImp.c @@ -455,7 +455,7 @@ Java_hdf_hdf5lib_H5_H5Eget_1msg(JNIEnv *env, jclass clss, jlong msg_id, jintArra H5_LIBRARY_ERROR(ENVONLY); namePtr[buf_size] = '\0'; - theArray[0] = error_msg_type; + theArray[0] = (jint)error_msg_type; if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, namePtr))) CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); diff --git a/java/src/jni/h5pDCPLImp.c b/java/src/jni/h5pDCPLImp.c index 133b69c40cd..bd44f447bd1 100644 --- a/java/src/jni/h5pDCPLImp.c +++ b/java/src/jni/h5pDCPLImp.c @@ -77,13 +77,11 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pset_1chunk(JNIEnv *env, jclass clss, jlong plist, jint ndims, jbyteArray dim) { jboolean isCopy; - hsize_t *da = NULL; - hsize_t *lp = NULL; - size_t i; + hsize_t *chunk_dims = NULL; + uint8_t *theArray_p = NULL; size_t rank; jsize arrLen; jbyte *theArray = NULL; - jlong *jlp = NULL; herr_t status = FAIL; UNUSED(clss); @@ -104,22 +102,29 @@ Java_hdf_hdf5lib_H5_H5Pset_1chunk(JNIEnv *env, jclass clss, jlong plist, jint nd PIN_BYTE_ARRAY(ENVONLY, dim, theArray, &isCopy, "H5Pset_chunk: dim array not pinned"); - if (NULL == (da = lp = (hsize_t *)malloc(rank * sizeof(hsize_t)))) + if (NULL == (chunk_dims = malloc(rank * sizeof(hsize_t)))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Pset_chunk: memory allocation failed"); - jlp = (jlong *)theArray; - for (i = 0; i < rank; i++) { - *lp = (hsize_t)*jlp; - lp++; - jlp++; - } /* end if */ + theArray_p = (uint8_t *)theArray; + for (size_t i = 0; i < rank; i++) { + jlong dim_val; - if ((status = H5Pset_chunk((hid_t)plist, (int)ndims, da)) < 0) + memcpy(&dim_val, theArray_p, sizeof(jlong)); + + if (dim_val < 0) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pset_chunk: chunk dimensions can't be negative"); + + chunk_dims[i] = (hsize_t)dim_val; + + theArray_p += sizeof(jlong); + } + + if ((status = H5Pset_chunk((hid_t)plist, (int)ndims, chunk_dims)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: - if (da) - free(da); + free(chunk_dims); + if (theArray) UNPIN_BYTE_ARRAY(ENVONLY, dim, theArray, JNI_ABORT); diff --git a/java/src/jni/h5pFAPLImp.c b/java/src/jni/h5pFAPLImp.c index e67b167020b..af56336fb55 100644 --- a/java/src/jni/h5pFAPLImp.c +++ b/java/src/jni/h5pFAPLImp.c @@ -1741,15 +1741,15 @@ Java_hdf_hdf5lib_H5_H5Pget_1mdc_1config(JNIEnv *env, jclass clss, jlong plist) args[9].j = (jlong)cacheinfo.max_size; args[10].j = (jlong)cacheinfo.min_size; args[11].j = cacheinfo.epoch_length; - args[12].i = cacheinfo.incr_mode; + args[12].i = (jint)cacheinfo.incr_mode; args[13].d = cacheinfo.lower_hr_threshold; args[14].d = cacheinfo.increment; args[15].z = cacheinfo.apply_max_increment; args[16].j = (jlong)cacheinfo.max_increment; - args[17].i = cacheinfo.flash_incr_mode; + args[17].i = (jint)cacheinfo.flash_incr_mode; args[18].d = cacheinfo.flash_multiple; args[19].d = cacheinfo.flash_threshold; - args[20].i = cacheinfo.decr_mode; + args[20].i = (jint)cacheinfo.decr_mode; args[21].d = cacheinfo.upper_hr_threshold; args[22].d = cacheinfo.decrement; args[23].z = cacheinfo.apply_max_decrement; diff --git a/java/src/jni/h5rImp.c b/java/src/jni/h5rImp.c index 3c356a4484c..f97f803f90e 100644 --- a/java/src/jni/h5rImp.c +++ b/java/src/jni/h5rImp.c @@ -204,6 +204,12 @@ Java_hdf_hdf5lib_H5_H5Rdestroy(JNIEnv *env, jclass clss, jbyteArray ref) if ((status = H5Rdestroy(&loc_ref)) < 0) H5_LIBRARY_ERROR(ENVONLY); + /* Reset buffer to 0 to be safe. H5Rdestroy does this, but + * only on our temporary reference object that we copied + * into for alignment reasons. + */ + memset(refBuf, 0, H5R_REF_BUF_SIZE); + done: if (refBuf) UNPIN_BYTE_ARRAY(ENVONLY, ref, refBuf, (status < 0) ? JNI_ABORT : 0); diff --git a/java/src/jni/h5sImp.c b/java/src/jni/h5sImp.c index d9d7c78a383..55fb268434f 100644 --- a/java/src/jni/h5sImp.c +++ b/java/src/jni/h5sImp.c @@ -221,13 +221,11 @@ Java_hdf_hdf5lib_H5_H5Sselect_1elements(JNIEnv *env, jclass clss, jlong space_id jbyteArray coords) { jboolean isCopy; - hsize_t *lp = NULL; - hsize_t *llp = NULL; - jlong *jlp = NULL; - jbyte *P = NULL; + hsize_t *coords_p = NULL; + uint8_t *pinned_arr_p = NULL; + jbyte *pinned_arr = NULL; jsize size; - int ii; - int nlongs; + size_t nlongs; herr_t status = FAIL; UNUSED(clss); @@ -235,35 +233,40 @@ Java_hdf_hdf5lib_H5_H5Sselect_1elements(JNIEnv *env, jclass clss, jlong space_id if (NULL == coords) H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Sselect_elements: coords is NULL"); - PIN_BYTE_ARRAY(ENVONLY, coords, P, &isCopy, "H5Sselect_elements: coords not pinned"); + PIN_BYTE_ARRAY(ENVONLY, coords, pinned_arr, &isCopy, "H5Sselect_elements: coords not pinned"); if ((size = ENVPTR->GetArrayLength(ENVONLY, coords)) < 0) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Sselect_elements: coords array length < 0"); } - nlongs = (int)((size_t)size / sizeof(jlong)); + nlongs = (size_t)size / sizeof(jlong); - if (NULL == (lp = (hsize_t *)malloc((size_t)nlongs * sizeof(hsize_t)))) + if (NULL == (coords_p = malloc(nlongs * sizeof(hsize_t)))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Sselect_elements: failed to allocate coordinate buffer"); - jlp = (jlong *)P; - llp = lp; - for (ii = 0; ii < nlongs; ii++) { - *lp = (hsize_t)*jlp; - lp++; - jlp++; - } /* end for */ + pinned_arr_p = (uint8_t *)pinned_arr; + for (size_t i = 0; i < nlongs; i++) { + jlong coord_elem; + + memcpy(&coord_elem, pinned_arr_p, sizeof(jlong)); + + if (coord_elem < 0) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Sselect_elements: coordinate element can't be negative"); - if ((status = H5Sselect_elements(space_id, (H5S_seloper_t)op, (size_t)num_elemn, (const hsize_t *)llp)) < - 0) + coords_p[i] = (hsize_t)coord_elem; + + pinned_arr_p += sizeof(jlong); + } + + if ((status = H5Sselect_elements(space_id, (H5S_seloper_t)op, (size_t)num_elemn, coords_p)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: - if (llp) - free(llp); - if (P) - UNPIN_BYTE_ARRAY(ENVONLY, coords, P, JNI_ABORT); + free(coords_p); + + if (pinned_arr) + UNPIN_BYTE_ARRAY(ENVONLY, coords, pinned_arr, JNI_ABORT); return (jint)status; } /* end Java_hdf_hdf5lib_H5_H5Sselect_1elements */ @@ -630,49 +633,49 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Soffset_1simple(JNIEnv *env, jclass clss, jlong space_id, jbyteArray offset) { jboolean isCopy; - hssize_t *sa = NULL; - hssize_t *lp = NULL; + hssize_t *offset_dims = NULL; + uint8_t *pinned_arr_p = NULL; + jbyte *pinned_arr = NULL; size_t rank; - jsize i; - jbyte *P = NULL; - jlong *jlp = NULL; herr_t status = FAIL; UNUSED(clss); if (NULL != offset) { - PIN_BYTE_ARRAY(ENVONLY, offset, P, &isCopy, "H5Soffset_simple: offset not pinned"); + jsize size; + + PIN_BYTE_ARRAY(ENVONLY, offset, pinned_arr, &isCopy, "H5Soffset_simple: offset not pinned"); - if ((i = ENVPTR->GetArrayLength(ENVONLY, offset)) < 0) { + if ((size = ENVPTR->GetArrayLength(ENVONLY, offset)) < 0) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Soffset_simple: offset array length < 0"); } - rank = (size_t)i / sizeof(jlong); + rank = (size_t)size / sizeof(jlong); - if (NULL == (sa = lp = (hssize_t *)malloc((size_t)rank * sizeof(hssize_t)))) + if (NULL == (offset_dims = malloc((size_t)rank * sizeof(hssize_t)))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "H5Soffset_simple: failed to allocate offset buffer"); - jlp = (jlong *)P; - for (i = 0; (size_t)i < rank; i++) { - *lp = (hssize_t)*jlp; - lp++; - jlp++; - } /* end for */ - } - else { - P = NULL; - sa = (hssize_t *)P; + pinned_arr_p = (uint8_t *)pinned_arr; + for (size_t i = 0; i < rank; i++) { + jlong offset_elem; + + memcpy(&offset_elem, pinned_arr_p, sizeof(jlong)); + + offset_dims[i] = (hssize_t)offset_elem; + + pinned_arr_p += sizeof(jlong); + } } - if ((status = H5Soffset_simple(space_id, sa)) < 0) + if ((status = H5Soffset_simple(space_id, offset_dims)) < 0) H5_LIBRARY_ERROR(ENVONLY); done: - if (sa) - free(sa); - if (P) - UNPIN_BYTE_ARRAY(ENVONLY, offset, P, JNI_ABORT); + free(offset_dims); + + if (pinned_arr) + UNPIN_BYTE_ARRAY(ENVONLY, offset, pinned_arr, JNI_ABORT); return (jint)status; } /* end Java_hdf_hdf5lib_H5_H5Soffset_1simple */ diff --git a/java/src/jni/h5tImp.c b/java/src/jni/h5tImp.c index 155bd3a9a08..309454b16e4 100644 --- a/java/src/jni/h5tImp.c +++ b/java/src/jni/h5tImp.c @@ -447,8 +447,13 @@ Java_hdf_hdf5lib_H5_H5Tget_1fields_1int(JNIEnv *env, jclass clss, jlong type_id, { jboolean isCopy; jsize arrLen; - jint *P = NULL; - herr_t status = FAIL; + size_t spos; + size_t epos; + size_t esize; + size_t mpos; + size_t msize; + jint *pinned_arr = NULL; + herr_t status = FAIL; UNUSED(clss); @@ -462,15 +467,20 @@ Java_hdf_hdf5lib_H5_H5Tget_1fields_1int(JNIEnv *env, jclass clss, jlong type_id, if (arrLen < 5) H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Tget_fields_int: fields input array < order 5"); - PIN_INT_ARRAY(ENVONLY, fields, P, &isCopy, "H5Tget_fields_int: fields not pinned"); + PIN_INT_ARRAY(ENVONLY, fields, pinned_arr, &isCopy, "H5Tget_fields_int: fields not pinned"); - if ((status = H5Tget_fields((hid_t)type_id, (size_t *)&(P[0]), (size_t *)&(P[1]), (size_t *)&(P[2]), - (size_t *)&(P[3]), (size_t *)&(P[4]))) < 0) + if ((status = H5Tget_fields((hid_t)type_id, &spos, &epos, &esize, &mpos, &msize)) < 0) H5_LIBRARY_ERROR(ENVONLY); + pinned_arr[0] = (jint)spos; + pinned_arr[1] = (jint)epos; + pinned_arr[2] = (jint)esize; + pinned_arr[3] = (jint)mpos; + pinned_arr[4] = (jint)msize; + done: - if (P) - UNPIN_INT_ARRAY(ENVONLY, fields, P, (status < 0) ? JNI_ABORT : 0); + if (pinned_arr) + UNPIN_INT_ARRAY(ENVONLY, fields, pinned_arr, (status < 0) ? JNI_ABORT : 0); return (jint)status; } /* end Java_hdf_hdf5lib_H5_H5Tget_1fields_1int */ diff --git a/java/src/jni/h5util.c b/java/src/jni/h5util.c index 10efb828c54..9c441729a39 100644 --- a/java/src/jni/h5util.c +++ b/java/src/jni/h5util.c @@ -82,10 +82,10 @@ void translate_atomic_wbuf(JNIEnv *env, jobject in_obj, jlong mem_type_ void *raw_buf); /* Strings for output */ -#define H5_TOOLS_GROUP "GROUP" -#define H5_TOOLS_DATASET "DATASET" -#define H5_TOOLS_DATATYPE "DATATYPE" -#define H5_TOOLS_ATTRIBUTE "ATTRIBUTE" +#define H5_TOOLS_GROUP "GROUP" +#define H5_TOOLS_DATASET "DATASET" +#define H5_TOOLS_DATATYPE "DATATYPE" +#define H5_TOOLS_MAP "MAP" /** frees memory held by array of strings */ void @@ -241,7 +241,7 @@ h5str_convert(JNIEnv *env, char **in_str, hid_t container, hid_t tid, void *out_ } #if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE case sizeof(long double): { - long double tmp_ldouble = 0.0; + long double tmp_ldouble = 0.0L; sscanf(token, "%Lg", &tmp_ldouble); memcpy(cptr, &tmp_ldouble, sizeof(long double)); @@ -892,7 +892,7 @@ h5str_sprintf(JNIEnv *env, h5str_t *out_str, hid_t container, hid_t tid, void *i } #if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE case sizeof(long double): { - long double tmp_ldouble = 0.0; + long double tmp_ldouble = 0.0L; memcpy(&tmp_ldouble, cptr, sizeof(long double)); @@ -1221,6 +1221,11 @@ h5str_sprintf(JNIEnv *env, h5str_t *out_str, hid_t container, hid_t tid, void *i H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: snprintf failure"); break; + case H5O_TYPE_MAP: + if (snprintf(this_str, size, "%s %s", H5_TOOLS_MAP, obj_tok_str) < 0) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: snprintf failure"); + break; + case H5O_TYPE_UNKNOWN: case H5O_TYPE_NTYPES: default: @@ -1303,6 +1308,12 @@ h5str_sprintf(JNIEnv *env, h5str_t *out_str, hid_t container, hid_t tid, void *i "h5str_sprintf: snprintf failure"); break; + case H5O_TYPE_MAP: + if (snprintf(this_str, this_len, "%s ", H5_TOOLS_MAP) < 0) + H5_JNI_FATAL_ERROR(ENVONLY, + "h5str_sprintf: snprintf failure"); + break; + case H5O_TYPE_UNKNOWN: case H5O_TYPE_NTYPES: default: @@ -4222,6 +4233,9 @@ translate_atomic_rbuf(JNIEnv *env, jlong mem_type_id, H5T_class_t type_class, vo CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); break; } + default: + H5_BAD_ARGUMENT_ERROR(ENVONLY, + "translate_atomic_rbuf: no matching JNI type for integer type"); } break; } /* H5T_INTEGER */ @@ -4246,6 +4260,9 @@ translate_atomic_rbuf(JNIEnv *env, jlong mem_type_id, H5T_class_t type_class, vo CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); break; } + default: + H5_BAD_ARGUMENT_ERROR( + ENVONLY, "translate_atomic_rbuf: no matching JNI type for floating-point type"); } break; } /* H5T_FLOAT */ @@ -4295,6 +4312,9 @@ translate_atomic_rbuf(JNIEnv *env, jlong mem_type_id, H5T_class_t type_class, vo break; } /* H5T_STRING */ + case H5T_TIME: + case H5T_NO_CLASS: + case H5T_NCLASSES: default: H5_UNIMPLEMENTED(ENVONLY, "translate_atomic_rbuf: invalid class type"); break; @@ -4456,6 +4476,9 @@ translate_atomic_wbuf(JNIEnv *env, jobject in_obj, jlong mem_type_id, H5T_class_ memcpy(char_buf, ((char *)&longValue), typeSize); break; } + default: + H5_BAD_ARGUMENT_ERROR(ENVONLY, + "translate_atomic_wbuf: no matching JNI type for integer type"); } break; } /* H5T_INTEGER */ @@ -4472,6 +4495,9 @@ translate_atomic_wbuf(JNIEnv *env, jobject in_obj, jlong mem_type_id, H5T_class_ memcpy(char_buf, ((char *)&doubleValue), typeSize); break; } + default: + H5_BAD_ARGUMENT_ERROR( + ENVONLY, "translate_atomic_wbuf: no matching JNI type for floating-point type"); } break; } /* H5T_FLOAT */ @@ -4510,6 +4536,9 @@ translate_atomic_wbuf(JNIEnv *env, jobject in_obj, jlong mem_type_id, H5T_class_ } break; } /* H5T_STRING */ + case H5T_TIME: + case H5T_NO_CLASS: + case H5T_NCLASSES: default: H5_UNIMPLEMENTED(ENVONLY, "translate_atomic_wbuf: invalid class type"); break; @@ -4729,6 +4758,9 @@ translate_rbuf(JNIEnv *env, jobjectArray ret_buf, jlong mem_type_id, H5T_class_t } break; } + case H5T_TIME: + case H5T_NO_CLASS: + case H5T_NCLASSES: default: H5_UNIMPLEMENTED(ENVONLY, "translate_rbuf: invalid class type"); break; @@ -4888,6 +4920,9 @@ translate_wbuf(JNIEnv *env, jobjectArray in_buf, jlong mem_type_id, H5T_class_t } break; } + case H5T_TIME: + case H5T_NO_CLASS: + case H5T_NCLASSES: default: H5_UNIMPLEMENTED(ENVONLY, "translate_wbuf: invalid class type"); break; diff --git a/java/src/jni/nativeData.c b/java/src/jni/nativeData.c index 17ab6ea8021..d25951ff436 100644 --- a/java/src/jni/nativeData.c +++ b/java/src/jni/nativeData.c @@ -49,13 +49,11 @@ Java_hdf_hdf5lib_HDFNativeData_byteToInt___3B(JNIEnv *env, jclass clss, jbyteArr { jintArray rarray = NULL; jboolean bb; + uint8_t *p = NULL; jbyte *barr = NULL; jint *iarray = NULL; - jint *iap = NULL; - char *bp = NULL; - int blen; - int ii; - int len; + jsize ilen; + jsize blen; UNUSED(clss); @@ -69,20 +67,21 @@ Java_hdf_hdf5lib_HDFNativeData_byteToInt___3B(JNIEnv *env, jclass clss, jbyteArr H5_BAD_ARGUMENT_ERROR(ENVONLY, "byteToInt: bdata length < 0"); } - len = blen / (int)sizeof(jint); + ilen = blen / (jsize)sizeof(jint); - if (NULL == (rarray = ENVPTR->NewIntArray(ENVONLY, len))) + if (NULL == (rarray = ENVPTR->NewIntArray(ENVONLY, ilen))) CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); PIN_INT_ARRAY(ENVONLY, rarray, iarray, &bb, "byteToInt: int array not pinned"); - bp = (char *)barr; - iap = iarray; - for (ii = 0; ii < len; ii++) { - *iap = *(jint *)bp; - iap++; - bp += sizeof(jint); - } /* end for */ + p = (uint8_t *)barr; + for (size_t i = 0; i < (size_t)ilen; i++) { + jint val; + + memcpy(&val, p, sizeof(jint)); + iarray[i] = val; + p += sizeof(jint); + } done: if (iarray) @@ -93,57 +92,6 @@ Java_hdf_hdf5lib_HDFNativeData_byteToInt___3B(JNIEnv *env, jclass clss, jbyteArr return rarray; } /* end Java_hdf_hdf5lib_HDFNativeData_byteToInt___3B */ -/* returns float [] */ -JNIEXPORT jfloatArray JNICALL -Java_hdf_hdf5lib_HDFNativeData_byteToFloat___3B(JNIEnv *env, jclass clss, - jbyteArray bdata) /* IN: array of bytes */ -{ - jfloatArray rarray = NULL; - jboolean bb; - jfloat *farray = NULL; - jfloat *iap = NULL; - jbyte *barr = NULL; - char *bp = NULL; - int blen; - int ii; - int len; - - UNUSED(clss); - - if (NULL == bdata) - H5_NULL_ARGUMENT_ERROR(ENVONLY, "byteToFloat: byte array is NULL"); - - PIN_BYTE_ARRAY(ENVONLY, bdata, barr, &bb, "byteToFloat: byte array not pinned"); - - if ((blen = ENVPTR->GetArrayLength(ENVONLY, bdata)) < 0) { - CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); - H5_BAD_ARGUMENT_ERROR(ENVONLY, "byteToFloat: bdata length < 0"); - } - - len = blen / (int)sizeof(jfloat); - - if (NULL == (rarray = ENVPTR->NewFloatArray(ENVONLY, len))) - CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); - - PIN_FLOAT_ARRAY(ENVONLY, rarray, farray, &bb, "byteToFloat: float array not pinned"); - - bp = (char *)barr; - iap = farray; - for (ii = 0; ii < len; ii++) { - *iap = *(jfloat *)bp; - iap++; - bp += sizeof(jfloat); - } /* end for */ - -done: - if (farray) - UNPIN_FLOAT_ARRAY(ENVONLY, rarray, farray, rarray ? 0 : JNI_ABORT); - if (barr) - UNPIN_BYTE_ARRAY(ENVONLY, bdata, barr, JNI_ABORT); - - return rarray; -} /* end Java_hdf_hdf5lib_HDFNativeData_byteToFloat___3B */ - /* returns short [] */ JNIEXPORT jshortArray JNICALL Java_hdf_hdf5lib_HDFNativeData_byteToShort___3B(JNIEnv *env, jclass clss, @@ -151,13 +99,11 @@ Java_hdf_hdf5lib_HDFNativeData_byteToShort___3B(JNIEnv *env, jclass clss, { jshortArray rarray = NULL; jboolean bb; + uint8_t *p = NULL; jshort *sarray = NULL; - jshort *iap = NULL; jbyte *barr = NULL; - char *bp = NULL; - int blen; - int ii; - int len; + jsize slen; + jsize blen; UNUSED(clss); @@ -171,20 +117,21 @@ Java_hdf_hdf5lib_HDFNativeData_byteToShort___3B(JNIEnv *env, jclass clss, H5_BAD_ARGUMENT_ERROR(ENVONLY, "byteToShort: bdata length < 0"); } - len = blen / (int)sizeof(jshort); + slen = blen / (jsize)sizeof(jshort); - if (NULL == (rarray = ENVPTR->NewShortArray(ENVONLY, len))) + if (NULL == (rarray = ENVPTR->NewShortArray(ENVONLY, slen))) CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); PIN_SHORT_ARRAY(ENVONLY, rarray, sarray, &bb, "byteToShort: short array not pinned"); - bp = (char *)barr; - iap = sarray; - for (ii = 0; ii < len; ii++) { - *iap = *(jshort *)bp; - iap++; - bp += sizeof(jshort); - } /* end for */ + p = (uint8_t *)barr; + for (size_t i = 0; i < (size_t)slen; i++) { + jshort val; + + memcpy(&val, p, sizeof(jshort)); + sarray[i] = val; + p += sizeof(jshort); + } done: if (sarray) @@ -202,13 +149,11 @@ Java_hdf_hdf5lib_HDFNativeData_byteToLong___3B(JNIEnv *env, jclass clss, { jlongArray rarray = NULL; jboolean bb; + uint8_t *p = NULL; jlong *larray = NULL; - jlong *iap = NULL; jbyte *barr = NULL; - char *bp = NULL; - int blen; - int ii; - int len; + jsize llen; + jsize blen; UNUSED(clss); @@ -222,20 +167,21 @@ Java_hdf_hdf5lib_HDFNativeData_byteToLong___3B(JNIEnv *env, jclass clss, H5_BAD_ARGUMENT_ERROR(ENVONLY, "byteToLong: bdata length < 0"); } - len = blen / (int)sizeof(jlong); + llen = blen / (jsize)sizeof(jlong); - if (NULL == (rarray = ENVPTR->NewLongArray(ENVONLY, len))) + if (NULL == (rarray = ENVPTR->NewLongArray(ENVONLY, llen))) CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); PIN_LONG_ARRAY(ENVONLY, rarray, larray, &bb, "byteToLong: long array not pinned"); - bp = (char *)barr; - iap = larray; - for (ii = 0; ii < len; ii++) { - *iap = *(jlong *)bp; - iap++; - bp += sizeof(jlong); - } /* end for */ + p = (uint8_t *)barr; + for (size_t i = 0; i < (size_t)llen; i++) { + jlong val; + + memcpy(&val, p, sizeof(jlong)); + larray[i] = val; + p += sizeof(jlong); + } done: if (larray) @@ -246,6 +192,56 @@ Java_hdf_hdf5lib_HDFNativeData_byteToLong___3B(JNIEnv *env, jclass clss, return rarray; } /* end Java_hdf_hdf5lib_HDFNativeData_byteToLong___3B */ +/* returns float [] */ +JNIEXPORT jfloatArray JNICALL +Java_hdf_hdf5lib_HDFNativeData_byteToFloat___3B(JNIEnv *env, jclass clss, + jbyteArray bdata) /* IN: array of bytes */ +{ + jfloatArray rarray = NULL; + jboolean bb; + uint8_t *p = NULL; + jfloat *farray = NULL; + jbyte *barr = NULL; + jsize flen; + jsize blen; + + UNUSED(clss); + + if (NULL == bdata) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "byteToFloat: byte array is NULL"); + + PIN_BYTE_ARRAY(ENVONLY, bdata, barr, &bb, "byteToFloat: byte array not pinned"); + + if ((blen = ENVPTR->GetArrayLength(ENVONLY, bdata)) < 0) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "byteToFloat: bdata length < 0"); + } + + flen = blen / (jsize)sizeof(jfloat); + + if (NULL == (rarray = ENVPTR->NewFloatArray(ENVONLY, flen))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + PIN_FLOAT_ARRAY(ENVONLY, rarray, farray, &bb, "byteToFloat: float array not pinned"); + + p = (uint8_t *)barr; + for (size_t i = 0; i < (size_t)flen; i++) { + jfloat val; + + memcpy(&val, p, sizeof(jfloat)); + farray[i] = val; + p += sizeof(jfloat); + } + +done: + if (farray) + UNPIN_FLOAT_ARRAY(ENVONLY, rarray, farray, rarray ? 0 : JNI_ABORT); + if (barr) + UNPIN_BYTE_ARRAY(ENVONLY, bdata, barr, JNI_ABORT); + + return rarray; +} /* end Java_hdf_hdf5lib_HDFNativeData_byteToFloat___3B */ + /* returns double [] */ JNIEXPORT jdoubleArray JNICALL Java_hdf_hdf5lib_HDFNativeData_byteToDouble___3B(JNIEnv *env, jclass clss, @@ -253,13 +249,11 @@ Java_hdf_hdf5lib_HDFNativeData_byteToDouble___3B(JNIEnv *env, jclass clss, { jdoubleArray rarray = NULL; jboolean bb; + uint8_t *p = NULL; jdouble *darray = NULL; - jdouble *iap = NULL; jbyte *barr = NULL; - char *bp = NULL; - int blen; - int ii; - int len; + jsize dlen; + jsize blen; UNUSED(clss); @@ -273,20 +267,21 @@ Java_hdf_hdf5lib_HDFNativeData_byteToDouble___3B(JNIEnv *env, jclass clss, H5_BAD_ARGUMENT_ERROR(ENVONLY, "byteToDouble: bdata length < 0"); } - len = blen / (int)sizeof(jdouble); + dlen = blen / (jsize)sizeof(jdouble); - if (NULL == (rarray = ENVPTR->NewDoubleArray(ENVONLY, len))) + if (NULL == (rarray = ENVPTR->NewDoubleArray(ENVONLY, dlen))) CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); PIN_DOUBLE_ARRAY(ENVONLY, rarray, darray, &bb, "byteToDouble: double array not pinned"); - bp = (char *)barr; - iap = darray; - for (ii = 0; ii < len; ii++) { - *iap = *(jdouble *)bp; - iap++; - bp += sizeof(jdouble); - } /* end for */ + p = (uint8_t *)barr; + for (size_t i = 0; i < (size_t)dlen; i++) { + jdouble val; + + memcpy(&val, p, sizeof(jdouble)); + darray[i] = val; + p += sizeof(jdouble); + } done: if (darray) @@ -304,12 +299,10 @@ Java_hdf_hdf5lib_HDFNativeData_byteToInt__II_3B(JNIEnv *env, jclass clss, jint s { jintArray rarray = NULL; jboolean bb; + uint8_t *p = NULL; jint *iarray = NULL; - jint *iap = NULL; jbyte *barr = NULL; - char *bp = NULL; - int blen; - int ii; + jsize blen; UNUSED(clss); @@ -323,22 +316,22 @@ Java_hdf_hdf5lib_HDFNativeData_byteToInt__II_3B(JNIEnv *env, jclass clss, jint s H5_BAD_ARGUMENT_ERROR(ENVONLY, "byteToInt: bdata length < 0"); } - if ((start < 0) || ((int)(start + (len * (int)sizeof(jint))) > blen)) - H5_BAD_ARGUMENT_ERROR(ENVONLY, "byteToInt: start < 0 or len exceeded buffer length"); - - bp = (char *)barr + start; + if ((start < 0) || (len < 0) || ((int)(start + (len * (int)sizeof(jint))) > blen)) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "byteToInt: start < 0, len < 0 or len exceeded buffer length"); if (NULL == (rarray = ENVPTR->NewIntArray(ENVONLY, len))) CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); PIN_INT_ARRAY(ENVONLY, rarray, iarray, &bb, "byteToInt: int array not pinned"); - iap = iarray; - for (ii = 0; ii < len; ii++) { - *iap = *(jint *)bp; - iap++; - bp += sizeof(jint); - } /* end for */ + p = (uint8_t *)barr + start; + for (size_t i = 0; i < (size_t)len; i++) { + jint val; + + memcpy(&val, p, sizeof(jint)); + iarray[i] = val; + p += sizeof(jint); + } done: if (iarray) @@ -356,12 +349,10 @@ Java_hdf_hdf5lib_HDFNativeData_byteToShort__II_3B(JNIEnv *env, jclass clss, jint { jshortArray rarray = NULL; jboolean bb; + uint8_t *p = NULL; jshort *sarray = NULL; - jshort *iap = NULL; jbyte *barr = NULL; - char *bp = NULL; - int blen; - int ii; + jsize blen; UNUSED(clss); @@ -375,22 +366,22 @@ Java_hdf_hdf5lib_HDFNativeData_byteToShort__II_3B(JNIEnv *env, jclass clss, jint H5_BAD_ARGUMENT_ERROR(ENVONLY, "byteToShort: bdata length < 0"); } - if ((start < 0) || ((int)(start + (len * (int)sizeof(jshort))) > blen)) - H5_BAD_ARGUMENT_ERROR(ENVONLY, "byteToShort: start < 0 or len exceeded buffer length"); - - bp = (char *)barr + start; + if ((start < 0) || (len < 0) || ((int)(start + (len * (int)sizeof(jshort))) > blen)) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "byteToShort: start < 0, len < 0 or len exceeded buffer length"); if (NULL == (rarray = ENVPTR->NewShortArray(ENVONLY, len))) CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); PIN_SHORT_ARRAY(ENVONLY, rarray, sarray, &bb, "byteToShort: short array not pinned"); - iap = sarray; - for (ii = 0; ii < len; ii++) { - *iap = *(jshort *)bp; - iap++; - bp += sizeof(jshort); - } /* end for */ + p = (uint8_t *)barr + start; + for (size_t i = 0; i < (size_t)len; i++) { + jshort val; + + memcpy(&val, p, sizeof(jshort)); + sarray[i] = val; + p += sizeof(jshort); + } done: if (sarray) @@ -401,109 +392,105 @@ Java_hdf_hdf5lib_HDFNativeData_byteToShort__II_3B(JNIEnv *env, jclass clss, jint return rarray; } /* end Java_hdf_hdf5lib_HDFNativeData_byteToShort__II_3B */ -/* returns float [] */ -JNIEXPORT jfloatArray JNICALL -Java_hdf_hdf5lib_HDFNativeData_byteToFloat__II_3B(JNIEnv *env, jclass clss, jint start, jint len, - jbyteArray bdata) /* IN: array of bytes */ +/* returns long [] */ +JNIEXPORT jlongArray JNICALL +Java_hdf_hdf5lib_HDFNativeData_byteToLong__II_3B(JNIEnv *env, jclass clss, jint start, jint len, + jbyteArray bdata) /* IN: array of bytes */ { - jfloatArray rarray = NULL; - jboolean bb; - jfloat *farray = NULL; - jfloat *iap = NULL; - jbyte *barr = NULL; - char *bp = NULL; - int blen; - int ii; + jlongArray rarray = NULL; + jboolean bb; + uint8_t *p = NULL; + jlong *larray = NULL; + jbyte *barr = NULL; + jsize blen; UNUSED(clss); if (NULL == bdata) - H5_NULL_ARGUMENT_ERROR(ENVONLY, "byteToFloat: byte array is NULL"); + H5_NULL_ARGUMENT_ERROR(ENVONLY, "byteToLong: byte array is NULL"); - PIN_BYTE_ARRAY(ENVONLY, bdata, barr, &bb, "byteToFloat: byte array not pinned"); + PIN_BYTE_ARRAY(ENVONLY, bdata, barr, &bb, "byteToLong: byte array not pinned"); if ((blen = ENVPTR->GetArrayLength(ENVONLY, bdata)) < 0) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); - H5_BAD_ARGUMENT_ERROR(ENVONLY, "byteToFloat: bdata length < 0"); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "byteToLong: bdata length < 0"); } - if ((start < 0) || ((int)(start + (len * (int)sizeof(jfloat))) > blen)) - H5_BAD_ARGUMENT_ERROR(ENVONLY, "byteToFloat: start < 0 or len exceeded buffer length"); - - bp = (char *)barr + start; + if ((start < 0) || (len < 0) || ((int)(start + (len * (int)sizeof(jlong))) > blen)) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "byteToLong: start < 0, len < 0 or len exceeded buffer length"); - if (NULL == (rarray = ENVPTR->NewFloatArray(ENVONLY, len))) + if (NULL == (rarray = ENVPTR->NewLongArray(ENVONLY, len))) CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); - PIN_FLOAT_ARRAY(ENVONLY, rarray, farray, &bb, "byteToFloat: float array not pinned"); + PIN_LONG_ARRAY(ENVONLY, rarray, larray, &bb, "byteToLong: long array not pinned"); - iap = farray; - for (ii = 0; ii < len; ii++) { - *iap = *(jfloat *)bp; - iap++; - bp += sizeof(jfloat); - } /* end for */ + p = (uint8_t *)barr + start; + for (size_t i = 0; i < (size_t)len; i++) { + jlong val; + + memcpy(&val, p, sizeof(jlong)); + larray[i] = val; + p += sizeof(jlong); + } done: - if (farray) - UNPIN_FLOAT_ARRAY(ENVONLY, rarray, farray, rarray ? 0 : JNI_ABORT); + if (larray) + UNPIN_LONG_ARRAY(ENVONLY, rarray, larray, rarray ? 0 : JNI_ABORT); if (barr) UNPIN_BYTE_ARRAY(ENVONLY, bdata, barr, JNI_ABORT); return rarray; -} /* end Java_hdf_hdf5lib_HDFNativeData_byteToFloat__II_3B */ +} /* end Java_hdf_hdf5lib_HDFNativeData_byteToLong__II_3B */ -/* returns long [] */ -JNIEXPORT jlongArray JNICALL -Java_hdf_hdf5lib_HDFNativeData_byteToLong__II_3B(JNIEnv *env, jclass clss, jint start, jint len, - jbyteArray bdata) /* IN: array of bytes */ +/* returns float [] */ +JNIEXPORT jfloatArray JNICALL +Java_hdf_hdf5lib_HDFNativeData_byteToFloat__II_3B(JNIEnv *env, jclass clss, jint start, jint len, + jbyteArray bdata) /* IN: array of bytes */ { - jlongArray rarray = NULL; - jboolean bb; - jlong *larray = NULL; - jlong *iap = NULL; - jbyte *barr = NULL; - char *bp = NULL; - int blen; - int ii; + jfloatArray rarray = NULL; + jboolean bb; + uint8_t *p = NULL; + jfloat *farray = NULL; + jbyte *barr = NULL; + jsize blen; UNUSED(clss); if (NULL == bdata) - H5_NULL_ARGUMENT_ERROR(ENVONLY, "byteToLong: byte array is NULL"); + H5_NULL_ARGUMENT_ERROR(ENVONLY, "byteToFloat: byte array is NULL"); - PIN_BYTE_ARRAY(ENVONLY, bdata, barr, &bb, "byteToLong: byte array not pinned"); + PIN_BYTE_ARRAY(ENVONLY, bdata, barr, &bb, "byteToFloat: byte array not pinned"); if ((blen = ENVPTR->GetArrayLength(ENVONLY, bdata)) < 0) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); - H5_BAD_ARGUMENT_ERROR(ENVONLY, "byteToLong: bdata length < 0"); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "byteToFloat: bdata length < 0"); } - if ((start < 0) || ((int)(start + (len * (int)sizeof(jlong))) > blen)) - H5_BAD_ARGUMENT_ERROR(ENVONLY, "byteToLong: start < 0 or len exceeded buffer length"); - - bp = (char *)barr + start; + if ((start < 0) || (len < 0) || ((int)(start + (len * (int)sizeof(jfloat))) > blen)) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "byteToFloat: start < 0, len < 0 or len exceeded buffer length"); - if (NULL == (rarray = ENVPTR->NewLongArray(ENVONLY, len))) + if (NULL == (rarray = ENVPTR->NewFloatArray(ENVONLY, len))) CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); - PIN_LONG_ARRAY(ENVONLY, rarray, larray, &bb, "byteToLong: long array not pinned"); + PIN_FLOAT_ARRAY(ENVONLY, rarray, farray, &bb, "byteToFloat: float array not pinned"); - iap = larray; - for (ii = 0; ii < len; ii++) { - *iap = *(jlong *)bp; - iap++; - bp += sizeof(jlong); - } /* end for */ + p = (uint8_t *)barr + start; + for (size_t i = 0; i < (size_t)len; i++) { + jfloat val; + + memcpy(&val, p, sizeof(jfloat)); + farray[i] = val; + p += sizeof(jfloat); + } done: - if (larray) - UNPIN_LONG_ARRAY(ENVONLY, rarray, larray, rarray ? 0 : JNI_ABORT); + if (farray) + UNPIN_FLOAT_ARRAY(ENVONLY, rarray, farray, rarray ? 0 : JNI_ABORT); if (barr) UNPIN_BYTE_ARRAY(ENVONLY, bdata, barr, JNI_ABORT); return rarray; -} /* end Java_hdf_hdf5lib_HDFNativeData_byteToLong__II_3B */ +} /* end Java_hdf_hdf5lib_HDFNativeData_byteToFloat__II_3B */ /* returns double [] */ JNIEXPORT jdoubleArray JNICALL @@ -512,12 +499,10 @@ Java_hdf_hdf5lib_HDFNativeData_byteToDouble__II_3B(JNIEnv *env, jclass clss, jin { jdoubleArray rarray = NULL; jboolean bb; + uint8_t *p = NULL; jdouble *darray = NULL; - jdouble *iap = NULL; jbyte *barr = NULL; - char *bp = NULL; - int blen; - int ii; + jsize blen; UNUSED(clss); @@ -531,22 +516,22 @@ Java_hdf_hdf5lib_HDFNativeData_byteToDouble__II_3B(JNIEnv *env, jclass clss, jin H5_BAD_ARGUMENT_ERROR(ENVONLY, "byteToDouble: bdata length < 0"); } - if ((start < 0) || ((int)(start + (len * (int)sizeof(jdouble))) > blen)) - H5_BAD_ARGUMENT_ERROR(ENVONLY, "byteToDouble: start < 0 or len exceeded buffer length"); - - bp = (char *)barr + start; + if ((start < 0) || (len < 0) || ((int)(start + (len * (int)sizeof(jdouble))) > blen)) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "byteToDouble: start < 0, len < 0 or len exceeded buffer length"); if (NULL == (rarray = ENVPTR->NewDoubleArray(ENVONLY, len))) CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); PIN_DOUBLE_ARRAY(ENVONLY, rarray, darray, &bb, "byteToDouble: double array not pinned"); - iap = darray; - for (ii = 0; ii < len; ii++) { - *iap = *(jdouble *)bp; - iap++; - bp += sizeof(jdouble); - } /* end for */ + p = (uint8_t *)barr + start; + for (size_t i = 0; i < (size_t)len; i++) { + jdouble val; + + memcpy(&val, p, sizeof(jdouble)); + darray[i] = val; + p += sizeof(jdouble); + } done: if (darray) diff --git a/test/h5test.c b/test/h5test.c index e921dc85c52..6f27a93a368 100644 --- a/test/h5test.c +++ b/test/h5test.c @@ -830,12 +830,12 @@ h5_get_vfd_fapl(hid_t fapl) } else if (!strcmp(tok, "core")) { /* In-memory driver settings (backing store on, 1 MB increment) */ - if (H5Pset_fapl_core(fapl, H5_MB, TRUE) < 0) + if (H5Pset_fapl_core(fapl, (size_t)H5_MB, TRUE) < 0) goto error; } else if (!strcmp(tok, "core_paged")) { /* In-memory driver with write tracking and paging on */ - if (H5Pset_fapl_core(fapl, H5_MB, TRUE) < 0) + if (H5Pset_fapl_core(fapl, (size_t)H5_MB, TRUE) < 0) goto error; if (H5Pset_core_write_tracking(fapl, TRUE, 4096) < 0) goto error;