Austin English : crypt32/tests: Make sure to use return values (LLVM/Clang) .

Alexandre Julliard julliard at winehq.org
Thu Feb 10 11:42:08 CST 2011


Module: wine
Branch: master
Commit: f900a8b0353253d22f8ecd1b349feecb3153a74c
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=f900a8b0353253d22f8ecd1b349feecb3153a74c

Author: Austin English <austinenglish at gmail.com>
Date:   Wed Feb  9 13:44:04 2011 -0800

crypt32/tests: Make sure to use return values (LLVM/Clang).

---

 dlls/crypt32/tests/cert.c |   30 ++++++++++++++++++++++--------
 1 files changed, 22 insertions(+), 8 deletions(-)

diff --git a/dlls/crypt32/tests/cert.c b/dlls/crypt32/tests/cert.c
index 9ee53fe..b1a993d 100644
--- a/dlls/crypt32/tests/cert.c
+++ b/dlls/crypt32/tests/cert.c
@@ -487,6 +487,8 @@ static void testCertProperties(void)
     size = sizeof(hashProperty);
     ret = CertGetCertificateContextProperty(context, CERT_HASH_PROP_ID,
      hashProperty, &size);
+    ok(ret, "CertGetCertificateContextProperty failed: %08x\n",
+     GetLastError());
     ok(!memcmp(hashProperty, hash, sizeof(hash)), "Unexpected hash\n");
     /* Delete the (bogus) hash, and get the real one */
     ret = CertSetCertificateContextProperty(context, CERT_HASH_PROP_ID, 0,
@@ -1520,6 +1522,7 @@ static void testGetIssuerCert(void)
     /* Adding an issuer allows one (and only one) issuer to be found */
     ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING,
      chain10_1, sizeof(chain10_1), CERT_STORE_ADD_ALWAYS, &cert1);
+    ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", GetLastError());
     parent = CertGetIssuerCertificateFromStore(store, child, NULL, &flags);
     ok(parent == cert1, "Expected cert1 to be the issuer\n");
     parent = CertGetIssuerCertificateFromStore(store, child, parent, &flags);
@@ -1530,6 +1533,7 @@ static void testGetIssuerCert(void)
      */
     ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING,
      chain10_0, sizeof(chain10_0), CERT_STORE_ADD_ALWAYS, &cert2);
+    ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", GetLastError());
     parent = CertGetIssuerCertificateFromStore(store, child, NULL, &flags);
     ok(parent == cert2, "Expected cert2 to be the first issuer\n");
     parent = CertGetIssuerCertificateFromStore(store, child, parent, &flags);
@@ -1549,11 +1553,13 @@ static void testGetIssuerCert(void)
     /* With only the child certificate, no issuer will be found */
     ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING,
      chain7_1, sizeof(chain7_1), CERT_STORE_ADD_ALWAYS, &child);
+    ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", GetLastError());
     parent = CertGetIssuerCertificateFromStore(store, child, NULL, &flags);
     ok(parent == NULL, "Expected no issuer\n");
     /* Adding an issuer allows one (and only one) issuer to be found */
     ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING,
      chain10_0, sizeof(chain10_0), CERT_STORE_ADD_ALWAYS, &cert1);
+    ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", GetLastError());
     parent = CertGetIssuerCertificateFromStore(store, child, NULL, &flags);
     ok(parent == cert1, "Expected cert1 to be the issuer\n");
     parent = CertGetIssuerCertificateFromStore(store, child, parent, &flags);
@@ -1564,6 +1570,7 @@ static void testGetIssuerCert(void)
      */
     ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING,
      chain10_1, sizeof(chain10_1), CERT_STORE_ADD_ALWAYS, &cert2);
+    ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", GetLastError());
     parent = CertGetIssuerCertificateFromStore(store, child, NULL, &flags);
     ok(parent == cert2, "Expected cert2 to be the first issuer\n");
     parent = CertGetIssuerCertificateFromStore(store, child, parent, &flags);
