]> granicus.if.org Git - p11-kit/commitdiff
build: Suppress cppcheck errors
authorDaiki Ueno <dueno@redhat.com>
Thu, 22 Nov 2018 15:19:52 +0000 (16:19 +0100)
committerDaiki Ueno <ueno@gnu.org>
Thu, 22 Nov 2018 17:17:17 +0000 (18:17 +0100)
common/test-tests.c
common/test.c
p11-kit/server.c
trust/test-bundle.c
trust/test-openssl.c
trust/test-save.c
trust/test-trust.c

index ba31d83534e2eabfe63b43931ec9435cc9d35cd9..2ca19298ed97c35b65f5cf6ce8812599292ec312 100644 (file)
@@ -62,6 +62,7 @@ test_memory (void)
                mem = malloc (1);
                assert (mem != NULL);
                free (mem);
+               /* cppcheck-suppress deallocuse */
                *mem = 1;
        }
 }
@@ -77,6 +78,7 @@ test_leak (void)
                assert (mem != NULL);
                *mem = 1;
        }
+       /* cppcheck-suppress memleak */
 }
 
 int
index 18cb50188ad4e00ca42b927f141e36aba018e2f2..c88aff14d126eab35badb7b44693d4f983830627 100644 (file)
@@ -457,6 +457,7 @@ p11_test_directory (const char *prefix)
                        directory, strerror (errno));
                free (directory);
                assert_not_reached ();
+               return NULL;
        }
 
        free (templ);
