mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-03-12 10:45:13 +01:00
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:
parent
1ab1cd6ba4
commit
472aef8278
@ -258,6 +258,8 @@ typedef struct
|
|||||||
static void
|
static void
|
||||||
test_error_private_init (TestErrorPrivate *priv)
|
test_error_private_init (TestErrorPrivate *priv)
|
||||||
{
|
{
|
||||||
|
g_assert_nonnull (priv);
|
||||||
|
|
||||||
priv->foo = 13;
|
priv->foo = 13;
|
||||||
/* If that triggers, it's test bug.
|
/* If that triggers, it's test bug.
|
||||||
*/
|
*/
|
||||||
@ -272,15 +274,20 @@ static void
|
|||||||
test_error_private_copy (const TestErrorPrivate *src_priv,
|
test_error_private_copy (const TestErrorPrivate *src_priv,
|
||||||
TestErrorPrivate *dest_priv)
|
TestErrorPrivate *dest_priv)
|
||||||
{
|
{
|
||||||
|
g_assert_nonnull (src_priv);
|
||||||
|
g_assert_nonnull (dest_priv);
|
||||||
|
|
||||||
dest_priv->foo = src_priv->foo;
|
dest_priv->foo = src_priv->foo;
|
||||||
dest_priv->check = src_priv->check;
|
dest_priv->check = src_priv->check;
|
||||||
|
|
||||||
|
g_assert_nonnull (dest_priv->check);
|
||||||
dest_priv->check->copy_called++;
|
dest_priv->check->copy_called++;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_error_private_clear (TestErrorPrivate *priv)
|
test_error_private_clear (TestErrorPrivate *priv)
|
||||||
{
|
{
|
||||||
|
g_assert_nonnull (priv->check);
|
||||||
priv->check->free_called++;
|
priv->check->free_called++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -291,6 +298,7 @@ fill_test_error (GError *error, TestErrorCheck *check)
|
|||||||
{
|
{
|
||||||
TestErrorPrivate *test_error = test_error_get_private (error);
|
TestErrorPrivate *test_error = test_error_get_private (error);
|
||||||
|
|
||||||
|
g_assert_nonnull (test_error);
|
||||||
test_error->check = check;
|
test_error->check = check;
|
||||||
|
|
||||||
return test_error;
|
return test_error;
|
||||||
@ -326,6 +334,7 @@ test_extended (void)
|
|||||||
g_assert_cmpstr (error->message, ==, copy_error->message);
|
g_assert_cmpstr (error->message, ==, copy_error->message);
|
||||||
|
|
||||||
copy_test_priv = test_error_get_private (copy_error);
|
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_assert_cmpint (test_priv->foo, ==, copy_test_priv->foo);
|
||||||
|
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user