tests: Add various non-null checks to extended error domain tests

This silences various ‘potential null pointer dereference’ warnings from
scan-build.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
This commit is contained in:
Philip Withnall 2024-12-31 12:52:40 +00:00
parent 1ab1cd6ba4
commit 472aef8278
No known key found for this signature in database
GPG Key ID: C5C42CFB268637CA

View File

@ -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);