[glib: 5/8] Fix several signedness warnings in tests/testglib.c
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 5/8] Fix several signedness warnings in tests/testglib.c
- Date: Thu, 6 May 2021 16:43:22 +0000 (UTC)
commit 4d3c741ddb2f9bddb6e1a78c24b42d28f57660bd
Author: Emmanuel Fleury <emmanuel fleury gmail com>
Date: Fri Nov 20 22:28:07 2020 +0100
Fix several signedness warnings in tests/testglib.c
tests/testglib.c: In function ‘gnode_test’:
tests/testglib.c:302:34: error: comparison of integer expressions of different signedness: ‘char’ and
‘guint’ {aka ‘unsigned int’}
302 | g_assert (P2C (node->data) == ('C' + i));
| ^~
glib/gmacros.h:941:25: note: in definition of macro ‘G_LIKELY’
941 | #define G_LIKELY(expr) (expr)
| ^~~~
tests/testglib.c:302:7: note: in expansion of macro ‘g_assert’
302 | g_assert (P2C (node->data) == ('C' + i));
| ^~~~~~~~
tests/testglib.c:306:76: error: comparison of integer expressions of different signedness: ‘gint’ {aka
‘int’} and ‘guint’ {aka ‘unsigned int’}
306 | g_assert (g_node_child_position (node_G, g_node_nth_child (node_G, i)) == i);
| ^~
glib/gmacros.h:941:25: note: in definition of macro ‘G_LIKELY’
941 | #define G_LIKELY(expr) (expr)
| ^~~~
tests/testglib.c:306:5: note: in expansion of macro ‘g_assert’
306 | g_assert (g_node_child_position (node_G, g_node_nth_child (node_G, i)) == i);
| ^~~~~~~~
tests/testglib.c: In function ‘test_arrays’:
tests/testglib.c:1316:41: error: comparison of integer expressions of different signedness: ‘gint’ {aka
‘int’} and ‘guint’ {aka ‘unsigned int’}
1316 | if (g_array_index (garray, gint, i) != i)
| ^~
tests/testglib.c:1324:41: error: comparison of integer expressions of different signedness: ‘gint’ {aka
‘int’} and ‘guint’ {aka ‘unsigned int’}
1324 | if (g_array_index (garray, gint, i) != (100 - i - 1))
| ^~
tests/testglib.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/tests/testglib.c b/tests/testglib.c
index 926010e5d..071afdc1d 100644
--- a/tests/testglib.c
+++ b/tests/testglib.c
@@ -299,11 +299,11 @@ gnode_test (void)
for (i = 0; i < g_node_n_children (node_B); i++)
{
node = g_node_nth_child (node_B, i);
- g_assert (P2C (node->data) == ('C' + i));
+ g_assert (P2C (node->data) == (gchar) ('C' + i));
}
for (i = 0; i < g_node_n_children (node_G); i++)
- g_assert (g_node_child_position (node_G, g_node_nth_child (node_G, i)) == i);
+ g_assert (g_node_child_position (node_G, g_node_nth_child (node_G, i)) == (gint) i);
/* we have built: A
* / \
@@ -1313,7 +1313,7 @@ test_arrays (void)
for (i = 0; i < 10000; i++)
g_array_append_val (garray, i);
for (i = 0; i < 10000; i++)
- if (g_array_index (garray, gint, i) != i)
+ if (g_array_index (garray, gint, i) != (gint) i)
g_error ("failure: %d ( %d )", g_array_index (garray, gint, i), i);
g_array_free (garray, TRUE);
@@ -1321,7 +1321,7 @@ test_arrays (void)
for (i = 0; i < 100; i++)
g_array_prepend_val (garray, i);
for (i = 0; i < 100; i++)
- if (g_array_index (garray, gint, i) != (100 - i - 1))
+ if (g_array_index (garray, gint, i) != (gint) (100 - i - 1))
g_error ("failure: %d ( %d )", g_array_index (garray, gint, i), 100 - i - 1);
g_array_free (garray, TRUE);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]