summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAllen Byrne <50328838+byrnHDF@users.noreply.github.com>2022-10-03 18:31:32 (GMT)
committerGitHub <noreply@github.com>2022-10-03 18:31:32 (GMT)
commitc114bd64b0662a010b0a9c502b921adfab00f1e6 (patch)
tree9bfe24cf7fa1618398e2a7e053483ff0c8043e51
parent1fb83da21531da8e531234fa6ab810b7a90d7ee9 (diff)
downloadhdf5-c114bd64b0662a010b0a9c502b921adfab00f1e6.zip
hdf5-c114bd64b0662a010b0a9c502b921adfab00f1e6.tar.gz
hdf5-c114bd64b0662a010b0a9c502b921adfab00f1e6.tar.bz2
Fix mostly java warnings, and cpp cast (#2134)
-rw-r--r--c++/test/tfilter.cpp8
-rw-r--r--java/src/jni/h5aImp.c30
-rw-r--r--java/src/jni/h5dImp.c28
-rw-r--r--java/src/jni/h5jni.h17
-rw-r--r--java/src/jni/h5util.c296
-rw-r--r--java/test/TestH5Fparams.java1
-rw-r--r--java/test/TestH5Ocreate.java4
-rw-r--r--java/test/TestH5Oparams.java3
-rw-r--r--test/tmisc.c2
9 files changed, 204 insertions, 185 deletions
diff --git a/c++/test/tfilter.cpp b/c++/test/tfilter.cpp
index b5073e8..e47a44d 100644
--- a/c++/test/tfilter.cpp
+++ b/c++/test/tfilter.cpp
@@ -190,13 +190,15 @@ test_szip_filter(H5File &file1)
hsize_t i, j, n;
for (i = n = 0; i < size[0]; i++) {
for (j = 0; j < size[1]; j++) {
- points[i][j] = (int)n++;
+ points[i][j] = static_cast<int> n++;
}
}
// Write to the dataset then read back the values
- dataset.write((void *)points, PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer);
- dataset.read((void *)check, PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer);
+ dataset.write(static_cast<void *> points, PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL,
+ xfer);
+ dataset.read(static_cast<void *> check, PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL,
+ xfer);
// Check that the values read are the same as the values written
for (i = 0; i < size[0]; i++)
diff --git a/java/src/jni/h5aImp.c b/java/src/jni/h5aImp.c
index e5e8462..086fea8 100644
--- a/java/src/jni/h5aImp.c
+++ b/java/src/jni/h5aImp.c
@@ -1084,7 +1084,7 @@ Java_hdf_hdf5lib_H5_H5AreadVL(JNIEnv *env, jclass clss, jlong attr_id, jlong mem
/* Get size of data array */
if ((n = ENVPTR->GetArrayLength(ENVONLY, buf)) < 0) {
CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE);
- H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Aread: readBuf length < 0");
+ H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5AreadVL: readBuf length < 0");
}
dims[0] = (hsize_t)n;
@@ -1095,12 +1095,12 @@ Java_hdf_hdf5lib_H5_H5AreadVL(JNIEnv *env, jclass clss, jlong attr_id, jlong mem
if ((type_class = H5Tget_class((hid_t)mem_type_id)) < 0)
H5_LIBRARY_ERROR(ENVONLY);
if (type_class == H5T_VLEN) {
- size_t typeSize;
- hid_t memb = H5I_INVALID_HID;
- H5T_class_t vlClass;
- size_t vlSize;
- void *rawBuf = NULL;
- jobject *jList = NULL;
+ size_t typeSize;
+ hid_t memb = H5I_INVALID_HID;
+ H5T_class_t vlClass;
+ size_t vlSize;
+ void *rawBuf = NULL;
+ jobjectArray jList = NULL;
size_t i, j, x;
@@ -1234,7 +1234,7 @@ Java_hdf_hdf5lib_H5_H5AreadVL(JNIEnv *env, jclass clss, jlong attr_id, jlong mem
}
jobj = ENVPTR->CallStaticObjectMethod(ENVONLY, cFloat, floatValueMid,
- floatValue);
+ (double)floatValue);
CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE);
break;
}
@@ -1321,7 +1321,7 @@ Java_hdf_hdf5lib_H5_H5AwriteVL(JNIEnv *env, jclass clss, jlong attr_id, jlong me
htri_t vl_data_class;
herr_t status = FAIL;
jboolean writeBufIsCopy;
- jbyteArray *writeBuf = NULL;
+ jbyteArray writeBuf = NULL;
UNUSED(clss);
@@ -1344,12 +1344,12 @@ Java_hdf_hdf5lib_H5_H5AwriteVL(JNIEnv *env, jclass clss, jlong attr_id, jlong me
if ((type_class = H5Tget_class((hid_t)mem_type_id)) < 0)
H5_LIBRARY_ERROR(ENVONLY);
if (type_class == H5T_VLEN) {
- size_t typeSize;
- hid_t memb = H5I_INVALID_HID;
- H5T_class_t vlClass;
- size_t vlSize;
- void *rawBuf = NULL;
- jobject *jList = NULL;
+ size_t typeSize;
+ hid_t memb = H5I_INVALID_HID;
+ H5T_class_t vlClass;
+ size_t vlSize;
+ void *rawBuf = NULL;
+ jobjectArray jList = NULL;
size_t i, j, x;
diff --git a/java/src/jni/h5dImp.c b/java/src/jni/h5dImp.c
index e6e9a76..59775e3 100644
--- a/java/src/jni/h5dImp.c
+++ b/java/src/jni/h5dImp.c
@@ -1110,12 +1110,12 @@ Java_hdf_hdf5lib_H5_H5DreadVL(JNIEnv *env, jclass clss, jlong dataset_id, jlong
if ((type_class = H5Tget_class((hid_t)mem_type_id)) < 0)
H5_LIBRARY_ERROR(ENVONLY);
if (type_class == H5T_VLEN) {
- size_t typeSize;
- hid_t memb = H5I_INVALID_HID;
- H5T_class_t vlClass;
- size_t vlSize;
- void *rawBuf = NULL;
- jobject *jList = NULL;
+ size_t typeSize;
+ hid_t memb = H5I_INVALID_HID;
+ H5T_class_t vlClass;
+ size_t vlSize;
+ void *rawBuf = NULL;
+ jobjectArray jList = NULL;
size_t i, j, x;
@@ -1250,7 +1250,7 @@ Java_hdf_hdf5lib_H5_H5DreadVL(JNIEnv *env, jclass clss, jlong dataset_id, jlong
}
jobj = ENVPTR->CallStaticObjectMethod(ENVONLY, cFloat, floatValueMid,
- floatValue);
+ (double)floatValue);
CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE);
break;
}
@@ -1334,7 +1334,7 @@ Java_hdf_hdf5lib_H5_H5DwriteVL(JNIEnv *env, jclass clss, jlong dataset_id, jlong
htri_t vl_data_class;
herr_t status = FAIL;
jboolean writeBufIsCopy;
- jbyteArray *writeBuf = NULL;
+ jbyteArray writeBuf = NULL;
UNUSED(clss);
@@ -1353,12 +1353,12 @@ Java_hdf_hdf5lib_H5_H5DwriteVL(JNIEnv *env, jclass clss, jlong dataset_id, jlong
if ((type_class = H5Tget_class((hid_t)mem_type_id)) < 0)
H5_LIBRARY_ERROR(ENVONLY);
if (type_class == H5T_VLEN) {
- size_t typeSize;
- hid_t memb = H5I_INVALID_HID;
- H5T_class_t vlClass;
- size_t vlSize;
- void *rawBuf = NULL;
- jobject *jList = NULL;
+ size_t typeSize;
+ hid_t memb = H5I_INVALID_HID;
+ H5T_class_t vlClass;
+ size_t vlSize;
+ void *rawBuf = NULL;
+ jobjectArray jList = NULL;
size_t i, j, x;
diff --git a/java/src/jni/h5jni.h b/java/src/jni/h5jni.h
index 2c93846..5af5a91 100644
--- a/java/src/jni/h5jni.h
+++ b/java/src/jni/h5jni.h
@@ -257,6 +257,23 @@
do { \
(*envptr)->ReleaseStringUTFChars(envptr, pinnedString, stringToRelease); \
} while (0)
+/*
+ * Above String macros may be incorrect, suggested code for getting a cstr from java
+ * int jstr_to_cstr(JNIEnv *jenv, jstring j_str, char *c_str, size_t cstr_len)
+ * {
+ * int32_t j_len, c_len;
+ *
+ * c_len = (*jenv)->GetStringUTFLength(jenv, j_str);
+ * if (c_len > (int32_t)cstr_len)
+ * return -ENAMETOOLONG;
+ * j_len = (*jenv)->GetStringLength(jenv, j_str);
+ * (*jenv)->GetStringUTFRegion(jenv, j_str, 0, j_len, c_str);
+ * if ((*jenv)->ExceptionCheck(jenv))
+ * return -EIO;
+ * return 0;
+ * }
+ *
+ */
#ifdef __cplusplus
extern "C" {
diff --git a/java/src/jni/h5util.c b/java/src/jni/h5util.c
index e8417b6..37d0194 100644
--- a/java/src/jni/h5util.c
+++ b/java/src/jni/h5util.c
@@ -436,7 +436,7 @@ h5str_convert(JNIEnv *env, char **in_str, hid_t container, hid_t tid, void *out_
break;
case H5T_ENUM: {
- void *value;
+ void *value = NULL;
token = HDstrtok(this_str, delimiter);
@@ -865,7 +865,7 @@ h5str_sprintf(JNIEnv *env, h5str_t *out_str, hid_t container, hid_t tid, void *i
if (NULL == (this_str = (char *)HDmalloc(this_len)))
H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer");
- if (HDsnprintf(this_str, this_len, "%g", tmp_float) < 0)
+ if (HDsnprintf(this_str, this_len, "%g", (double)tmp_float) < 0)
H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsnprintf failure");
break;
@@ -2273,10 +2273,10 @@ h5str_render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hs
}
case H5T_STRING: {
- unsigned char tempuchar;
unsigned int i;
H5T_str_t pad;
- char *s;
+ char *s = NULL;
+ unsigned char tempuchar;
if ((pad = H5Tget_strpad(tid)) < 0) {
ret_value = FAIL;
@@ -2287,7 +2287,7 @@ h5str_render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hs
mem = ((unsigned char *)_mem) + block_index * size;
if (H5Tis_variable_str(tid)) {
- s = *(char **)mem;
+ s = *(char **)((void *)mem);
if (s != NULL)
size = HDstrlen(s);
}
@@ -2919,24 +2919,20 @@ done:
int
h5str_dump_simple_dset(JNIEnv *env, FILE *stream, hid_t dset, int binary_order)
{
+ hid_t f_space = H5I_INVALID_HID; /* file data space */
hsize_t elmtno; /* counter */
+ size_t i = 0; /* counter */
+ int sndims; /* rank of dataspace */
+ int carry; /* counter carry value */
hsize_t zero[8]; /* vector of zeros */
hsize_t total_size[H5S_MAX_RANK]; /* total size of dataset*/
- size_t i; /* counter */
- hid_t f_space = H5I_INVALID_HID; /* file data space */
- int ndims;
- int carry; /* counter carry value */
-
- /* Print info */
- hssize_t p_nelmts; /* total selected elmts */
- size_t p_type_nbytes; /* size of memory type */
/* Stripmine info */
- void *sm_buf = NULL; /* buffer for raw data */
- hsize_t sm_size[H5S_MAX_RANK]; /* stripmine size */
- hsize_t sm_nbytes; /* bytes per stripmine */
- hsize_t sm_nelmts; /* elements per stripmine */
- hid_t sm_space = H5I_INVALID_HID; /* stripmine data space */
+ hsize_t sm_size[H5S_MAX_RANK]; /* stripmine size */
+ hsize_t sm_nbytes; /* bytes per stripmine */
+ hsize_t sm_nelmts; /* elements per stripmine */
+ unsigned char *sm_buf = NULL; /* buffer for raw data */
+ hid_t sm_space = H5I_INVALID_HID; /* stripmine data space */
/* Hyperslab info */
hsize_t hs_offset[H5S_MAX_RANK]; /* starting offset */
@@ -2944,11 +2940,11 @@ h5str_dump_simple_dset(JNIEnv *env, FILE *stream, hid_t dset, int binary_order)
hsize_t hs_nelmts; /* elements in request */
/* VL data special information */
- unsigned int vl_data = 0; /* contains VL datatypes */
- hid_t p_type = H5I_INVALID_HID;
- hid_t f_type = H5I_INVALID_HID;
+ unsigned int vl_data = 0; /* contains VL datatypes */
+ int ret_value = FAIL;
- int ret_value = FAIL;
+ hid_t p_type = H5I_INVALID_HID;
+ hid_t f_type = H5I_INVALID_HID;
if (dset < 0)
H5_BAD_ARGUMENT_ERROR(ENVONLY, "h5str_dump_simple_dset: dset ID < 0");
@@ -2959,18 +2955,21 @@ h5str_dump_simple_dset(JNIEnv *env, FILE *stream, hid_t dset, int binary_order)
if ((f_space = H5Dget_space(dset)) < 0)
H5_LIBRARY_ERROR(ENVONLY);
- if ((ndims = H5Sget_simple_extent_ndims(f_space)) < 0)
+ if ((sndims = H5Sget_simple_extent_ndims(f_space)) < 0)
H5_LIBRARY_ERROR(ENVONLY);
+ /* Assume entire data space to be printed */
if (H5Sget_simple_extent_dims(f_space, total_size, NULL) < 0)
H5_LIBRARY_ERROR(ENVONLY);
if (H5Tequal(f_type, H5T_STD_REF_DSETREG)) {
+ hssize_t p_nelmts; /* total selected elmts */
+
if ((p_nelmts = H5Sget_simple_extent_npoints(f_space)) < 0)
H5_LIBRARY_ERROR(ENVONLY);
if (NULL ==
- (sm_buf = (H5R_ref_t *)HDcalloc(MAX(sizeof(unsigned), sizeof(H5R_ref_t)), (size_t)p_nelmts)))
+ (sm_buf = (unsigned char *)HDcalloc(MAX(sizeof(unsigned), sizeof(H5R_ref_t)), (size_t)p_nelmts)))
H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_dump_simple_mem: failed to allocate sm_buf");
/* Read the data */
@@ -2987,6 +2986,10 @@ h5str_dump_simple_dset(JNIEnv *env, FILE *stream, hid_t dset, int binary_order)
}
}
else {
+ /* Print info */
+ size_t p_type_nbytes; /* size of memory type */
+ hsize_t p_nelmts; /* total selected elmts */
+
switch (binary_order) {
case 1: {
if ((p_type = h5str_get_native_type(f_type)) < 0)
@@ -3017,109 +3020,102 @@ h5str_dump_simple_dset(JNIEnv *env, FILE *stream, hid_t dset, int binary_order)
}
}
- if ((size_t)ndims <= (sizeof(sm_size) / sizeof(sm_size[0]))) {
- if (H5Sget_simple_extent_dims(f_space, total_size, NULL) < 0)
- H5_LIBRARY_ERROR(ENVONLY);
+ /* Calculate the number of elements we're going to print */
+ p_nelmts = 1;
- /* Calculate the number of elements we're going to print */
- p_nelmts = 1;
-
- if (ndims > 0) {
- for (i = 0; i < (size_t)ndims; i++)
- p_nelmts *= total_size[i];
- } /* end if */
+ if (sndims > 0) {
+ for (i = 0; i < (size_t)sndims; i++)
+ p_nelmts *= total_size[i];
+ } /* end if */
- if (p_nelmts > 0) {
- /* Check if we have VL data in the dataset's datatype */
- if (h5str_detect_vlen(p_type) != 0)
- vl_data = 1;
+ if (p_nelmts > 0) {
+ /* Check if we have VL data in the dataset's datatype */
+ if (h5str_detect_vlen(p_type) != 0)
+ vl_data = 1;
- /*
- * Determine the strip mine size and allocate a buffer. The strip mine is
- * a hyperslab whose size is manageable.
- */
- if (!(sm_nbytes = p_type_nbytes = H5Tget_size(p_type)))
- H5_LIBRARY_ERROR(ENVONLY);
+ /*
+ * Determine the strip mine size and allocate a buffer. The strip mine is
+ * a hyperslab whose size is manageable.
+ */
+ if (!(sm_nbytes = p_type_nbytes = H5Tget_size(p_type)))
+ H5_LIBRARY_ERROR(ENVONLY);
- if (ndims > 0) {
- for (i = (size_t)ndims; i > 0; --i) {
- hsize_t size = H5TOOLS_BUFSIZE / sm_nbytes;
- if (size == 0) /* datum size > H5TOOLS_BUFSIZE */
- size = 1;
- sm_size[i - 1] = (((total_size[i - 1]) < (size)) ? (total_size[i - 1]) : (size));
- sm_nbytes *= sm_size[i - 1];
- }
+ if (sndims > 0) {
+ for (i = (size_t)sndims; i > 0; --i) {
+ hsize_t size = H5TOOLS_BUFSIZE / sm_nbytes;
+ if (size == 0) /* datum size > H5TOOLS_BUFSIZE */
+ size = 1;
+ sm_size[i - 1] = (((total_size[i - 1]) < (size)) ? (total_size[i - 1]) : (size));
+ sm_nbytes *= sm_size[i - 1];
}
+ }
- if (sm_nbytes > 0) {
- if (NULL == (sm_buf = (unsigned char *)HDmalloc((size_t)sm_nbytes)))
- H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_dump_simple_dset: failed to allocate sm_buf");
+ if (sm_nbytes > 0) {
+ if (NULL == (sm_buf = (unsigned char *)HDmalloc((size_t)sm_nbytes)))
+ H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_dump_simple_dset: failed to allocate sm_buf");
- sm_nelmts = sm_nbytes / p_type_nbytes;
+ sm_nelmts = sm_nbytes / p_type_nbytes;
- if ((sm_space = H5Screate_simple(1, &sm_nelmts, NULL)) < 0)
- H5_LIBRARY_ERROR(ENVONLY);
-
- /* The stripmine loop */
- HDmemset(hs_offset, 0, sizeof hs_offset);
- HDmemset(zero, 0, sizeof zero);
-
- for (elmtno = 0; elmtno < (hsize_t)p_nelmts; elmtno += hs_nelmts) {
- /* Calculate the hyperslab size */
- if (ndims > 0) {
- for (i = 0, hs_nelmts = 1; i < (size_t)ndims; i++) {
- hs_size[i] = (((total_size[i] - hs_offset[i]) < (sm_size[i]))
- ? (total_size[i] - hs_offset[i])
- : (sm_size[i]));
- hs_nelmts *= hs_size[i];
- }
-
- if (H5Sselect_hyperslab(f_space, H5S_SELECT_SET, hs_offset, NULL, hs_size, NULL) <
- 0)
- H5_LIBRARY_ERROR(ENVONLY);
+ if ((sm_space = H5Screate_simple(1, &sm_nelmts, NULL)) < 0)
+ H5_LIBRARY_ERROR(ENVONLY);
- if (H5Sselect_hyperslab(sm_space, H5S_SELECT_SET, zero, NULL, &hs_nelmts, NULL) <
- 0)
- H5_LIBRARY_ERROR(ENVONLY);
+ /* The stripmine loop */
+ HDmemset(hs_offset, 0, sizeof hs_offset);
+ HDmemset(zero, 0, sizeof zero);
+
+ for (elmtno = 0; elmtno < (hsize_t)p_nelmts; elmtno += hs_nelmts) {
+ /* Calculate the hyperslab size */
+ if (sndims > 0) {
+ for (i = 0, hs_nelmts = 1; i < (size_t)sndims; i++) {
+ hs_size[i] = (((total_size[i] - hs_offset[i]) < (sm_size[i]))
+ ? (total_size[i] - hs_offset[i])
+ : (sm_size[i]));
+ hs_nelmts *= hs_size[i];
}
- else {
- if (H5Sselect_all(f_space) < 0)
- H5_LIBRARY_ERROR(ENVONLY);
- if (H5Sselect_all(sm_space) < 0)
- H5_LIBRARY_ERROR(ENVONLY);
+ if (H5Sselect_hyperslab(f_space, H5S_SELECT_SET, hs_offset, NULL, hs_size, NULL) < 0)
+ H5_LIBRARY_ERROR(ENVONLY);
- hs_nelmts = 1;
- }
+ if (H5Sselect_hyperslab(sm_space, H5S_SELECT_SET, zero, NULL, &hs_nelmts, NULL) < 0)
+ H5_LIBRARY_ERROR(ENVONLY);
+ }
+ else {
+ if (H5Sselect_all(f_space) < 0)
+ H5_LIBRARY_ERROR(ENVONLY);
- /* Read the data */
- if (H5Dread(dset, p_type, sm_space, f_space, H5P_DEFAULT, sm_buf) < 0)
+ if (H5Sselect_all(sm_space) < 0)
H5_LIBRARY_ERROR(ENVONLY);
- if (binary_order == 99) {
- if (h5str_dump_simple_data(ENVONLY, stream, dset, p_type, sm_buf, hs_nelmts) < 0)
- CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE);
- }
- else {
- if (h5str_render_bin_output(stream, dset, p_type, sm_buf, hs_nelmts) < 0)
- CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE);
- }
+ hs_nelmts = 1;
+ }
- /* Reclaim any VL memory, if necessary */
- if (vl_data) {
- if (H5Treclaim(p_type, sm_space, H5P_DEFAULT, sm_buf) < 0)
- H5_LIBRARY_ERROR(ENVONLY);
- }
+ /* Read the data */
+ if (H5Dread(dset, p_type, sm_space, f_space, H5P_DEFAULT, sm_buf) < 0)
+ H5_LIBRARY_ERROR(ENVONLY);
+
+ if (binary_order == 99) {
+ if (h5str_dump_simple_data(ENVONLY, stream, dset, p_type, sm_buf, hs_nelmts) < 0)
+ CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE);
+ }
+ else {
+ if (h5str_render_bin_output(stream, dset, p_type, sm_buf, hs_nelmts) < 0)
+ CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE);
+ }
- /* Calculate the next hyperslab offset */
- for (i = (size_t)ndims, carry = 1; i > 0 && carry; --i) {
- hs_offset[i - 1] += hs_size[i - 1];
+ /* Reclaim any VL memory, if necessary */
+ if (vl_data) {
+ if (H5Treclaim(p_type, sm_space, H5P_DEFAULT, sm_buf) < 0)
+ H5_LIBRARY_ERROR(ENVONLY);
+ }
- if (hs_offset[i - 1] == total_size[i - 1])
- hs_offset[i - 1] = 0;
- else
- carry = 0;
- }
+ /* Calculate the next hyperslab offset */
+ for (i = (size_t)sndims, carry = 1; i > 0 && carry; --i) {
+ hs_offset[i - 1] += hs_size[i - 1];
+
+ if (hs_offset[i - 1] == total_size[i - 1])
+ hs_offset[i - 1] = 0;
+ else
+ carry = 0;
}
}
}
@@ -3148,15 +3144,12 @@ h5str_dump_simple_mem(JNIEnv *env, FILE *stream, hid_t attr_id, int binary_order
{
hid_t f_space = H5I_INVALID_HID; /* file data space */
hsize_t alloc_size;
- int ndims; /* rank of dataspace */
- unsigned i; /* counters */
- hsize_t total_size[H5S_MAX_RANK]; /* total size of dataset*/
- hssize_t p_nelmts; /* total selected elmts */
+ int sndims; /* rank of dataspace */
+ unsigned i; /* counters */
+ hsize_t total_size[H5S_MAX_RANK]; /* total size of dataset */
+ int ret_value = 0;
- void *sm_buf = NULL; /* buffer for raw data */
- hsize_t sm_size[H5S_MAX_RANK]; /* stripmine size */
-
- int ret_value = 0;
+ unsigned char *sm_buf = NULL; /* buffer for raw data */
/* VL data special information */
unsigned int vl_data = 0; /* contains VL datatypes */
@@ -3172,18 +3165,20 @@ h5str_dump_simple_mem(JNIEnv *env, FILE *stream, hid_t attr_id, int binary_order
if (H5I_INVALID_HID == (f_space = H5Aget_space(attr_id)))
H5_LIBRARY_ERROR(ENVONLY);
- if ((ndims = H5Sget_simple_extent_ndims(f_space)) < 0)
+ if ((sndims = H5Sget_simple_extent_ndims(f_space)) < 0)
H5_LIBRARY_ERROR(ENVONLY);
if (H5Sget_simple_extent_dims(f_space, total_size, NULL) < 0)
H5_LIBRARY_ERROR(ENVONLY);
if (H5Tequal(f_type, H5T_STD_REF_DSETREG)) {
+ hssize_t p_nelmts; /* total selected elmts */
+
if ((p_nelmts = H5Sget_simple_extent_npoints(f_space)) < 0)
H5_LIBRARY_ERROR(ENVONLY);
if (NULL ==
- (sm_buf = (H5R_ref_t *)HDcalloc(MAX(sizeof(unsigned), sizeof(H5R_ref_t)), (size_t)p_nelmts)))
+ (sm_buf = (unsigned char *)HDcalloc(MAX(sizeof(unsigned), sizeof(H5R_ref_t)), (size_t)p_nelmts)))
H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_dump_simple_mem: failed to allocate sm_buf");
/* Read the data */
@@ -3200,6 +3195,8 @@ h5str_dump_simple_mem(JNIEnv *env, FILE *stream, hid_t attr_id, int binary_order
}
}
else {
+ hsize_t p_nelmts; /* total selected elmts */
+
switch (binary_order) {
case 1: {
if ((p_type = h5str_get_native_type(f_type)) < 0)
@@ -3230,45 +3227,40 @@ h5str_dump_simple_mem(JNIEnv *env, FILE *stream, hid_t attr_id, int binary_order
}
}
- if ((size_t)ndims <= (sizeof(sm_size) / sizeof(sm_size[0]))) {
- if (H5Sget_simple_extent_dims(f_space, total_size, NULL) < 0)
- H5_LIBRARY_ERROR(ENVONLY);
- /* Calculate the number of elements we're going to print */
- p_nelmts = 1;
+ /* Calculate the number of elements we're going to print */
+ p_nelmts = 1;
- if (ndims > 0) {
- for (i = 0; i < (size_t)ndims; i++)
- p_nelmts *= total_size[i];
- } /* end if */
+ if (sndims > 0) {
+ for (i = 0; i < (size_t)sndims; i++)
+ p_nelmts *= total_size[i];
+ } /* end if */
- if (p_nelmts > 0) {
- /* Check if we have VL data in the dataset's datatype */
- if (h5str_detect_vlen(p_type) != 0)
- vl_data = 1;
+ if (p_nelmts > 0) {
+ /* Check if we have VL data in the dataset's datatype */
+ if (h5str_detect_vlen(p_type) != 0)
+ vl_data = 1;
- alloc_size = (size_t)p_nelmts * H5Tget_size(p_type);
- if (NULL == (sm_buf = (unsigned char *)HDmalloc((size_t)alloc_size)))
- H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_dump_simple_mem: failed to allocate sm_buf");
+ alloc_size = (size_t)p_nelmts * H5Tget_size(p_type);
+ if (NULL == (sm_buf = (unsigned char *)HDmalloc((size_t)alloc_size)))
+ H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_dump_simple_mem: failed to allocate sm_buf");
- /* Read the data */
- if (H5Aread(attr_id, p_type, sm_buf) < 0)
- H5_LIBRARY_ERROR(ENVONLY);
+ /* Read the data */
+ if (H5Aread(attr_id, p_type, sm_buf) < 0)
+ H5_LIBRARY_ERROR(ENVONLY);
- if (binary_order == 99) {
- if (h5str_dump_simple_data(ENVONLY, stream, attr_id, p_type, sm_buf, (size_t)p_nelmts) <
- 0)
- CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE);
- }
- else {
- if (h5str_render_bin_output(stream, attr_id, p_type, sm_buf, (size_t)p_nelmts) < 0)
- CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE);
- }
+ if (binary_order == 99) {
+ if (h5str_dump_simple_data(ENVONLY, stream, attr_id, p_type, sm_buf, (size_t)p_nelmts) < 0)
+ CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE);
+ }
+ else {
+ if (h5str_render_bin_output(stream, attr_id, p_type, sm_buf, (size_t)p_nelmts) < 0)
+ CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE);
+ }
- /* Reclaim any VL memory, if necessary */
- if (vl_data) {
- if (H5Treclaim(p_type, f_space, H5P_DEFAULT, sm_buf) < 0)
- H5_LIBRARY_ERROR(ENVONLY);
- }
+ /* Reclaim any VL memory, if necessary */
+ if (vl_data) {
+ if (H5Treclaim(p_type, f_space, H5P_DEFAULT, sm_buf) < 0)
+ H5_LIBRARY_ERROR(ENVONLY);
}
}
}
diff --git a/java/test/TestH5Fparams.java b/java/test/TestH5Fparams.java
index 6accc3b..3fcfe3b 100644
--- a/java/test/TestH5Fparams.java
+++ b/java/test/TestH5Fparams.java
@@ -77,6 +77,7 @@ public class TestH5Fparams {
H5.H5Funmount(-1, null);
}
+ @SuppressWarnings("deprecation")
@Ignore
public void testH5Fis_hdf5_text()
{
diff --git a/java/test/TestH5Ocreate.java b/java/test/TestH5Ocreate.java
index 096abcd..eb57938 100644
--- a/java/test/TestH5Ocreate.java
+++ b/java/test/TestH5Ocreate.java
@@ -449,6 +449,7 @@ public class TestH5Ocreate {
((idata)((H5O_iter_data)iter_data).iterdata.get(3)).link_name.compareToIgnoreCase("G1/DS2") == 0);
}
+ @SuppressWarnings("deprecation")
@Test
public void testH5Ocomment()
{
@@ -479,6 +480,7 @@ public class TestH5Ocreate {
assertTrue("H5Oget_comment: ", obj_comment.compareTo("Test Comment") == 0);
}
+ @SuppressWarnings("deprecation")
@Test
public void testH5Ocomment_clear()
{
@@ -525,6 +527,7 @@ public class TestH5Ocreate {
assertTrue("H5Oget_comment: ", obj_comment == null);
}
+ @SuppressWarnings("deprecation")
@Test
public void testH5Ocomment_by_name()
{
@@ -548,6 +551,7 @@ public class TestH5Ocreate {
assertTrue("H5Oget_comment_by_name: ", obj_comment.compareTo("Test Comment") == 0);
}
+ @SuppressWarnings("deprecation")
@Test
public void testH5Ocomment_by_name_clear()
{
diff --git a/java/test/TestH5Oparams.java b/java/test/TestH5Oparams.java
index 280e9fd..296babc 100644
--- a/java/test/TestH5Oparams.java
+++ b/java/test/TestH5Oparams.java
@@ -168,6 +168,7 @@ public class TestH5Oparams {
H5.H5Ovisit_by_name(-1, "Bogus", -1, -1, null, null, 0, -1);
}
+ @SuppressWarnings("deprecation")
@Test(expected = HDF5LibraryException.class)
public void testH5Oset_comment_invalid() throws Throwable
{
@@ -180,12 +181,14 @@ public class TestH5Oparams {
H5.H5Oget_comment(-1);
}
+ @SuppressWarnings("deprecation")
@Test(expected = HDF5LibraryException.class)
public void testH5Oset_comment_by_name_invalid() throws Throwable
{
H5.H5Oset_comment_by_name(-1, "Bogus", null, -1);
}
+ @SuppressWarnings("deprecation")
@Test(expected = NullPointerException.class)
public void testH5Oset_comment_by_name_null() throws Throwable
{
diff --git a/test/tmisc.c b/test/tmisc.c
index c8da98c..429b275 100644
--- a/test/tmisc.c
+++ b/test/tmisc.c
@@ -3978,7 +3978,7 @@ test_misc22(void)
if ((prec[j] + offsets[k]) > (H5Tget_size(idts[i]) * 8))
continue;
- MESSAGE(5, (" Testing datatypes size=%d precision=%u offset=%d\n", H5Tget_size(idts[i]),
+ MESSAGE(5, (" Testing datatypes size=%zu precision=%u offset=%d\n", H5Tget_size(idts[i]),
(unsigned)prec[j], (unsigned)offsets[k]));
/* Create the DCPL */