changeset 56353:49836127542b

8231222: fix pkcs11 P11_DEBUG guarded native traces Reviewed-by: clanger
author mbaesken
date Mon, 23 Sep 2019 17:02:08 +0200
parents ef8c8cf9256a
children 03fce7b04b42
files src/jdk.crypto.cryptoki/share/native/libj2pkcs11/p11_convert.c src/jdk.crypto.cryptoki/share/native/libj2pkcs11/p11_general.c src/jdk.crypto.cryptoki/share/native/libj2pkcs11/p11_objmgmt.c src/jdk.crypto.cryptoki/share/native/libj2pkcs11/p11_sessmgmt.c src/jdk.crypto.cryptoki/share/native/libj2pkcs11/p11_util.c
diffstat 5 files changed, 23 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.crypto.cryptoki/share/native/libj2pkcs11/p11_convert.c	Fri Sep 20 10:28:48 2019 +0200
+++ b/src/jdk.crypto.cryptoki/share/native/libj2pkcs11/p11_convert.c	Mon Sep 23 17:02:08 2019 +0200
@@ -1179,7 +1179,7 @@
         throwOutOfMemoryError(env, 0);
         return NULL;
     }
-    TRACE1("DEBUG jMechanismToCKMechanismPtr: allocated mech 0x%lX\n", ckpMech);
+    TRACE1("DEBUG jMechanismToCKMechanismPtr: allocated mech %p \n", ckpMech);
 
     ckpMech->mechanism = jLongToCKULong(jMechType);
 
--- a/src/jdk.crypto.cryptoki/share/native/libj2pkcs11/p11_general.c	Fri Sep 20 10:28:48 2019 +0200
+++ b/src/jdk.crypto.cryptoki/share/native/libj2pkcs11/p11_general.c	Mon Sep 23 17:02:08 2019 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
  */
 
 /* Copyright  (c) 2002 Graz University of Technology. All rights reserved.
@@ -98,7 +98,7 @@
 (JNIEnv *env, jclass thisClass, jlong ckpMechanism) {
     if (ckpMechanism != 0L) {
         freeCKMechanismPtr(jlong_to_ptr(ckpMechanism));
-        TRACE1("DEBUG PKCS11_freeMechanism: free pMech = %x\n", ckpMechanism);
+        TRACE1("DEBUG PKCS11_freeMechanism: free pMech = %lld\n", (long long int) ckpMechanism);
     }
     return 0L;
 }
@@ -232,7 +232,10 @@
 
     free(ckpInitArgs);
 
-    if (ckAssertReturnValueOK(env, rv) != CK_ASSERT_OK) { return; }
+    if (ckAssertReturnValueOK(env, rv) != CK_ASSERT_OK) {
+      TRACE1("DEBUG: C_Initialize had a bad return value %lu \n", (unsigned long) rv);
+      return;
+    }
 
     TRACE0("FINISHED\n");
 }
--- a/src/jdk.crypto.cryptoki/share/native/libj2pkcs11/p11_objmgmt.c	Fri Sep 20 10:28:48 2019 +0200
+++ b/src/jdk.crypto.cryptoki/share/native/libj2pkcs11/p11_objmgmt.c	Mon Sep 23 17:02:08 2019 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
  */
 
 /* Copyright  (c) 2002 Graz University of Technology. All rights reserved.
@@ -223,18 +223,18 @@
     if (ckpFunctions == NULL) { return; }
 
     TRACE0("DEBUG: C_GetAttributeValue");
-    TRACE1(", hSession=%u", jSessionHandle);
-    TRACE1(", hObject=%u", jObjectHandle);
+    TRACE1(", hSession=%lld", (long long) jSessionHandle);
+    TRACE1(", hObject=%lld", (long long) jObjectHandle);
     TRACE1(", pTemplate=%p", jTemplate);
     TRACE0(" ... ");
 
     ckSessionHandle = jLongToCKULong(jSessionHandle);
     ckObjectHandle = jLongToCKULong(jObjectHandle);
-    TRACE1("jAttributeArrayToCKAttributeArray now with jTemplate = %d", jTemplate);
+    TRACE1("jAttributeArrayToCKAttributeArray now with jTemplate = %p", jTemplate);
     jAttributeArrayToCKAttributeArray(env, jTemplate, &ckpAttributes, &ckAttributesLength);
     if ((*env)->ExceptionCheck(env)) { return; }
 
-    TRACE2("DEBUG: jAttributeArrayToCKAttributeArray finished with ckpAttribute = %d, Length = %d\n", ckpAttributes, ckAttributesLength);
+    TRACE2("DEBUG: jAttributeArrayToCKAttributeArray finished with ckpAttribute = %p, Length = %lu\n", ckpAttributes, (unsigned long) ckAttributesLength);
 
     /* first set all pValue to NULL, to get the needed buffer length */
     for(i = 0; i < ckAttributesLength; i++) {
@@ -345,7 +345,7 @@
     if (ckpFunctions == NULL) { return; }
 
     TRACE0("DEBUG: C_FindObjectsInit");
-    TRACE1(", hSession=%u", jSessionHandle);
+    TRACE1(", hSession=%lld", (long long int) jSessionHandle);
     TRACE1(", pTemplate=%p", jTemplate);
     TRACE0(" ... ");
 
--- a/src/jdk.crypto.cryptoki/share/native/libj2pkcs11/p11_sessmgmt.c	Fri Sep 20 10:28:48 2019 +0200
+++ b/src/jdk.crypto.cryptoki/share/native/libj2pkcs11/p11_sessmgmt.c	Mon Sep 23 17:02:08 2019 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
  */
 
 /* Copyright  (c) 2002 Graz University of Technology. All rights reserved.
@@ -117,8 +117,8 @@
 #endif /* NO_CALLBACKS */
 
     TRACE0("DEBUG: C_OpenSession");
-    TRACE1(", slotID=%u", ckSlotID);
-    TRACE1(", flags=%x", ckFlags);
+    TRACE1(", slotID=%lu", ckSlotID);
+    TRACE1(", flags=%lu", (unsigned long) ckFlags);
     TRACE0(" ... ");
 
     rv = (*ckpFunctions->C_OpenSession)(ckSlotID, ckFlags, ckpApplication, ckNotify, &ckSessionHandle);
@@ -136,7 +136,7 @@
     }
 
     TRACE0("got session");
