]> granicus.if.org Git - p11-kit/commitdiff
Fix mostly erroneous scanner warnings in tests
authorStef Walter <stef@thewalter.net>
Fri, 8 Aug 2014 15:18:10 +0000 (17:18 +0200)
committerStef Walter <stef@thewalter.net>
Fri, 8 Aug 2014 16:44:49 +0000 (18:44 +0200)
common/tests/test-array.c
common/tests/test-dict.c
common/tests/test-tests.c
p11-kit/tests/test-deprecated.c
p11-kit/tests/test-uri.c
trust/tests/frob-bc.c
trust/tests/frob-eku.c
trust/tests/frob-ext.c
trust/tests/frob-ku.c
trust/tests/frob-oid.c
trust/tests/test-token.c

index 8e8f9966e8b212ee9d3f83db71494d3231961055..695917a12f18559e38cdde53db5f303aa6ec5c48 100644 (file)
@@ -151,6 +151,7 @@ test_remove_and_count (void)
 
        for (i = 0; i < 20000; ++i) {
                value = malloc (sizeof (int));
+               assert (value != NULL);
                *value = i;
                if (!p11_array_push (array, value))
                        assert_not_reached ();
index 7c6f8513307fa32b0b3b834af0289e5ff9e64dab..f12a34e125bd93bc3d43359c017980c98777f805 100644 (file)
@@ -426,6 +426,7 @@ test_hash_add_check_lots_and_collisions (void)
 
        for (i = 0; i < 20000; ++i) {
                value = malloc (sizeof (int));
+               assert (value != NULL);
                *value = i;
                if (!p11_dict_set (map, value, value))
                        assert_not_reached ();
@@ -454,6 +455,7 @@ test_hash_count (void)
 
        for (i = 0; i < 20000; ++i) {
                value = malloc (sizeof (int));
+               assert (value != NULL);
                *value = i;
                if (!p11_dict_set (map, value, value))
                        assert_not_reached ();
@@ -483,6 +485,7 @@ test_hash_ulongptr (void)
 
        for (i = 0; i < 20000; ++i) {
                value = malloc (sizeof (unsigned long));
+               assert (value != NULL);
                *value = i;
                if (!p11_dict_set (map, value, value))
                        assert_not_reached ();
index cd48a13b94c03e820534e74462cd7cd57df6ac04..ba31d83534e2eabfe63b43931ec9435cc9d35cd9 100644 (file)
@@ -60,6 +60,7 @@ test_memory (void)
 
        if (getenv ("TEST_FAIL")) {
                mem = malloc (1);
+               assert (mem != NULL);
                free (mem);
                *mem = 1;
        }
@@ -73,6 +74,7 @@ test_leak (void)
 
        if (getenv ("TEST_FAIL")) {
                mem = malloc (1);
+               assert (mem != NULL);
                *mem = 1;
        }
 }
index 56f1941db05e044f3438bb699bcfa1f7f500a099..c8b80014a1a08b9dd216a77cd38a851c5ced3b3a 100644 (file)
@@ -376,8 +376,10 @@ test_threaded_initialization (void)
        module.C_Initialize = mock_C_Initialize__threaded_race;
        module.C_Finalize = mock_C_Finalize__threaded_race;
 
+       p11_mutex_lock (&race_mutex);
        initialization_count = 0;
        finalization_count = 0;
+       p11_mutex_unlock (&race_mutex);
 
        for (i = 0; i < num_threads; i++) {
                ret = p11_thread_create (&threads[i], initialization_thread, "thread-data");
@@ -404,8 +406,10 @@ test_threaded_initialization (void)
        }
 
        /* C_Initialize should have been called exactly once */
+       p11_mutex_lock (&race_mutex);
        assert_num_eq (1, initialization_count);
        assert_num_eq (1, finalization_count);
+       p11_mutex_unlock (&race_mutex);
 
        assert (!mock_module_initialized ());
 }
@@ -478,7 +482,7 @@ test_load_and_initialize (void)
        assert (ret == 0);
 
        rv = p11_kit_finalize_module (module);
-       assert (ret == CKR_OK);
+       assert_num_eq (rv, CKR_OK);
 }
 
 int
index b6de7ada0ed87fa9d98e32e6678e7682f2c659c5..9b5b293102f9a916e53c8f6645a9b02a47684e8c 100644 (file)
@@ -537,17 +537,20 @@ test_uri_build_with_attributes (void)
        at.pValue = "The Label";
        at.ulValueLen = 9;
        ret = p11_kit_uri_set_attribute (uri, &at);
+       assert_num_eq (P11_KIT_URI_OK, ret);
 
        at.type = CKA_ID;
        at.pValue = "HELLO";
        at.ulValueLen = 5;
        ret = p11_kit_uri_set_attribute (uri, &at);
+       assert_num_eq (P11_KIT_URI_OK, ret);
 
        klass = CKO_DATA;
        at.type = CKA_CLASS;
        at.pValue = &klass;
        at.ulValueLen = sizeof (klass);
        ret = p11_kit_uri_set_attribute (uri, &at);
+       assert_num_eq (P11_KIT_URI_OK, ret);
 
        ret = p11_kit_uri_format (uri, P11_KIT_URI_FOR_ANY, &string);
        assert_num_eq (P11_KIT_URI_OK, ret);
index 762f8c5c1853869bb1609f53d8488286773114c1..41fbc58c3fd6ab88108ba9b7219805091794f14a 100644 (file)
@@ -87,6 +87,7 @@ main (int argc,
        ret = asn1_der_coding (ext, "", buf, &len, message);
        if (ret != ASN1_SUCCESS) {
                fprintf (stderr, "asn1_der_coding: %s\n", message);
+               free (buf);
                return 1;
        }
 
index 5cc58290f9ead92434c2ceb108e4121f57be67a2..f467b3620249566e29fe7e06ac96f4e86179e78c 100644 (file)
@@ -88,6 +88,7 @@ main (int argc,
        ret = asn1_der_coding (ekus, "", buf, &len, message);
        if (ret != ASN1_SUCCESS) {
                fprintf (stderr, "asn1_der_coding: %s\n", message);
+               free (buf);
                return 1;
        }
 
index b1b5dd5a718b4725bf803dfc14625e7ed11aafa6..201720591a0dc4fbfbb904d698229bf113f2e455 100644 (file)
@@ -104,6 +104,7 @@ main (int argc,
        ret = asn1_der_coding (ext, "", buf, &len, message);
        if (ret != ASN1_SUCCESS) {
                fprintf (stderr, "asn1_der_coding: %s\n", message);
+               free (buf);
                return 1;
        }
 
index 00d45c614454501caf5653b26fbd0c10499b0600..99ac217ef4d1f0189d6aa895e95723f079876c4a 100644 (file)
@@ -111,11 +111,13 @@ main (int argc,
        ret = asn1_der_coding (ku, "", buf, &len, message);
        if (ret != ASN1_SUCCESS) {
                fprintf (stderr, "asn1_der_coding: %s\n", message);
+               free (buf);
                return 1;
        }
 
        fwrite (buf, 1, len, stdout);
        fflush (stdout);
+       free (buf);
 
        asn1_delete_structure (&ku);
        asn1_delete_structure (&definitions);
index b4c7658e4dd4f6b9bdec3387e78056ca31821e25..5a2499a3fcb53f4f57fcda5ef3cadb9337570c7d 100644 (file)
@@ -87,11 +87,13 @@ main (int argc,
        ret = asn1_der_coding (oid, "", buf, &len, message);
        if (ret != ASN1_SUCCESS) {
                fprintf (stderr, "asn1_der_coding: %s\n", message);
+               free (buf);
                return 1;
        }
 
        fwrite (buf, 1, len, stdout);
        fflush (stdout);
+       free (buf);
 
        asn1_delete_structure (&oid);
        asn1_delete_structure (&definitions);
index f4367c3000acc6241d529b09653fb0dd4468fc64..a24539e2719126c71a28b84eada98af744d66c11 100644 (file)
@@ -91,8 +91,8 @@ static void
 teardown_temp (void *unused)
 {
        p11_test_directory_delete (test.directory);
-       free (test.directory);
        teardown (test.directory);
+       free (test.directory);
 }
 
 static void