From 472aef8278e5453528ff8db0668412dcc42ef6f0 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Tue, 31 Dec 2024 12:52:40 +0000 Subject: [PATCH] tests: Add various non-null checks to extended error domain tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This silences various ‘potential null pointer dereference’ warnings from scan-build. Signed-off-by: Philip Withnall --- glib/tests/error.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/glib/tests/error.c b/glib/tests/error.c index 8dd40aa56..cdd6b1e3c 100644 --- a/glib/tests/error.c +++ b/glib/tests/error.c @@ -258,6 +258,8 @@ typedef struct static void test_error_private_init (TestErrorPrivate *priv) { + g_assert_nonnull (priv); + priv->foo = 13; /* If that triggers, it's test bug. */ @@ -272,15 +274,20 @@ static void test_error_private_copy (const TestErrorPrivate *src_priv, TestErrorPrivate *dest_priv) { + g_assert_nonnull (src_priv); + g_assert_nonnull (dest_priv); + dest_priv->foo = src_priv->foo; dest_priv->check = src_priv->check; + g_assert_nonnull (dest_priv->check); dest_priv->check->copy_called++; } static void test_error_private_clear (TestErrorPrivate *priv) { + g_assert_nonnull (priv->check); priv->check->free_called++; } @@ -291,6 +298,7 @@ fill_test_error (GError *error, TestErrorCheck *check) { TestErrorPrivate *test_error = test_error_get_private (error); + g_assert_nonnull (test_error); test_error->check = check; return test_error; @@ -326,6 +334,7 @@ test_extended (void) g_assert_cmpstr (error->message, ==, copy_error->message); copy_test_priv = test_error_get_private (copy_error); + g_assert_nonnull (copy_test_priv); g_assert_cmpint (test_priv->foo, ==, copy_test_priv->foo); g_error_free (error);