summaryrefslogtreecommitdiffstats
path: root/java/src/jni/h5vlImp.c
diff options
context:
space:
mode:
authorDana Robinson <derobins@hdfgroup.org>2019-03-31 01:31:11 (GMT)
committerDana Robinson <derobins@hdfgroup.org>2019-03-31 01:31:11 (GMT)
commit6e0d81dc8b65dc078fa31dae50acf96f3ce372e7 (patch)
tree588378063a4eae446ffe0c7e684f4e3aff6af358 /java/src/jni/h5vlImp.c
parentfdbbe61bcf2c5bcbea8a4e08bd6ce8c62f7b43bc (diff)
parent799a732650735b8ad05a0398781d2a26ec47b288 (diff)
downloadhdf5-6e0d81dc8b65dc078fa31dae50acf96f3ce372e7.zip
hdf5-6e0d81dc8b65dc078fa31dae50acf96f3ce372e7.tar.gz
hdf5-6e0d81dc8b65dc078fa31dae50acf96f3ce372e7.tar.bz2
Merge pull request #1629 in HDFFV/hdf5 from ~DEROBINS/hdf5_der:feature/json_vol to feature/json_vol
* commit '799a732650735b8ad05a0398781d2a26ec47b288': (185 commits) Updated the VOL struct. The json_vol test fails, though, because the plugin can't be found. Will diagnose later. Correct examples for packaging HDFFV-10738 Wrong INTENT for H5LTread_dataset_double_f Changes that show the right way to iterate over enums. Changes that show the right way to iterate over enums. Test improvement Description Moved the new tests to a more appropriate test function. Platforms tested: Linux/64 (jelly) Used the H5_INC_ENUM macro to squash enum value increment warnings. Fixed HDFFV-10210 and HDFFV-10587 Description: - Added parameter validation (HDFFV-10210) - Added detection of division by zero (HDFFV-10587 - CVE-2018-17438) - Fixed typos in various tests Platforms tested: Linux/64 (jelly) Linux/64 (platypus) Darwin (osx1011test) Fix CMake error in name Commented out memcpy overlap check while we investigate parallel filters issues. Yanked check for memcpy n > 0 - Added H5MMprivate.h #includes where needed - Added casts to quiet H5MM_memcpy warnings - Removed char * casts from HDmemcpy Added an H5MM_memcpy call that checks for buffer overlap. Added the HDopen work-around on windows to pio_engine.c Adds _wopen support on Windows so that files with UTF-8 names can be opened. CMake: fix pthread linking to only be private Add API routines to retrieve, restore, reset, and free library state. Added a note of bug fix for HDFFV-10705. Fixed the MANIFEST Fix issue with direct chunk write not updating the "last chunk" index cache. Fix issues involving datasets being "no allocated" when they contain cached raw data. ...
Diffstat (limited to 'java/src/jni/h5vlImp.c')
-rw-r--r--java/src/jni/h5vlImp.c157
1 files changed, 86 insertions, 71 deletions
diff --git a/java/src/jni/h5vlImp.c b/java/src/jni/h5vlImp.c
index 89ea703..92e456e 100644
--- a/java/src/jni/h5vlImp.c
+++ b/java/src/jni/h5vlImp.c
@@ -21,9 +21,9 @@
extern "C" {
#endif /* __cplusplus */
-#include "hdf5.h"
#include <jni.h>
#include <stdlib.h>
+#include "hdf5.h"
#include "h5jni.h"
#include "h5vlImp.h"
@@ -36,18 +36,22 @@ JNIEXPORT jlong JNICALL
Java_hdf_hdf5lib_H5_H5VLregister_1connector_1by_1name
(JNIEnv *env, jclass clss, jobject connector_name, jlong vipl_id)
{
- hid_t status = -1;
- const char *vlName;
+ const char *volName = NULL;
+ hid_t status = H5I_INVALID_HID;
- PIN_JAVA_STRING(connector_name, vlName);
- if (vlName != NULL) {
- status = H5VLregister_connector_by_name(vlName, (hid_t)vipl_id);
+ UNUSED(clss);
- UNPIN_JAVA_STRING(connector_name, vlName);
+ if (NULL == connector_name)
+ H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5VLregister_connector_by_name: VOL connector name is NULL");
- if (status < 0)
- h5libraryError(env);
- }
+ PIN_JAVA_STRING(ENVONLY, connector_name, volName, NULL, "H5VLregister_connector_by_name: VOL connector name not pinned");
+
+ if ((status = H5VLregister_connector_by_name(volName, (hid_t)vipl_id)) < 0)
+ H5_LIBRARY_ERROR(ENVONLY);
+
+done:
+ if (volName)
+ UNPIN_JAVA_STRING(ENVONLY, connector_name, volName);
return (jlong)status;
} /* end Java_hdf_hdf5lib_H5_H5VLregister_1connector_1by_1name */
@@ -61,11 +65,14 @@ JNIEXPORT jlong JNICALL
Java_hdf_hdf5lib_H5_H5VLregister_1connector_1by_1value
(JNIEnv *env, jclass clss, jint connector_value, jlong vipl_id)
{
- hid_t status = H5VLregister_connector_by_value((H5VL_class_value_t)connector_value, (hid_t)vipl_id);
+ hid_t status = H5I_INVALID_HID;
+
+ UNUSED(clss);
- if (status < 0)
- h5libraryError(env);
+ if ((status = H5VLregister_connector_by_value((H5VL_class_value_t)connector_value, (hid_t)vipl_id)) < 0)
+ H5_LIBRARY_ERROR(ENVONLY);
+done:
return (jlong)status;
} /* end Java_hdf_hdf5lib_H5_H5VLregister_1connector_1by_1value */
@@ -78,20 +85,24 @@ JNIEXPORT jboolean JNICALL
Java_hdf_hdf5lib_H5_H5VLis_1connector_1registered
(JNIEnv *env, jclass clss, jobject connector_name)
{
+ const char *volName = NULL;
htri_t bval = JNI_FALSE;
- const char *vlName;
- PIN_JAVA_STRING(connector_name, vlName);
- if (vlName != NULL) {
- bval = H5VLis_connector_registered(vlName);
+ UNUSED(clss);
- UNPIN_JAVA_STRING(connector_name, vlName);
+ if (NULL == connector_name)
+ H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5VLis_connector_registered: VOL connector name is NULL");
- if (bval > 0)
- bval = JNI_TRUE;
- else if (bval < 0)
- h5libraryError(env);
- }
+ PIN_JAVA_STRING(ENVONLY, connector_name, volName, NULL, "H5VLis_connector_registered: VOL connector name not pinned");
+
+ if ((bval = H5VLis_connector_registered(volName)) < 0)
+ H5_LIBRARY_ERROR(ENVONLY);
+
+ bval = (bval > 0) ? JNI_TRUE : JNI_FALSE;
+
+done:
+ if (volName)
+ UNPIN_JAVA_STRING(ENVONLY, connector_name, volName);
return (jboolean)bval;
} /* end Java_hdf_hdf5lib_H5_H5VLis_1connector_1registered */
@@ -105,18 +116,22 @@ JNIEXPORT jlong JNICALL
Java_hdf_hdf5lib_H5_H5VLget_1connector_1id
(JNIEnv *env, jclass clss, jobject connector_name)
{
- hid_t status = -1;
- const char *vlName;
+ const char *volName = NULL;
+ hid_t status = H5I_INVALID_HID;
- PIN_JAVA_STRING(connector_name, vlName);
- if (vlName != NULL) {
- status = H5VLget_connector_id(vlName);
+ UNUSED(clss);
- UNPIN_JAVA_STRING(connector_name, vlName);
+ if (NULL == connector_name)
+ H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5VLget_connector_id: VOL connector name is NULL");
- if (status < 0)
- h5libraryError(env);
- }
+ PIN_JAVA_STRING(ENVONLY, connector_name, volName, NULL, "H5VLget_connector_id: VOL connector name not pinned");
+
+ if ((status = H5VLget_connector_id(volName)) < 0)
+ H5_LIBRARY_ERROR(ENVONLY);
+
+done:
+ if (volName)
+ UNPIN_JAVA_STRING(ENVONLY, connector_name, volName);
return (jlong)status;
} /* end Java_hdf_hdf5lib_H5_H5VLget_1connector_1id */
@@ -131,41 +146,31 @@ JNIEXPORT jobject JNICALL
Java_hdf_hdf5lib_H5_H5VLget_1connector_1name
(JNIEnv *env, jclass clss, jlong object_id)
{
- char *vlName;
- ssize_t buf_size;
- ssize_t status;
+ ssize_t buf_size, status;
+ char *volName = NULL;
jstring str = NULL;
- /* get the length of the comment */
- buf_size = H5VLget_connector_name((hid_t)object_id, NULL, 0);
- if (buf_size < 0) {
- H5Eprint2(H5E_DEFAULT, NULL);
-
- h5badArgument(env, "H5VLget_connector_name: buf_size < 0");
- } /* end if */
- else if (buf_size > 0) {
- buf_size++; /* add extra space for the null terminator */
- vlName = (char *)HDmalloc(sizeof(char) * (size_t)buf_size);
- if (vlName == NULL) {
- /* exception -- out of memory */
- h5outOfMemory(env, "H5VLget_connector_name: malloc failed");
- } /* end if */
- else {
- status = H5VLget_connector_name((hid_t)object_id, vlName, (size_t)buf_size);
-
- if (status < 0) {
- h5libraryError(env);
- } /* end if */
- else {
- /* may throw OutOfMemoryError */
- str = ENVPTR->NewStringUTF(ENVPAR vlName);
- if (str == NULL) {
- h5JNIFatalError(env, "H5VLget_connector_name: return string not allocated");
- } /* end if */
- } /* end else */
- HDfree(vlName);
- }
- } /* end else if */
+ UNUSED(clss);
+
+ /* Get the length of the comment */
+ if ((buf_size = H5VLget_connector_name((hid_t)object_id, NULL, 0)) < 0)
+ H5_LIBRARY_ERROR(ENVONLY);
+
+ if (buf_size > 0) {
+ if (NULL == (volName = (char *) HDmalloc(sizeof(char) * (size_t)buf_size + 1)))
+ H5_JNI_FATAL_ERROR(ENVONLY, "H5VLget_connector_name: failed to allocated VOL connector name buffer");
+
+ if ((status = H5VLget_connector_name((hid_t)object_id, volName, (size_t)buf_size + 1)) < 0)
+ H5_LIBRARY_ERROR(ENVONLY);
+ volName[buf_size] = '\0';
+
+ if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, volName)))
+ CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE);
+ }
+
+done:
+ if (volName)
+ HDfree(volName);
return (jstring)str;
} /* end Java_hdf_hdf5lib_H5_H5VLget_1connector_1name */
@@ -179,10 +184,15 @@ JNIEXPORT void JNICALL
Java_hdf_hdf5lib_H5_H5VLclose
(JNIEnv *env, jclass clss, jlong connector_id)
{
- herr_t retValue = H5VLclose((hid_t)connector_id);
+ herr_t retValue = FAIL;
+
+ UNUSED(clss);
+
+ if ((retValue = H5VLclose((hid_t)connector_id)) < 0)
+ H5_LIBRARY_ERROR(ENVONLY);
- if (retValue < 0)
- h5libraryError(env);
+done:
+ return;
} /* end Java_hdf_hdf5lib_H5_H5VLclose */
/*
@@ -194,10 +204,15 @@ JNIEXPORT void JNICALL
Java_hdf_hdf5lib_H5_H5VLunregister_1connector
(JNIEnv *env, jclass clss, jlong connector_id)
{
- herr_t retValue = H5VLunregister_connector((hid_t)connector_id);
+ herr_t retValue = FAIL;
+
+ UNUSED(clss);
+
+ if ((retValue = H5VLunregister_connector((hid_t)connector_id)) < 0)
+ H5_LIBRARY_ERROR(ENVONLY);
- if (retValue < 0)
- h5libraryError(env);
+done:
+ return;
} /* end Java_hdf_hdf5lib_H5_H5VLunregister_1connector */