From 8341a1cf064b628d57bfed46fbfb14e810ddf265 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Mon, 24 Oct 2022 21:33:18 +0200 Subject: [PATCH 1/2] tests/sequence: Ensure iterator is set and actually checked Clang was complaining: ../glib/tests/sequence.c:125:7: warning: variable 'i' set but not used int i; ^ 1 warning generated. --- glib/tests/sequence.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/glib/tests/sequence.c b/glib/tests/sequence.c index 842bc5435..5cf0b415a 100644 --- a/glib/tests/sequence.c +++ b/glib/tests/sequence.c @@ -122,7 +122,7 @@ check_integrity (SequenceInfo *info) { GList *list; GSequenceIter *iter; - int i; + unsigned int i; g_sequence_check (info->sequence); @@ -149,6 +149,7 @@ check_integrity (SequenceInfo *info) i++; } + g_assert_cmpuint (i, ==, info->n_items); g_assert (info->n_items == g_queue_get_length (info->queue)); g_assert ((guint) g_sequence_get_length (info->sequence) == info->n_items); } From 0de22a8864a70a25de2a8e5b76dd5d377235597e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Mon, 24 Oct 2022 21:34:35 +0200 Subject: [PATCH 2/2] tests/strfuncs: Do not compare string literal with pointers Otherwise clang would complain: ../glib/tests/strfuncs.c:2603:32: warning: result of comparison against a string literal is unspecified (use an explicit string comparison function instead) [-Wstring-compare] g_assert_true ((gpointer)str != (gpointer)""); ^ ~~~~~~~~~~~~ ../glib/gtestutils.h:187:59: note: expanded from macro 'g_assert_true' if G_LIKELY (expr) ; else \ ^~~~ ../glib/gmacros.h:1186:59: note: expanded from macro 'G_LIKELY' #define G_LIKELY(expr) (__builtin_expect (_G_BOOLEAN_EXPR(expr), 1)) ^~~~ ../glib/gmacros.h:1180:8: note: expanded from macro '_G_BOOLEAN_EXPR' if (expr) --- glib/tests/strfuncs.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/glib/tests/strfuncs.c b/glib/tests/strfuncs.c index 6c0d43090..cc7d9c211 100644 --- a/glib/tests/strfuncs.c +++ b/glib/tests/strfuncs.c @@ -2593,20 +2593,21 @@ static void test_set_str (void) { char *str = NULL; + const char *empty_str = ""; g_assert_false (g_set_str (&str, NULL)); g_assert_null (str); - g_assert_true (g_set_str (&str, "")); - g_assert_false (g_set_str (&str, "")); + g_assert_true (g_set_str (&str, empty_str)); + g_assert_false (g_set_str (&str, empty_str)); g_assert_nonnull (str); - g_assert_true ((gpointer)str != (gpointer)""); - g_assert_cmpstr (str, ==, ""); + g_assert_true ((gpointer)str != (gpointer)empty_str); + g_assert_cmpstr (str, ==, empty_str); g_assert_true (g_set_str (&str, NULL)); g_assert_null (str); - g_assert_true (g_set_str (&str, "")); + g_assert_true (g_set_str (&str, empty_str)); g_assert_true (g_set_str (&str, "test")); g_assert_cmpstr (str, ==, "test");