This is an automated email from the ASF dual-hosted git repository.
sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-crypto.git
The following commit(s) were added to refs/heads/master by this push:
new 8a4fb5b1 Rework code
8a4fb5b1 is described below
commit 8a4fb5b124037c2a0a44f5c7ffb5989ada26567f
Author: Sebb <[email protected]>
AuthorDate: Wed Dec 6 17:58:30 2023 +0000
Rework code
---
.../java/org/apache/commons/crypto/jna/OpenSslMacOS.java | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/src/main/java/org/apache/commons/crypto/jna/OpenSslMacOS.java
b/src/main/java/org/apache/commons/crypto/jna/OpenSslMacOS.java
index b4165de7..38b3334f 100644
--- a/src/main/java/org/apache/commons/crypto/jna/OpenSslMacOS.java
+++ b/src/main/java/org/apache/commons/crypto/jna/OpenSslMacOS.java
@@ -26,7 +26,13 @@ import com.sun.jna.Native;
*/
class OpenSslMacOS {
- static native boolean dlopen_preflight(String path);
+ /*
+ * The method is declared as 'bool dlopen_preflight(const char* path)',
which is not a standard
+ * JNA type, see:
+ *
http://java-native-access.github.io/jna/5.13.0/javadoc/overview-summary.html#marshalling
+ * bool appears to be closest to a byte, where non-zero is true and zero
is false
+ */
+ static native byte dlopen_preflight(String path);
static native String dlerror();
@@ -40,10 +46,9 @@ class OpenSslMacOS {
* @return null if OK, else error message
*/
public static String checkLibrary(String path) {
- if (dlopen_preflight(path)){
- return null;
- }
- return dlerror();
+ boolean loadedOK = dlopen_preflight(path) != 0;
+ String dlerror = dlerror(); // fetch error, and clear for next call
+ return loadedOK ? null : dlerror;
}
}