From fb36889d29d6674f2fc22319aa416d2588feb2a8 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Wed, 26 Feb 2020 10:33:23 +0100 Subject: [PATCH] gtk.cfg: Fix syntax errors and false positives (#2552) A missing definition for g_assert_cmp*() causes syntax errors if code like g_assert_cmpint(a, ==, b); is encountered. The function g_hash_table_iter_replace() does not have to be marked with leak-ignore since the memory could be freed later if corresponding functions are present in the GHashTable. Since we can not know if this is the case we have to assume that the memory is freed to avoid false positives. The same is true for g_hash_table_insert() and g_hash_table_replace(). --- cfg/gtk.cfg | 26 +++++++++++++++++++++++++- test/cfg/gtk.c | 9 ++++++++- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/cfg/gtk.cfg b/cfg/gtk.cfg index b61c1b8fe..11e1db7df 100644 --- a/cfg/gtk.cfg +++ b/cfg/gtk.cfg @@ -161,6 +161,12 @@ + + + + + + @@ -881,8 +887,19 @@ + false + + + + + + + + + + @@ -5246,9 +5263,16 @@ false + - false + + + + + + + diff --git a/test/cfg/gtk.c b/test/cfg/gtk.c index ae26fbb1b..0f152d286 100644 --- a/test/cfg/gtk.c +++ b/test/cfg/gtk.c @@ -11,8 +11,11 @@ #include -void validCode(int argInt) +void validCode(int argInt, GHashTableIter * hash_table_iter, GHashTable * hash_table) { + g_assert_cmpint(4 + 1, >=, 5); + g_assert_cmpstr("test", ==, "test"); + // if G_UNLIKELY is not defined this results in a syntax error if G_UNLIKELY(argInt == 1) { } else if (G_UNLIKELY(argInt == 2)) { @@ -59,6 +62,10 @@ void validCode(int argInt) gsize result_val = 1; g_once_init_leave(&init_val, result_val); } + + g_hash_table_iter_replace(hash_table_iter, g_strdup("test")); + g_hash_table_insert(hash_table, g_strdup("key"), g_strdup("value")); + g_hash_table_replace(hash_table, g_strdup("key"), g_strdup("value")); } void g_malloc_test()