@@ -2015,6 +2022,8 @@ static void testCreateSelfSignCert(void)
     CryptReleaseContext(csp, 0);
     ret = pCryptAcquireContextA(&csp, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL,
      CRYPT_DELETEKEYSET);
+    ok(ret, "CryptAcquireContext failed: %08x\n", GetLastError());
+
 
     /* do the same test with AT_KEYEXCHANGE  and key info*/
     memset(&info,0,sizeof(info));
@@ -2083,7 +2092,7 @@ static void testIntendedKeyUsage(void)
     if (0)
     {
         /* Crash */
-        ret = CertGetIntendedKeyUsage(0, NULL, NULL, 0);
+        CertGetIntendedKeyUsage(0, NULL, NULL, 0);
     }
     ret = CertGetIntendedKeyUsage(0, &info, NULL, 0);
     ok(!ret, "expected failure\n");
@@ -2093,6 +2102,7 @@ static void testIntendedKeyUsage(void)
     ok(!ret, "expected failure\n");
     ret = CertGetIntendedKeyUsage(X509_ASN_ENCODING, &info, usage_bytes,
      sizeof(usage_bytes));
+    ok(!ret, "expected failure\n");
     info.cExtension = 1;
     info.rgExtension = &ext;
     ret = CertGetIntendedKeyUsage(X509_ASN_ENCODING, &info, NULL, 0);
@@ -2251,6 +2261,8 @@ static void testKeyUsage(void)
         SetLastError(0xbaadcafe);
         size = sizeof(buf);
         ret = CertGetEnhancedKeyUsage(context, 0, pUsage, &size);
+        ok(ret || broken(!ret && GetLastError() == CRYPT_E_NOT_FOUND /* NT4 */),
+	 "CertGetEnhancedKeyUsage failed: %08x\n", GetLastError());
         ok(GetLastError() == CRYPT_E_NOT_FOUND,
          "Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError());
 
@@ -2656,9 +2668,8 @@ static void testIsRDNAttrsInCertificateName(void)
     if (0)
     {
         /* Crash */
-        ret = CertIsRDNAttrsInCertificateName(0, 0, NULL, NULL);
-        ret = CertIsRDNAttrsInCertificateName(X509_ASN_ENCODING, 0, &name,
-         NULL);
+        CertIsRDNAttrsInCertificateName(0, 0, NULL, NULL);
+        CertIsRDNAttrsInCertificateName(X509_ASN_ENCODING, 0, &name, NULL);
     }
     SetLastError(0xdeadbeef);
     ret = CertIsRDNAttrsInCertificateName(0, 0, &name, NULL);
@@ -2932,7 +2943,7 @@ static void testHashToBeSigned(void)
     /* Crash */
     if (0)
     {
-        ret = CryptHashToBeSigned(0, 0, NULL, 0, NULL, NULL);
+        CryptHashToBeSigned(0, 0, NULL, 0, NULL, NULL);
     }
     SetLastError(0xdeadbeef);
     ret = CryptHashToBeSigned(0, 0, NULL, 0, NULL, &size);
@@ -2973,6 +2984,9 @@ static void testHashToBeSigned(void)
 
     ret = CryptHashToBeSigned(0, X509_ASN_ENCODING, md5SignedEmptyCert,
      sizeof(md5SignedEmptyCert), hash, &size);
+    ok(ret || broken(!ret && GetLastError() == NTE_BAD_ALGID) /* NT4 */,
+     "CryptHashToBeSigned failed: %08x\n", GetLastError());
+
     ok(!memcmp(hash, md5SignedEmptyCertHash, size), "unexpected value\n");
 }
 
@@ -2981,9 +2995,9 @@ static void testCompareCert(void)
     CERT_INFO info1 = { 0 }, info2 = { 0 };
     BOOL ret;
 
-    /* Crashes
-    ret = CertCompareCertificate(X509_ASN_ENCODING, NULL, NULL);
-     */
+    /* Crashes */
+    if (0)
+        CertCompareCertificate(X509_ASN_ENCODING, NULL, NULL);
 
     /* Certs with the same issuer and serial number are equal, even if they
      * differ in other respects (like subject).




More information about the wine-cvs mailing list