[xmlsec] unused variables - Clang complains (Simo Sorce, Red Hat)



commit b4baa10befc8bcdd8a7f91daa68a56ff3940546d
Author: Aleksey Sanin <aleksey aleksey com>
Date:   Wed Jun 4 09:53:02 2014 -0700

    unused variables - Clang complains (Simo Sorce, Red Hat)

 src/keysdata.c        |    2 +-
 src/nss/pkikeys.c     |    9 +++++++
 src/nss/x509vfy.c     |    2 +-
 src/openssl/x509vfy.c |   58 ++++++++++++++++++++++---------------------------
 src/parser.c          |    2 +-
 5 files changed, 38 insertions(+), 35 deletions(-)
---
diff --git a/src/keysdata.c b/src/keysdata.c
index de854ba..0367b16 100644
--- a/src/keysdata.c
+++ b/src/keysdata.c
@@ -255,7 +255,7 @@ xmlSecKeyDataDuplicate(xmlSecKeyDataPtr data) {
     }
 
     ret = (data->id->duplicate)(newData, data);
-    if(newData == NULL) {
+    if(ret < 0) {
         xmlSecError(XMLSEC_ERRORS_HERE,
                     xmlSecErrorsSafeString(xmlSecKeyDataGetName(data)),
                     "id->duplicate",
diff --git a/src/nss/pkikeys.c b/src/nss/pkikeys.c
index ae9e29b..5ede4cc 100644
--- a/src/nss/pkikeys.c
+++ b/src/nss/pkikeys.c
@@ -752,6 +752,15 @@ xmlSecNssKeyDataDsaXmlRead(xmlSecKeyDataId id, xmlSecKeyPtr key,
     }
 
     handle = PK11_ImportPublicKey(slot, pubkey, PR_FALSE);
+    if(handle == CK_INVALID_HANDLE) {
+        xmlSecError(XMLSEC_ERRORS_HERE,
+                    xmlSecErrorsSafeString(xmlSecKeyDataKlassGetName(id)),
+                    "PK11_ImportPublicKey",
+                    XMLSEC_ERRORS_R_CRYPTO_FAILED,
+                    XMLSEC_ERRORS_NO_MESSAGE);
+        ret = -1;
+        goto done;
+    }
 
     data = xmlSecKeyDataCreate(id);
     if(data == NULL ) {
diff --git a/src/nss/x509vfy.c b/src/nss/x509vfy.c
index fdb866f..fecf4ae 100644
--- a/src/nss/x509vfy.c
+++ b/src/nss/x509vfy.c
@@ -603,7 +603,7 @@ xmlSecNssX509NameRead(xmlSecByte *str, int len) {
     xmlSecByte value[256];
     xmlSecByte *retval = NULL;
     xmlSecByte *p = NULL;
-    int nameLen, valueLen;
+    int nameLen, valueLen = 0;
 
     xmlSecAssert2(str != NULL, NULL);
 
diff --git a/src/openssl/x509vfy.c b/src/openssl/x509vfy.c
index ca5a462..06ee566 100644
--- a/src/openssl/x509vfy.c
+++ b/src/openssl/x509vfy.c
@@ -178,7 +178,7 @@ xmlSecOpenSSLX509StoreVerify(xmlSecKeyDataStorePtr store, XMLSEC_STACK_OF_X509*
     X509 * cert;
     X509 * err_cert = NULL;
     char buf[256];
-    int err = 0, depth;
+    int err = 0;
     int i;
     int ret;
 
@@ -287,49 +287,43 @@ xmlSecOpenSSLX509StoreVerify(xmlSecKeyDataStorePtr store, XMLSEC_STACK_OF_X509*
         if(xmlSecOpenSSLX509FindNextChainCert(certs2, cert) == NULL) {
             X509_STORE_CTX xsc;
 
-#if !defined(XMLSEC_OPENSSL_096) && !defined(XMLSEC_OPENSSL_097)
-            X509_VERIFY_PARAM * vpm = NULL;
-            unsigned long vpm_flags = 0;
-
-            vpm = X509_VERIFY_PARAM_new();
-            if(vpm == NULL) {
-                xmlSecError(XMLSEC_ERRORS_HERE,
-                            xmlSecErrorsSafeString(xmlSecKeyDataStoreGetName(store)),
-                            "X509_VERIFY_PARAM_new",
-                            XMLSEC_ERRORS_R_CRYPTO_FAILED,
-                            XMLSEC_ERRORS_NO_MESSAGE);
-                goto done;
-            }
-            vpm_flags = vpm->flags;
-/*
-            vpm_flags &= (~X509_V_FLAG_X509_STRICT);
-*/
-            vpm_flags &= (~X509_V_FLAG_CRL_CHECK);
-
-            X509_VERIFY_PARAM_set_depth(vpm, 9);
-            X509_VERIFY_PARAM_set_flags(vpm, vpm_flags);
-#endif /* !defined(XMLSEC_OPENSSL_096) && !defined(XMLSEC_OPENSSL_097) */
-
-
             X509_STORE_CTX_init (&xsc, ctx->xst, cert, certs2);
-
             if(keyInfoCtx->certsVerificationTime > 0) {
-#if !defined(XMLSEC_OPENSSL_096) && !defined(XMLSEC_OPENSSL_097)
-                vpm_flags |= X509_V_FLAG_USE_CHECK_TIME;
-                X509_VERIFY_PARAM_set_time(vpm, keyInfoCtx->certsVerificationTime);
-#endif /* !defined(XMLSEC_OPENSSL_096) && !defined(XMLSEC_OPENSSL_097) */
                 X509_STORE_CTX_set_time(&xsc, 0, keyInfoCtx->certsVerificationTime);
             }
 
 #if !defined(XMLSEC_OPENSSL_096) && !defined(XMLSEC_OPENSSL_097)
-            X509_STORE_CTX_set0_param(&xsc, vpm);
+            {
+                               X509_VERIFY_PARAM * vpm = NULL;
+                               unsigned long vpm_flags = 0;
+
+                               vpm = X509_VERIFY_PARAM_new();
+                               if(vpm == NULL) {
+                                       xmlSecError(XMLSEC_ERRORS_HERE,
+                                                               
xmlSecErrorsSafeString(xmlSecKeyDataStoreGetName(store)),
+                                                               "X509_VERIFY_PARAM_new",
+                                                               XMLSEC_ERRORS_R_CRYPTO_FAILED,
+                                                               XMLSEC_ERRORS_NO_MESSAGE);
+                                       goto done;
+                               }
+                               vpm_flags = vpm->flags;
+                               vpm_flags &= (~X509_V_FLAG_CRL_CHECK);
+
+                               if(keyInfoCtx->certsVerificationTime > 0) {
+                                       vpm_flags |= X509_V_FLAG_USE_CHECK_TIME;
+                                       X509_VERIFY_PARAM_set_time(vpm, keyInfoCtx->certsVerificationTime);
+                               }
+
+                               X509_VERIFY_PARAM_set_depth(vpm, 9);
+                               X509_VERIFY_PARAM_set_flags(vpm, vpm_flags);
+                               X509_STORE_CTX_set0_param(&xsc, vpm);
+            }
 #endif /* !defined(XMLSEC_OPENSSL_096) && !defined(XMLSEC_OPENSSL_097) */
 
 
             ret         = X509_verify_cert(&xsc);
             err_cert    = X509_STORE_CTX_get_current_cert(&xsc);
             err         = X509_STORE_CTX_get_error(&xsc);
-            depth       = X509_STORE_CTX_get_error_depth(&xsc);
 
             X509_STORE_CTX_cleanup (&xsc);
 
diff --git a/src/parser.c b/src/parser.c
index 990ff98..99ab234 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -317,7 +317,7 @@ xmlSecParserPopXml(xmlSecTransformPtr transform, xmlSecNodeSetPtr* nodes,
     }
 
     ret = inputPush(ctxt, input);
-    if(input == NULL) {
+    if(ret < 0) {
         xmlSecError(XMLSEC_ERRORS_HERE,
                     xmlSecErrorsSafeString(xmlSecTransformGetName(transform)),
                     "inputPush",


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]