From 3951ccffae110b6fb22436a828f14322cfaa125a Mon Sep 17 00:00:00 2001 From: Emmanuel Fleury Date: Fri, 20 Nov 2020 22:52:46 +0100 Subject: [PATCH 1/7] Fix signedness warning in tests/thread-test.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit tests/thread-test.c: In function ‘test_g_static_private’: tests/thread-test.c:214:60: error: comparison of integer expressions of different signedness: ‘int’ and ‘guint’ {aka ‘unsigned int’} 214 | g_assert (GPOINTER_TO_INT (g_thread_join (threads[i])) == i * 3); | ^~ glib/gmacros.h:941:25: note: in definition of macro ‘G_LIKELY’ 941 | #define G_LIKELY(expr) (expr) | ^~~~ tests/thread-test.c:214:5: note: in expansion of macro ‘g_assert’ 214 | g_assert (GPOINTER_TO_INT (g_thread_join (threads[i])) == i * 3); | ^~~~~~~~ --- tests/thread-test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/thread-test.c b/tests/thread-test.c index 17ac41f7b..883aa5424 100644 --- a/tests/thread-test.c +++ b/tests/thread-test.c @@ -211,7 +211,7 @@ test_g_static_private (void) test_g_static_private_ready = 0; for (i = 0; i < THREADS; i++) - g_assert (GPOINTER_TO_INT (g_thread_join (threads[i])) == i * 3); + g_assert (GPOINTER_TO_UINT (g_thread_join (threads[i])) == i * 3); g_assert (test_g_static_private_counter == 0); } From 951105fae5fbfef9d37db67f2612bc4e61937298 Mon Sep 17 00:00:00 2001 From: Emmanuel Fleury Date: Fri, 20 Nov 2020 22:59:12 +0100 Subject: [PATCH 2/7] Fix several signedness warnings in tests/threadpool-test.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit tests/threadpool-test.c: In function ‘test_thread_sort’: tests/threadpool-test.c:283:17: error: comparison of integer expressions of different signedness: ‘gint’ {aka ‘int’} and ‘guint’ {aka ‘unsigned int’} 283 | for (i = 0; i < limit; i++) { | ^ tests/threadpool-test.c:296:50: error: comparison of integer expressions of different signedness: ‘gint’ {aka ‘int’} and ‘guint’ {aka ‘unsigned int’} 296 | g_assert (g_thread_pool_get_max_threads (pool) == max_threads); | ^~ glib/gmacros.h:941:25: note: in definition of macro ‘G_LIKELY’ 941 | #define G_LIKELY(expr) (expr) | ^~~~ tests/threadpool-test.c:296:3: note: in expansion of macro ‘g_assert’ 296 | g_assert (g_thread_pool_get_max_threads (pool) == max_threads); | ^~~~~~~~ tests/threadpool-test.c:297:50: error: comparison of integer expressions of different signedness: ‘guint’ {aka ‘unsigned int’} and ‘gint’ {aka ‘int’} 297 | g_assert (g_thread_pool_get_num_threads (pool) == g_thread_pool_get_max_threads (pool)); | ^~ glib/gmacros.h:941:25: note: in definition of macro ‘G_LIKELY’ 941 | #define G_LIKELY(expr) (expr) | ^~~~ tests/threadpool-test.c:297:3: note: in expansion of macro ‘g_assert’ 297 | g_assert (g_thread_pool_get_num_threads (pool) == g_thread_pool_get_max_threads (pool)); | ^~~~~~~~ tests/threadpool-test.c: In function ‘test_thread_idle_time’: tests/threadpool-test.c:355:17: error: comparison of integer expressions of different signedness: ‘gint’ {aka ‘int’} and ‘guint’ {aka ‘unsigned int’} 355 | for (i = 0; i < limit; i++) { | ^ --- tests/threadpool-test.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/threadpool-test.c b/tests/threadpool-test.c index dfd138212..1612e274e 100644 --- a/tests/threadpool-test.c +++ b/tests/threadpool-test.c @@ -248,7 +248,7 @@ test_thread_sort (gboolean sort) GThreadPool *pool; guint limit; guint max_threads; - gint i; + guint i; limit = MAX_THREADS * 10; @@ -293,8 +293,8 @@ test_thread_sort (gboolean sort) g_thread_pool_unprocessed (pool))); } - g_assert (g_thread_pool_get_max_threads (pool) == max_threads); - g_assert (g_thread_pool_get_num_threads (pool) == g_thread_pool_get_max_threads (pool)); + g_assert (g_thread_pool_get_max_threads (pool) == (gint) max_threads); + g_assert (g_thread_pool_get_num_threads (pool) == (guint) g_thread_pool_get_max_threads (pool)); g_thread_pool_free (pool, TRUE, TRUE); } @@ -337,7 +337,7 @@ test_thread_idle_time (void) { guint limit = 50; guint interval = 10000; - gint i; + guint i; idle_pool = g_thread_pool_new (test_thread_idle_time_entry_func, NULL, From 53157f32b90905c49a4f9894bcb81034e37628f0 Mon Sep 17 00:00:00 2001 From: Emmanuel Fleury Date: Fri, 20 Nov 2020 23:13:17 +0100 Subject: [PATCH 3/7] Fix several signedness warnings in tests/unicode-encoding.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit tests/unicode-encoding.c: In function ‘process’: tests/unicode-encoding.c:140:38: error: comparison of integer expressions of different signedness: ‘glong’ {aka ‘long int’} and ‘size_t’ {aka ‘long unsigned int’} 140 | if (!ucs4_result || items_read == strlen (utf8)) | ^~ tests/unicode-encoding.c:161:15: error: comparison of integer expressions of different signedness: ‘glong’ {aka ‘long int’} and ‘size_t’ {aka ‘long unsigned int’} 161 | items_read != strlen (utf8) || | ^~ tests/unicode-encoding.c:198:18: error: comparison of integer expressions of different signedness: ‘glong’ {aka ‘long int’} and ‘size_t’ {aka ‘long unsigned int’} 198 | items_written != strlen (utf8)) | ^~ tests/unicode-encoding.c:260:22: error: comparison of integer expressions of different signedness: ‘glong’ {aka ‘long int’} and ‘size_t’ {aka ‘long unsigned int’} 260 | if (items_read != strlen (utf8) || | ^~ tests/unicode-encoding.c:294:18: error: comparison of integer expressions of different signedness: ‘glong’ {aka ‘long int’} and ‘size_t’ {aka ‘long unsigned int’} 294 | items_written != strlen (utf8)) | ^~ --- tests/unicode-encoding.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/unicode-encoding.c b/tests/unicode-encoding.c index c729b284d..b0603d105 100644 --- a/tests/unicode-encoding.c +++ b/tests/unicode-encoding.c @@ -137,7 +137,7 @@ process (gint line, ucs4_result = g_utf8_to_ucs4 (utf8, -1, &items_read, NULL, &error); - if (!ucs4_result || items_read == strlen (utf8)) + if (!ucs4_result || items_read == (glong) strlen (utf8)) { fail ("line %d: incomplete input not properly detected\n", line); return; @@ -158,7 +158,7 @@ process (gint line, } if (!ucs4_equal (ucs4_result, ucs4) || - items_read != strlen (utf8) || + items_read != (glong) strlen (utf8) || items_written != ucs4_len) { fail ("line %d: results of conversion with status %d to ucs4 do not match expected.\n", line, status); @@ -195,7 +195,7 @@ process (gint line, if (strcmp (utf8_result, utf8) != 0 || items_read != ucs4_len || - items_written != strlen (utf8)) + items_written != (glong) strlen (utf8)) { fail ("line %d: conversion back to utf8 did not match original\n", line); return; @@ -257,7 +257,7 @@ process (gint line, return; } - if (items_read != strlen (utf8) || + if (items_read != (glong) strlen (utf8) || utf16_count (utf16_from_utf8) != items_written) { fail ("line %d: length error in conversion to ucs16\n", line); @@ -291,7 +291,7 @@ process (gint line, } if (items_read != utf16_count (utf16_from_utf8) || - items_written != strlen (utf8)) + items_written != (glong) strlen (utf8)) { fail ("line %d: length error in conversion from ucs16 to utf8\n", line); return; From 00a15152f39943413ca9ed107e6f5870fa227075 Mon Sep 17 00:00:00 2001 From: Emmanuel Fleury Date: Fri, 20 Nov 2020 23:17:07 +0100 Subject: [PATCH 4/7] Fix signedness warning in tests/memchunks.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit tests/memchunks.c: In function ‘old_mem_chunk_new’: tests/memchunks.c:140:35: error: comparison of integer expressions of different signedness: ‘gulong’ {aka ‘long unsigned int’} and ‘gint’ {aka ‘int’} 140 | g_return_val_if_fail (area_size >= atom_size, NULL); | ^~ --- tests/memchunks.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/memchunks.c b/tests/memchunks.c index fae7c4107..f574ed8b0 100644 --- a/tests/memchunks.c +++ b/tests/memchunks.c @@ -49,7 +49,7 @@ static guint mem_chunk_recursion = 0; /* --- old memchunk prototypes --- */ GMemChunk* old_mem_chunk_new (const gchar *name, - gint atom_size, + gulong atom_size, gulong area_size, gint type); void old_mem_chunk_destroy (GMemChunk *mem_chunk); @@ -129,7 +129,7 @@ static GMemChunk *mem_chunks = NULL; GMemChunk* old_mem_chunk_new (const gchar *name, - gint atom_size, + gulong atom_size, gulong area_size, gint type) { From e3453f39dd898f384b5702d4a6362bcc9973868b Mon Sep 17 00:00:00 2001 From: Emmanuel Fleury Date: Tue, 2 Feb 2021 18:19:37 +0100 Subject: [PATCH 5/7] Fix missing initializer in gio/tests/fake-service-name.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit gio/tests/fake-service-name.c:55:1: error: missing initializer for field ‘padding’ of ‘GDBusInterfaceVTable’ {aka ‘const struct _GDBusInterfaceVTable’} 55 | }; | ^ --- gio/tests/fake-service-name.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gio/tests/fake-service-name.c b/gio/tests/fake-service-name.c index 1a601a50c..c3a61180c 100644 --- a/gio/tests/fake-service-name.c +++ b/gio/tests/fake-service-name.c @@ -51,7 +51,8 @@ incoming_method_call (GDBusConnection *connection, static const GDBusInterfaceVTable interface_vtable = { incoming_method_call, NULL, - NULL + NULL, + { 0 } }; static void From 83d46f6a0ac453ea343bf90951f39a38ae669425 Mon Sep 17 00:00:00 2001 From: Emmanuel Fleury Date: Wed, 28 Apr 2021 10:44:40 +0200 Subject: [PATCH 6/7] Fix missing field initializer in glib/deprecated/gthread.h glib/deprecated/gthread-deprecated.c:473:42: warning: missing field 'unused' initializer static const GStaticMutex init_mutex = G_STATIC_MUTEX_INIT; ^ glib/deprecated/gthread.h:128:36: note: expanded from macro 'G_STATIC_MUTEX_INIT' ^ glib/deprecated/gthread-deprecated.c:659:45: warning: missing field 'unused' initializer static const GStaticRecMutex init_mutex = G_STATIC_REC_MUTEX_INIT; ^ glib/deprecated/gthread.h:170:35: note: expanded from macro 'G_STATIC_REC_MUTEX_INIT' ^ glib/deprecated/gthread.h:128:36: note: expanded from macro 'G_STATIC_MUTEX_INIT' ^ glib/deprecated/gthread-deprecated.c:959:42: warning: missing field 'unused' initializer static const GStaticRWLock init_lock = G_STATIC_RW_LOCK_INIT; ^ glib/deprecated/gthread.h:206:33: note: expanded from macro 'G_STATIC_RW_LOCK_INIT' ^ glib/deprecated/gthread.h:128:36: note: expanded from macro 'G_STATIC_MUTEX_INIT' ^ --- glib/deprecated/gthread.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/glib/deprecated/gthread.h b/glib/deprecated/gthread.h index 33b422240..2d490a110 100644 --- a/glib/deprecated/gthread.h +++ b/glib/deprecated/gthread.h @@ -125,7 +125,11 @@ void g_thread_foreach (GFunc thread_func, #endif #define g_static_mutex_get_mutex g_static_mutex_get_mutex_impl GLIB_DEPRECATED_MACRO_IN_2_32 +#ifndef G_OS_WIN32 +#define G_STATIC_MUTEX_INIT { NULL, PTHREAD_MUTEX_INITIALIZER } GLIB_DEPRECATED_MACRO_IN_2_32_FOR(g_mutex_init) +#else #define G_STATIC_MUTEX_INIT { NULL } GLIB_DEPRECATED_MACRO_IN_2_32_FOR(g_mutex_init) +#endif typedef struct { GMutex *mutex; From 9656e606d236aec470fc24353443459bc05b02ca Mon Sep 17 00:00:00 2001 From: Emmanuel Fleury Date: Wed, 28 Apr 2021 13:04:49 +0200 Subject: [PATCH 7/7] Fix cast to smaller integer type warning in glib/gscanner.c glib/gscanner.c:1681:13: warning: cast to smaller integer type 'GTokenType' from 'gpointer' (aka 'void *') *token_p = (GTokenType) value_p->v_symbol; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --- glib/gscanner.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glib/gscanner.c b/glib/gscanner.c index c858abf9e..9102b3a92 100644 --- a/glib/gscanner.c +++ b/glib/gscanner.c @@ -1678,7 +1678,7 @@ g_scanner_get_token_i (GScanner *scanner, case G_TOKEN_SYMBOL: if (scanner->config->symbol_2_token) - *token_p = (GTokenType) value_p->v_symbol; + *token_p = (GTokenType) ((size_t) value_p->v_symbol); break; case G_TOKEN_BINARY: