From 2b8407a3ca541a491fd71efb92ac182f412959d4 Mon Sep 17 00:00:00 2001
From: Allen Byrne <byrn@hdfgroup.org>
Date: Tue, 24 Mar 2020 17:42:58 -0500
Subject: Fix Werror issues in JNI and tools

---
 config/gnu-warnings/error-general | 4 +---
 java/src/jni/h5aImp.c             | 5 +++--
 java/src/jni/h5eImp.c             | 5 +++--
 java/src/jni/h5lImp.c             | 5 +++--
 java/src/jni/h5oImp.c             | 5 +++--
 tools/lib/h5diff_array.c          | 1 -
 6 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/config/gnu-warnings/error-general b/config/gnu-warnings/error-general
index 5f7e4e1..d747b7d 100644
--- a/config/gnu-warnings/error-general
+++ b/config/gnu-warnings/error-general
@@ -14,6 +14,7 @@
 #-Werror=discarded-qualifiers
 -Werror=missing-declarations
 -Werror=missing-prototypes
+-Werror=unused-but-set-variable
 #
 # NOTE: File Driver files are not compatible with these warnings as errors
 #     H5FDdirect.c,H5FDmpio.c,H5FDros3.c,
@@ -31,9 +32,6 @@
 #     lib/h5tools.c
 #       -Werror=cast-align
 -Wcast-align
-#     lib/h5diff_array.c
-#       -Werror=unused-but-set-variable
--Werror=unused-but-set-variable
 #     lib/h5tools_utils.c
 #       -Werror=unused-parameter
 #
diff --git a/java/src/jni/h5aImp.c b/java/src/jni/h5aImp.c
index 0da763c..8b3f9e5 100644
--- a/java/src/jni/h5aImp.c
+++ b/java/src/jni/h5aImp.c
@@ -2167,6 +2167,7 @@ H5A_iterate_cb
     jobject     visit_callback = wrapper->visit_callback;
     jstring     str;
     JNIEnv     *cbenv = NULL;
+    jclass      cbcls;
     jvalue      args[4];
     void       *op_data = (void *)wrapper->op_data;
     jint        status = -1;
@@ -2176,10 +2177,10 @@ H5A_iterate_cb
         H5_JNI_FATAL_ERROR(CBENVONLY, "H5A_iterate_cb: failed to attach current thread to JVM");
     }
 
-    if (NULL == (cls = CBENVPTR->GetObjectClass(CBENVONLY, visit_callback)))
+    if (NULL == (cbcls = CBENVPTR->GetObjectClass(CBENVONLY, visit_callback)))
         CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE);
 
-    if (NULL == (mid = CBENVPTR->GetMethodID(CBENVONLY, cls, "callback", "(JLjava/lang/String;Lhdf/hdf5lib/structs/H5A_info_t;Lhdf/hdf5lib/callbacks/H5A_iterate_t;)I")))
+    if (NULL == (mid = CBENVPTR->GetMethodID(CBENVONLY, cbcls, "callback", "(JLjava/lang/String;Lhdf/hdf5lib/structs/H5A_info_t;Lhdf/hdf5lib/callbacks/H5A_iterate_t;)I")))
         CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE);
 
     if (NULL == (str = CBENVPTR->NewStringUTF(CBENVONLY, name)))
diff --git a/java/src/jni/h5eImp.c b/java/src/jni/h5eImp.c
index 1e12f66..80e23a1 100644
--- a/java/src/jni/h5eImp.c
+++ b/java/src/jni/h5eImp.c
@@ -523,6 +523,7 @@ H5E_walk_cb
     jobject     cb_info_t = NULL;
     jvalue      args[7];
     JNIEnv     *cbenv = NULL;
+    jclass      cbcls;
     void       *op_data = (void *)wrapper->op_data;
     jint        status = FAIL;
 
@@ -531,10 +532,10 @@ H5E_walk_cb
         H5_JNI_FATAL_ERROR(CBENVONLY, "H5E_walk_cb: failed to attach current thread to JVM");
     }
 
-    if (NULL == (cls = CBENVPTR->GetObjectClass(CBENVONLY, visit_callback)))
+    if (NULL == (cbcls = CBENVPTR->GetObjectClass(CBENVONLY, visit_callback)))
         CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE);
 