@@ -483,6 +484,7 @@ p11_test_file_write (const char *base,
                printf ("# couldn't open file for writing: %s: %s\n", name, strerror (errno));
                free (path);
                assert_not_reached ();
+               return;
        }
 
        if (fwrite (contents, 1, length, f) != length ||
@@ -490,6 +492,7 @@ p11_test_file_write (const char *base,
                printf ("# couldn't write to file: %s: %s\n", name, strerror (errno));
                free (path);
                assert_not_reached ();
+               return;
        }
 
        free (path);
@@ -511,6 +514,7 @@ p11_test_file_delete (const char *base,
                printf ("# Couldn't delete file: %s\n", name);
                free (path);
                assert_not_reached ();
+               return;
        }
 
        free (path);
index a737c2a822568022563f008088d019a0ad224d4b..75b93d667d3f09127968bb17091ecc4dfe3143d2 100644 (file)
@@ -147,13 +147,17 @@ server_new (const char **tokens, size_t n_tokens, const char *provider,
        if (strncmp (tokens[0], "pkcs11:", 7) == 0) {
                if (server->provider) {
                        server->module = p11_kit_module_load (server->provider, 0);
-                       if (server->module == NULL)
+                       if (server->module == NULL) {
+                               free (server);
                                return NULL;
+                       }
                }
        } else {
                server->module = p11_kit_module_load (tokens[0], 0);
-               if (server->module == NULL)
+               if (server->module == NULL) {
+                       free (server);
                        return NULL;
+               }
        }
 #endif /* OS_WIN32 */
 
index 3f4bcad437959336077b3ced79cedcfb987edb05..f1c28416d8c28fcac32476677c948fcbe2142420 100644 (file)
@@ -236,11 +236,14 @@ test_directory_hash (void)
        ret = p11_extract_pem_directory_hash (&test.ex, test.directory);
        assert_num_eq (true, ret);
 
-       test_check_directory (test.directory, ("Cacert3_Here.pem", "Cacert3_Here.1.pem",
 #ifdef OS_UNIX
-                                           "e5662767.1", "e5662767.0", "590d426f.1", "590d426f.0",
+       test_check_directory (test.directory, ("Cacert3_Here.pem", "Cacert3_Here.1.pem",
+                                              "e5662767.1", "e5662767.0", "590d426f.1", "590d426f.0",
+                                              NULL));
+#else
+       test_check_directory (test.directory, ("Cacert3_Here.pem", "Cacert3_Here.1.pem",
+                                              NULL));
 #endif
-                                           NULL));
        test_check_file (test.directory, "Cacert3_Here.pem", SRCDIR "/trust/fixtures/cacert3.pem");
        test_check_file (test.directory, "Cacert3_Here.1.pem", SRCDIR "/trust/fixtures/cacert3.pem");
 #ifdef OS_UNIX
index b1276dfb534ab6afb407a17a55fdf0781cc70684..3c20625ebb09ea08f78c43bd3b3c00f977bdfeb0 100644 (file)
@@ -595,11 +595,14 @@ test_directory (void)
        ret = p11_extract_openssl_directory (&test.ex, test.directory);
        assert_num_eq (true, ret);
 
-       test_check_directory (test.directory, ("Custom_Label.pem", "Custom_Label.1.pem",
 #ifdef OS_UNIX
-                                                  "e5662767.1", "e5662767.0", "590d426f.1", "590d426f.0",
+       test_check_directory (test.directory, ("Custom_Label.pem", "Custom_Label.1.pem",
+                                              "e5662767.1", "e5662767.0", "590d426f.1", "590d426f.0",
+                                              NULL));
+#else
+       test_check_directory (test.directory, ("Custom_Label.pem", "Custom_Label.1.pem",
+                                              NULL));
 #endif
-                                                  NULL));
        test_check_file (test.directory, "Custom_Label.pem",
                         SRCDIR "/trust/fixtures/cacert3-trusted-server-alias.pem");
        test_check_file (test.directory, "Custom_Label.1.pem",
index 1de798d3a2683db0e330d2955e5d0aea84e334c4..0609e7933049afd089e19a27efa97aac303faf82 100644 (file)
@@ -357,11 +357,14 @@ test_directory_files (void)
        ret = p11_save_finish_directory (dir, true);
        assert_num_eq (true, ret);
 
-       test_check_directory (subdir, ("blah.cer", "file.txt",
 #ifdef OS_UNIX
+       test_check_directory (subdir, ("blah.cer", "file.txt",
                              "link.ext",
-#endif
                              NULL));
+#else
+       test_check_directory (subdir, ("blah.cer", "file.txt",
+                             NULL));
+#endif
        test_check_file (subdir, "blah.cer", SRCDIR "/trust/fixtures/cacert3.der");
        test_check_data (subdir, "file.txt", test_text, strlen (test_text));
 #ifdef OS_UNIX
@@ -443,13 +446,18 @@ test_directory_dups (void)
        ret = p11_save_finish_directory (dir, true);
        assert_num_eq (true, ret);
 
-       test_check_directory (subdir, ("file.txt", "file.1.txt", "file.2.txt",
-                                          "no-ext", "no-ext.1",
-                                          "with-num.0", "with-num.1",
 #ifdef OS_UNIX
-                                          "link.0", "link.1",
+       test_check_directory (subdir, ("file.txt", "file.1.txt", "file.2.txt",
+                                      "no-ext", "no-ext.1",
+                                      "with-num.0", "with-num.1",
+                                      "link.0", "link.1",
+                                      NULL));
+#else
+       test_check_directory (subdir, ("file.txt", "file.1.txt", "file.2.txt",
+                                      "no-ext", "no-ext.1",
+                                      "with-num.0", "with-num.1",
+                                      NULL));
 #endif
-                                          NULL));
        test_check_data (subdir, "file.txt", test_text, 5);
        test_check_data (subdir, "file.1.txt", test_text, 10);
        test_check_data (subdir, "file.2.txt", test_text, 15);
index 802007d087f510d7dc6eb6d78aa1a3ba0108e480..29b2797b5b898602630565d2aa5181831e107420 100644 (file)
@@ -283,8 +283,10 @@ test_check_directory_files (const char *file,
        va_start (va, file);
 
        while (file != NULL) {
-               if (!p11_dict_set (files, (void *)file, (void *)file))
+               if (!p11_dict_set (files, (void *)file, (void *)file)) {
+                       va_end (va);
                        return_val_if_reached (NULL);
+               }
                file = va_arg (va, const char *);
        }