[glib: 2/6] tests: Add some additional assertions to avoid scan-build warnings
- From: Sebastian Dröge <sdroege src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 2/6] tests: Add some additional assertions to avoid scan-build warnings
- Date: Mon, 19 Oct 2020 10:26:23 +0000 (UTC)
commit 2e7d3dcf7082e7f09b84b62cc68bd6b38bde39f9
Author: Philip Withnall <pwithnall endlessos org>
Date: Wed Oct 14 13:04:44 2020 +0100
tests: Add some additional assertions to avoid scan-build warnings
This should avoid warnings like:
```
../../../glib/tests/regex.c:715:7: warning: Array access (from variable 'matches') results in a null
pointer dereference
g_assert_cmpstr (l_exp->data, ==, matches[i]);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../../glib/gtestutils.h:43:79: note: expanded from macro 'g_assert_cmpstr'
const char *__s1 = (s1), *__s2 = (s2); \
^~~~
../../../glib/tests/regex.c:803:7: warning: Array access (from variable 'tokens') results in a null
pointer dereference
g_assert_cmpstr (l_exp->data, ==, tokens[i]);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../../glib/gtestutils.h:43:79: note: expanded from macro 'g_assert_cmpstr'
const char *__s1 = (s1), *__s2 = (s2); \
^~~~
../../../glib/tests/regex.c:886:7: warning: Array access (from variable 'tokens') results in a null
pointer dereference
g_assert_cmpstr (l_exp->data, ==, tokens[i]);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../../glib/gtestutils.h:43:79: note: expanded from macro 'g_assert_cmpstr'
const char *__s1 = (s1), *__s2 = (s2); \
^~~~
../../../glib/tests/regex.c:918:7: warning: Array access (from variable 'tokens') results in a null
pointer dereference
g_assert_cmpstr (l_exp->data, ==, tokens[i]);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../../glib/gtestutils.h:43:79: note: expanded from macro 'g_assert_cmpstr'
const char *__s1 = (s1), *__s2 = (s2); \
^~~~
```
Signed-off-by: Philip Withnall <pwithnall endlessos org>
glib/tests/regex.c | 4 ++++
1 file changed, 4 insertions(+)
---
diff --git a/glib/tests/regex.c b/glib/tests/regex.c
index ee9cd21ca..1ea6f9288 100644
--- a/glib/tests/regex.c
+++ b/glib/tests/regex.c
@@ -712,6 +712,7 @@ test_fetch_all (gconstpointer d)
l_exp = data->expected;
for (i = 0; l_exp != NULL; i++, l_exp = g_slist_next (l_exp))
{
+ g_assert_nonnull (matches);
g_assert_cmpstr (l_exp->data, ==, matches[i]);
}
@@ -800,6 +801,7 @@ test_split_simple (gconstpointer d)
l_exp = data->expected;
for (i = 0; l_exp != NULL; i++, l_exp = g_slist_next (l_exp))
{
+ g_assert_nonnull (tokens);
g_assert_cmpstr (l_exp->data, ==, tokens[i]);
}
@@ -883,6 +885,7 @@ test_split_full (gconstpointer d)
l_exp = data->expected;
for (i = 0; l_exp != NULL; i++, l_exp = g_slist_next (l_exp))
{
+ g_assert_nonnull (tokens);
g_assert_cmpstr (l_exp->data, ==, tokens[i]);
}
@@ -915,6 +918,7 @@ test_split (gconstpointer d)
l_exp = data->expected;
for (i = 0; l_exp != NULL; i++, l_exp = g_slist_next (l_exp))
{
+ g_assert_nonnull (tokens);
g_assert_cmpstr (l_exp->data, ==, tokens[i]);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]