diff --git a/tests/test-basic-c.c b/tests/test-basic-c.c index 447c46ea..8e7882b9 100644 --- a/tests/test-basic-c.c +++ b/tests/test-basic-c.c @@ -73,7 +73,6 @@ test_raw_file_to_archive_z2_stream (gconstpointer data) &commit_checksum, &error); g_assert_no_error (error); - reachable = ostree_repo_traverse_new_reachable (); ostree_repo_traverse_commit (repo, commit_checksum, -1, diff --git a/tests/test-keyfile-utils.c b/tests/test-keyfile-utils.c index 4bf37578..8fd59163 100644 --- a/tests/test-keyfile-utils.c +++ b/tests/test-keyfile-utils.c @@ -31,7 +31,7 @@ static GKeyFile *g_keyfile; static void test_get_boolean_with_default (void) { - GError *error = NULL; + g_autoptr(GError) error = NULL; gboolean out = FALSE; GLogLevelFlags always_fatal_mask; @@ -46,18 +46,21 @@ test_get_boolean_with_default (void) FALSE, &out, &error)); + g_clear_error (&error); g_assert_false (ot_keyfile_get_boolean_with_default (g_keyfile, NULL, "a_boolean_true", FALSE, &out, &error)); + g_clear_error (&error); g_assert_false (ot_keyfile_get_boolean_with_default (g_keyfile, "section", NULL, FALSE, &out, &error)); + g_clear_error (&error); /* Restore the old mask. */ g_log_set_always_fatal (always_fatal_mask); @@ -86,6 +89,7 @@ test_get_boolean_with_default (void) &error)); g_assert_true (out); + g_clear_error (&error); g_assert_false (ot_keyfile_get_boolean_with_default (g_keyfile, "a_fake_section", "a_boolean_true", @@ -97,8 +101,8 @@ test_get_boolean_with_default (void) static void test_get_value_with_default (void) { - GError *error = NULL; - char *out = NULL; + g_autoptr(GError) error = NULL; + g_autofree char *out = NULL; GLogLevelFlags always_fatal_mask; const char *section = "section"; @@ -112,18 +116,21 @@ test_get_value_with_default (void) "none", &out, &error)); + g_clear_pointer (&out, g_free); g_assert_false (ot_keyfile_get_value_with_default (g_keyfile, section, NULL, "none", &out, &error)); + g_clear_pointer (&out, g_free); g_assert_false (ot_keyfile_get_value_with_default (g_keyfile, section, NULL, "something", &out, &error)); + g_clear_pointer (&out, g_free); /* Restore the old mask. */ g_log_set_always_fatal (always_fatal_mask); @@ -135,6 +142,7 @@ test_get_value_with_default (void) &out, &error)); g_assert_cmpstr (out, ==, "foo"); + g_clear_pointer (&out, g_free); g_assert (ot_keyfile_get_value_with_default (g_keyfile, section, @@ -143,6 +151,7 @@ test_get_value_with_default (void) &out, &error)); g_assert_cmpstr (out, ==, "correct"); + g_clear_pointer (&out, g_free); g_assert_false (ot_keyfile_get_value_with_default (g_keyfile, "a_fake_section", @@ -150,6 +159,8 @@ test_get_value_with_default (void) "no value", &out, &error)); + g_clear_error (&error); + g_clear_pointer (&out, g_free); } static void diff --git a/tests/test-libarchive-import.c b/tests/test-libarchive-import.c index 05c5568d..254d4143 100644 --- a/tests/test-libarchive-import.c +++ b/tests/test-libarchive-import.c @@ -180,7 +180,7 @@ static void test_libarchive_autocreate_empty (gconstpointer data) { TestData *td = (void*)data; - GError *error = NULL; + g_autoptr(GError) error = NULL; struct archive *a = archive_read_new (); OstreeRepoImportArchiveOptions opts = { 0, }; glnx_unref_object OstreeMutableTree *mtree = ostree_mutable_tree_new (); @@ -198,7 +198,7 @@ static void test_libarchive_error_device_file (gconstpointer data) { TestData *td = (void*)data; - GError *error = NULL; + g_autoptr(GError) error = NULL; struct archive *a = archive_read_new (); OstreeRepoImportArchiveOptions opts = { 0, }; glnx_unref_object OstreeMutableTree *mtree = ostree_mutable_tree_new (); @@ -563,6 +563,7 @@ int main (int argc, char **argv) r = g_test_run(); + g_clear_object (&td.repo); if (td.tmpd && g_getenv ("TEST_SKIP_CLEANUP") == NULL) (void) glnx_shutil_rm_rf_at (AT_FDCWD, td.tmpd, NULL, NULL); g_free (td.tmpd); diff --git a/tests/test-pull-c.c b/tests/test-pull-c.c index d784312f..43d5d61d 100644 --- a/tests/test-pull-c.c +++ b/tests/test-pull-c.c @@ -127,6 +127,7 @@ int main (int argc, char **argv) g_test_add_data_func ("/test-pull-c/multi-ok-error-repeat", &td, test_pull_multi_error_then_ok); r = g_test_run(); + g_clear_object (&td.repo); return r; } diff --git a/tests/test-rollsum.c b/tests/test-rollsum.c index 97aeb0ae..1ed99645 100644 --- a/tests/test-rollsum.c +++ b/tests/test-rollsum.c @@ -74,8 +74,8 @@ test_rollsum (void) #define MAX_BUFFER_SIZE 1000000 gsize i; int len; - unsigned char *a = malloc (MAX_BUFFER_SIZE); - unsigned char *b = malloc (MAX_BUFFER_SIZE); + g_autofree unsigned char *a = malloc (MAX_BUFFER_SIZE); + g_autofree unsigned char *b = malloc (MAX_BUFFER_SIZE); g_autoptr(GRand) rand = g_rand_new (); /* These two buffers produce the same crc32. */