-    if (NULL == (mid = CBENVPTR->GetMethodID(CBENVONLY, cls, "callback", "(ILhdf/hdf5lib/structs/H5E_error2_t;Lhdf/hdf5lib/callbacks/H5E_walk_t;)I")))
+    if (NULL == (mid = CBENVPTR->GetMethodID(CBENVONLY, cbcls, "callback", "(ILhdf/hdf5lib/structs/H5E_error2_t;Lhdf/hdf5lib/callbacks/H5E_walk_t;)I")))
         CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE);
 
     args[0].j = info->cls_id;
diff --git a/java/src/jni/h5lImp.c b/java/src/jni/h5lImp.c
index 6606664..b5312bd 100644
--- a/java/src/jni/h5lImp.c
+++ b/java/src/jni/h5lImp.c
@@ -672,6 +672,7 @@ H5L_iterate_cb
     jobject     visit_callback = wrapper->visit_callback;
     jstring     str;
     JNIEnv     *cbenv = NULL;
+    jclass      cbcls;
     jvalue      args[5];
     void       *op_data = (void *)wrapper->op_data;
     jint        status = -1;
@@ -682,10 +683,10 @@ H5L_iterate_cb
     }
 
     /* Get the Method ID for the "callback" function of the H5L_iterate_t class */
-    if (NULL == (cls = CBENVPTR->GetObjectClass(CBENVONLY, visit_callback)))
+    if (NULL == (cbcls = CBENVPTR->GetObjectClass(CBENVONLY, visit_callback)))
         CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE);
 
-    if (NULL == (mid = CBENVPTR->GetMethodID(CBENVONLY, cls, "callback", "(JLjava/lang/String;Lhdf/hdf5lib/structs/H5L_info_t;Lhdf/hdf5lib/callbacks/H5L_iterate_opdata_t;)I")))
+    if (NULL == (mid = CBENVPTR->GetMethodID(CBENVONLY, cbcls, "callback", "(JLjava/lang/String;Lhdf/hdf5lib/structs/H5L_info_t;Lhdf/hdf5lib/callbacks/H5L_iterate_opdata_t;)I")))
         CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE);
 
     if (NULL == (str = CBENVPTR->NewStringUTF(CBENVONLY, name)))
diff --git a/java/src/jni/h5oImp.c b/java/src/jni/h5oImp.c
index 08482d1..33bec85 100644
--- a/java/src/jni/h5oImp.c
+++ b/java/src/jni/h5oImp.c
@@ -548,6 +548,7 @@ H5O_iterate_cb
     jobject     token;
     jstring     str;
     JNIEnv     *cbenv = NULL;
+    jclass      cbcls;
     jvalue      args[12];
     void       *op_data = (void *)wrapper->op_data;
     jint        status = FAIL;
@@ -557,10 +558,10 @@ H5O_iterate_cb
         H5_JNI_FATAL_ERROR(CBENVONLY, "H5O_iterate_cb: failed to attach current thread to JVM");
     }
 
-    if (NULL == (cls = CBENVPTR->GetObjectClass(CBENVONLY, visit_callback)))
+    if (NULL == (cbcls = CBENVPTR->GetObjectClass(CBENVONLY, visit_callback)))
         CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE);
 
-    if (NULL == (mid = CBENVPTR->GetMethodID(CBENVONLY, cls, "callback", "(JLjava/lang/String;Lhdf/hdf5lib/structs/H5O_info_t;Lhdf/hdf5lib/callbacks/H5O_iterate_opdata_t;)I")))
+    if (NULL == (mid = CBENVPTR->GetMethodID(CBENVONLY, cbcls, "callback", "(JLjava/lang/String;Lhdf/hdf5lib/structs/H5O_info_t;Lhdf/hdf5lib/callbacks/H5O_iterate_opdata_t;)I")))
         CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE);
 
     if (NULL == (str = CBENVPTR->NewStringUTF(CBENVONLY, name)))
diff --git a/tools/lib/h5diff_array.c b/tools/lib/h5diff_array.c
index 52bae51..094f3d1 100644
--- a/tools/lib/h5diff_array.c
+++ b/tools/lib/h5diff_array.c
@@ -2539,7 +2539,6 @@ static hsize_t character_compare_opt(unsigned char *mem1, unsigned char *mem2,
     unsigned char temp1_uchar;
     unsigned char temp2_uchar;
     double        per;
-    hbool_t       both_zero;
 
     HDmemcpy(&temp1_uchar, mem1, sizeof(unsigned char));
     HDmemcpy(&temp2_uchar, mem2, sizeof(unsigned char));
-- 
cgit v0.12