-    TRACE1(", SessionHandle=%u", ckSessionHandle);
+    TRACE1(", SessionHandle=%lu", (unsigned long) ckSessionHandle);
     TRACE0(" ... ");
 
     jSessionHandle = ckULongToJLong(ckSessionHandle);
--- a/src/jdk.crypto.cryptoki/share/native/libj2pkcs11/p11_util.c	Fri Sep 20 10:28:48 2019 +0200
+++ b/src/jdk.crypto.cryptoki/share/native/libj2pkcs11/p11_util.c	Mon Sep 23 17:02:08 2019 +0200
@@ -719,16 +719,15 @@
         throwOutOfMemoryError(env, 0);
         return;
     }
-    TRACE1(", converting %d attributes", jLength);
+    TRACE1(", converting %lld attributes", (long long int) jLength);
     for (i=0; i<(*ckpLength); i++) {
-        TRACE1(", getting %d. attribute", i);
+        TRACE1(", getting %lu. attribute", i);
         jAttribute = (*env)->GetObjectArrayElement(env, jArray, i);
         if ((*env)->ExceptionCheck(env)) {
             freeCKAttributeArray(*ckpArray, i);
             return;
         }
-        TRACE1(", jAttribute = %d", jAttribute);
-        TRACE1(", converting %d. attribute", i);
+        TRACE1(", jAttribute , converting %lu. attribute", i);
         (*ckpArray)[i] = jAttributeToCKAttribute(env, jAttribute);
         if ((*env)->ExceptionCheck(env)) {
             freeCKAttributeArray(*ckpArray, i);
@@ -1116,7 +1115,7 @@
     if ((*env)->IsInstanceOf(env, jObject, jLongClass)) {
         ckpObject = jLongObjectToCKULongPtr(env, jObject);
         *ckpLength = sizeof(CK_ULONG);
-        TRACE1("<converted long value %X>", *((CK_ULONG *) ckpObject));
+        TRACE1("<converted long value %lu>", *((CK_ULONG *) ckpObject));
         return ckpObject;
     }
 
@@ -1126,7 +1125,7 @@
         ckpObject = jBooleanObjectToCKBBoolPtr(env, jObject);
         *ckpLength = sizeof(CK_BBOOL);
         TRACE0(" <converted boolean value ");
-        TRACE0((*((CK_BBOOL *) ckpObjectPtr) == TRUE) ? "TRUE>" : "FALSE>");
+        TRACE0((*((CK_BBOOL *) ckpObject) == TRUE) ? "TRUE>" : "FALSE>");
         return ckpObject;
     }
 
@@ -1177,7 +1176,7 @@
     if ((*env)->IsInstanceOf(env, jObject, jIntegerClass)) {
         ckpObject = jIntegerObjectToCKULongPtr(env, jObject);
         *ckpLength = sizeof(CK_ULONG);
-        TRACE1("<converted integer value %X>", *((CK_ULONG *) ckpObject));
+        TRACE1("<converted integer value %lu>", *((CK_ULONG *) ckpObject));
         return ckpObject;
     }