From a9652620045172cafd2f863df8b3260ccde6b469 Mon Sep 17 00:00:00 2001 From: Emmanuel Fleury Date: Fri, 20 Nov 2020 19:58:20 +0100 Subject: [PATCH 1/8] Fix several signedness warnings in gio/tests/unix-streams.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit gio/tests/unix-streams.c: In function ‘test_write_async_wouldblock’: gio/tests/unix-streams.c:692:17: error: comparison of integer expressions of different signedness: ‘guint’ {aka ‘unsigned int’} and ‘gint’ {aka ‘int’} 692 | for (i = 0; i < 4 * pipe_capacity; i++) | ^ gio/tests/unix-streams.c: In function ‘test_writev_async_wouldblock’: gio/tests/unix-streams.c:780:17: error: comparison of integer expressions of different signedness: ‘guint’ {aka ‘unsigned int’} and ‘gint’ {aka ‘int’} 780 | for (i = 0; i < 4 * pipe_capacity; i++) | ^ --- gio/tests/unix-streams.c | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/gio/tests/unix-streams.c b/gio/tests/unix-streams.c index 5ec829919..407a67dbd 100644 --- a/gio/tests/unix-streams.c +++ b/gio/tests/unix-streams.c @@ -474,8 +474,9 @@ test_write_wouldblock (void) gint fd[2]; GError *err = NULL; guint8 data_write[1024], data_read[1024]; - guint i; - gint pipe_capacity; + gsize i; + int retval; + gsize pipe_capacity; for (i = 0; i < sizeof (data_write); i++) data_write[i] = i; @@ -483,7 +484,9 @@ test_write_wouldblock (void) g_assert_cmpint (pipe (fd), ==, 0); g_assert_cmpint (fcntl (fd[0], F_SETPIPE_SZ, 4096, NULL), !=, 0); - pipe_capacity = fcntl (fd[0], F_GETPIPE_SZ, &pipe_capacity, NULL); + retval = fcntl (fd[0], F_GETPIPE_SZ); + g_assert_cmpint (retval, >=, 0); + pipe_capacity = (gsize) retval; g_assert_cmpint (pipe_capacity, >=, 4096); g_assert_cmpint (pipe_capacity % 1024, >=, 0); @@ -552,10 +555,11 @@ test_writev_wouldblock (void) gint fd[2]; GError *err = NULL; guint8 data_write[1024], data_read[1024]; - guint i; + gsize i; + int retval; + gsize pipe_capacity; GOutputVector vectors[4]; GPollableReturn res; - gint pipe_capacity; for (i = 0; i < sizeof (data_write); i++) data_write[i] = i; @@ -563,7 +567,9 @@ test_writev_wouldblock (void) g_assert_cmpint (pipe (fd), ==, 0); g_assert_cmpint (fcntl (fd[0], F_SETPIPE_SZ, 4096, NULL), !=, 0); - pipe_capacity = fcntl (fd[0], F_GETPIPE_SZ, &pipe_capacity, NULL); + retval = fcntl (fd[0], F_GETPIPE_SZ); + g_assert_cmpint (retval, >=, 0); + pipe_capacity = (gsize) retval; g_assert_cmpint (pipe_capacity, >=, 4096); g_assert_cmpint (pipe_capacity % 1024, >=, 0); @@ -667,8 +673,9 @@ test_write_async_wouldblock (void) GUnixOutputStream *os; gint fd[2]; guint8 *data, *data_read; - guint i; - gint pipe_capacity; + gsize i; + int retval; + gsize pipe_capacity; gsize bytes_written = 0, bytes_read = 0; g_assert_cmpint (pipe (fd), ==, 0); @@ -685,7 +692,9 @@ test_write_async_wouldblock (void) g_unix_set_fd_nonblocking (fd[1], TRUE, NULL); g_assert_cmpint (fcntl (fd[0], F_SETPIPE_SZ, 4096, NULL), !=, 0); - pipe_capacity = fcntl (fd[0], F_GETPIPE_SZ, &pipe_capacity, NULL); + retval = fcntl (fd[0], F_GETPIPE_SZ); + g_assert_cmpint (retval, >=, 0); + pipe_capacity = (gsize) retval; g_assert_cmpint (pipe_capacity, >=, 4096); data = g_new (guint8, 4 * pipe_capacity); @@ -754,8 +763,9 @@ test_writev_async_wouldblock (void) GUnixOutputStream *os; gint fd[2]; guint8 *data, *data_read; - guint i; - gint pipe_capacity; + gsize i; + int retval; + gsize pipe_capacity; gsize bytes_written = 0, bytes_read = 0; GOutputVector vectors[4]; @@ -773,7 +783,9 @@ test_writev_async_wouldblock (void) g_unix_set_fd_nonblocking (fd[1], TRUE, NULL); g_assert_cmpint (fcntl (fd[0], F_SETPIPE_SZ, 4096, NULL), !=, 0); - pipe_capacity = fcntl (fd[0], F_GETPIPE_SZ, &pipe_capacity, NULL); + retval = fcntl (fd[0], F_GETPIPE_SZ); + g_assert_cmpint (retval, >=, 0); + pipe_capacity = (gsize) retval; g_assert_cmpint (pipe_capacity, >=, 4096); data = g_new (guint8, 4 * pipe_capacity); From 4ad62f7fab017e3562256d82971ab9fdf13fb81b Mon Sep 17 00:00:00 2001 From: Emmanuel Fleury Date: Fri, 20 Nov 2020 20:29:28 +0100 Subject: [PATCH 2/8] Fix signedness warning in gio/tests/readwrite.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit gio/tests/readwrite.c: In function ‘verify_iostream’: gio/tests/readwrite.c:77:17: error: comparison of integer expressions of different signedness: ‘gboolean’ {aka ‘int’} and ‘size_t’ {aka ‘long unsigned int’} 77 | g_assert (res == strlen (original_data) - 15); | ^~ --- gio/tests/readwrite.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gio/tests/readwrite.c b/gio/tests/readwrite.c index 2aa925b30..7551e5384 100644 --- a/gio/tests/readwrite.c +++ b/gio/tests/readwrite.c @@ -32,6 +32,7 @@ static void verify_iostream (GFileIOStream *file_iostream) { gboolean res; + gssize skipped; GIOStream *iostream; GError *error; GInputStream *in; @@ -73,8 +74,9 @@ verify_iostream (GFileIOStream *file_iostream) g_assert (res == 5); verify_pos (iostream, 15); - res = g_input_stream_skip (in, 10000, NULL, NULL); - g_assert (res == strlen (original_data) - 15); + skipped = g_input_stream_skip (in, 10000, NULL, NULL); + g_assert_cmpint (skipped, >=, 0); + g_assert ((gsize) skipped == strlen (original_data) - 15); verify_pos (iostream, strlen (original_data)); res = g_seekable_seek (G_SEEKABLE (iostream), From 4a503bdbd7dd8e6f5560bfb8808fb8c705027f46 Mon Sep 17 00:00:00 2001 From: Emmanuel Fleury Date: Fri, 20 Nov 2020 20:08:47 +0100 Subject: [PATCH 3/8] Fix several missing initializer warnings in gio/tests/dbus-appinfo.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit gio/tests/dbus-appinfo.c:177:3: error: missing initializer for field ‘parameter_type’ of ‘GActionEntry’ {aka ‘const struct _GActionEntry’} 177 | { "frob", test_application_frob }, | ^ gio/tests/dbus-appinfo.c:178:3: error: missing initializer for field ‘parameter_type’ of ‘GActionEntry’ {aka ‘const struct _GActionEntry’} 178 | { "tweak", test_application_tweak }, | ^ gio/tests/dbus-appinfo.c:179:3: error: missing initializer for field ‘parameter_type’ of ‘GActionEntry’ {aka ‘const struct _GActionEntry’} 179 | { "twiddle", test_application_twiddle }, | ^ gio/tests/dbus-appinfo.c:180:3: error: missing initializer for field ‘parameter_type’ of ‘GActionEntry’ {aka ‘const struct _GActionEntry’} 180 | { "quit", test_application_quit } | ^ --- gio/tests/dbus-appinfo.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gio/tests/dbus-appinfo.c b/gio/tests/dbus-appinfo.c index 7e2fc4d79..86bdfebee 100644 --- a/gio/tests/dbus-appinfo.c +++ b/gio/tests/dbus-appinfo.c @@ -174,10 +174,10 @@ test_application_quit (GSimpleAction *action, } static const GActionEntry app_actions[] = { - { "frob", test_application_frob }, - { "tweak", test_application_tweak }, - { "twiddle", test_application_twiddle }, - { "quit", test_application_quit } + { "frob", test_application_frob, NULL, NULL, NULL, { 0 } }, + { "tweak", test_application_tweak, NULL, NULL, NULL, { 0 } }, + { "twiddle", test_application_twiddle, NULL, NULL, NULL, { 0 } }, + { "quit", test_application_quit, NULL, NULL, NULL, { 0 } } }; static void From 180c1a18d9d9ffc81a8a3d7aad26d07410443ed9 Mon Sep 17 00:00:00 2001 From: Emmanuel Fleury Date: Fri, 20 Nov 2020 20:11:05 +0100 Subject: [PATCH 4/8] Fix several missing initializer warnings in gio/tests/basic-application.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit gio/tests/basic-application.c: In function ‘startup’: gio/tests/basic-application.c:57:5: error: missing initializer for field ‘padding’ of ‘GActionEntry’ {aka ‘struct _GActionEntry’} 57 | { "new", new_activated, NULL, NULL, NULL }, | ^ gio/tests/basic-application.c:58:5: error: missing initializer for field ‘padding’ of ‘GActionEntry’ {aka ‘struct _GActionEntry’} 58 | { "quit", quit_activated, NULL, NULL, NULL }, | ^ gio/tests/basic-application.c:59:5: error: missing initializer for field ‘padding’ of ‘GActionEntry’ {aka ‘struct _GActionEntry’} 59 | { "action1", action1_activated, NULL, NULL, NULL }, | ^ gio/tests/basic-application.c:60:5: error: missing initializer for field ‘padding’ of ‘GActionEntry’ {aka ‘struct _GActionEntry’} 60 | { "action2", action2_activated, "b", "false", change_action2 } | ^ --- gio/tests/basic-application.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gio/tests/basic-application.c b/gio/tests/basic-application.c index 94100eb5f..362b2fd51 100644 --- a/gio/tests/basic-application.c +++ b/gio/tests/basic-application.c @@ -54,10 +54,10 @@ static void startup (GApplication *app) { static GActionEntry actions[] = { - { "new", new_activated, NULL, NULL, NULL }, - { "quit", quit_activated, NULL, NULL, NULL }, - { "action1", action1_activated, NULL, NULL, NULL }, - { "action2", action2_activated, "b", "false", change_action2 } + { "new", new_activated, NULL, NULL, NULL, { 0 } }, + { "quit", quit_activated, NULL, NULL, NULL, { 0 } }, + { "action1", action1_activated, NULL, NULL, NULL, { 0 } }, + { "action2", action2_activated, "b", "false", change_action2, { 0 } } }; g_action_map_add_action_entries (G_ACTION_MAP (app), From 76af9efbff7d974d9c0b9ed4d7fb94b6d3de8ecd Mon Sep 17 00:00:00 2001 From: Emmanuel Fleury Date: Fri, 20 Nov 2020 20:26:10 +0100 Subject: [PATCH 5/8] Fix several missing initializer in tests/gobject/testgobject.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit tests/gobject/testgobject.c: In function ‘test_iface_get_type’: tests/gobject/testgobject.c:53:7: error: missing initializer for field ‘class_init’ of ‘GTypeInfo’ {aka ‘const struct _GTypeInfo’} 53 | }; | ^ tests/gobject/testgobject.c: In function ‘test_object_get_type’: tests/gobject/testgobject.c:182:7: error: missing initializer for field ‘value_table’ of ‘GTypeInfo’ {aka ‘const struct _GTypeInfo’} 182 | }; | ^ tests/gobject/testgobject.c: In function ‘derived_object_get_type’: tests/gobject/testgobject.c:349:7: error: missing initializer for field ‘value_table’ of ‘GTypeInfo’ {aka ‘const struct _GTypeInfo’} 349 | }; | ^ --- tests/gobject/testgobject.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tests/gobject/testgobject.c b/tests/gobject/testgobject.c index df7d4c748..e467abcd4 100644 --- a/tests/gobject/testgobject.c +++ b/tests/gobject/testgobject.c @@ -50,6 +50,13 @@ test_iface_get_type (void) sizeof (TestIfaceClass), (GBaseInitFunc) iface_base_init, /* base_init */ (GBaseFinalizeFunc) iface_base_finalize, /* base_finalize */ + NULL, + NULL, + NULL, + 0, + 0, + NULL, + NULL }; test_iface_type = g_type_register_static (G_TYPE_INTERFACE, "TestIface", &test_iface_info, 0); @@ -178,7 +185,8 @@ test_object_get_type (void) NULL, /* class_data */ sizeof (TestObject), 5, /* n_preallocs */ - (GInstanceInitFunc) test_object_init, + (GInstanceInitFunc) test_object_init, + NULL }; GInterfaceInfo iface_info = { test_object_test_iface_init, NULL, GUINT_TO_POINTER (42) }; @@ -345,7 +353,8 @@ derived_object_get_type (void) NULL, /* class_data */ sizeof (DerivedObject), 5, /* n_preallocs */ - (GInstanceInitFunc) derived_object_init, + (GInstanceInitFunc) derived_object_init, + NULL }; GInterfaceInfo iface_info = { derived_object_test_iface_init, NULL, GUINT_TO_POINTER (87) }; From 277d206d3812b913efbdf364403b776a15013d2b Mon Sep 17 00:00:00 2001 From: Emmanuel Fleury Date: Fri, 20 Nov 2020 21:17:03 +0100 Subject: [PATCH 6/8] Fix multiple missing initializer warnings in tests/gobject/testcommon.h MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit tests/gobject/testmodule.c: In function ‘test_module_get_type’: tests/gobject/testmodule.c:34:1: error: missing initializer for field ‘value_table’ of ‘GTypeInfo’ {aka ‘const struct _GTypeInfo’} 34 | DEFINE_TYPE (TestModule, test_module, | ^~~~~~~~~~~ tests/gobject/defaultiface.c: In function ‘test_static_iface_get_type’: tests/gobject/defaultiface.c:58:1: error: missing initializer for field ‘class_finalize’ of ‘GTypeInfo’ {aka ‘const struct _GTypeInfo’} 58 | DEFINE_IFACE (TestStaticIface, test_static_iface, | ^~~~~~~~~~~~ --- tests/gobject/testcommon.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/gobject/testcommon.h b/tests/gobject/testcommon.h index a5b59b3d3..3e40cca67 100644 --- a/tests/gobject/testcommon.h +++ b/tests/gobject/testcommon.h @@ -40,7 +40,8 @@ prefix ## _get_type (void) \ NULL, /* class_data */ \ sizeof (name), \ 0, /* n_prelocs */ \ - (GInstanceInitFunc) instance_init \ + (GInstanceInitFunc) instance_init, \ + (const GTypeValueTable *) NULL, \ }; \ \ object_type = g_type_register_static (parent_type, \ @@ -72,6 +73,12 @@ prefix ## _get_type (void) \ (GBaseInitFunc) base_init, \ (GBaseFinalizeFunc) NULL, \ (GClassInitFunc) dflt_init, \ + (GClassFinalizeFunc) NULL, \ + (gconstpointer) NULL, \ + (guint16) 0, \ + (guint16) 0, \ + (GInstanceInitFunc) NULL, \ + (const GTypeValueTable*) NULL, \ }; \ \ iface_type = g_type_register_static (G_TYPE_INTERFACE, \ From b04ebbf67b4fba06c84ac10e5ab486e79c0bfc38 Mon Sep 17 00:00:00 2001 From: Emmanuel Fleury Date: Fri, 20 Nov 2020 21:21:56 +0100 Subject: [PATCH 7/8] Fix missing initializer warning in tests/gobject/defaultiface.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit tests/gobject/defaultiface.c: In function ‘test_dynamic_iface_register’: tests/gobject/defaultiface.c:126:5: error: missing initializer for field ‘class_data’ of ‘GTypeInfo’ {aka ‘const struct _GTypeInfo’} 126 | }; | ^ --- tests/gobject/defaultiface.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/gobject/defaultiface.c b/tests/gobject/defaultiface.c index eccb79ced..92e45cefb 100644 --- a/tests/gobject/defaultiface.c +++ b/tests/gobject/defaultiface.c @@ -122,7 +122,12 @@ test_dynamic_iface_register (GTypeModule *module) (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) test_dynamic_iface_default_init, - (GClassFinalizeFunc) test_dynamic_iface_default_finalize + (GClassFinalizeFunc) test_dynamic_iface_default_finalize, + NULL, + 0, + 0, + NULL, + NULL }; test_dynamic_iface_type = g_type_module_register_type (module, G_TYPE_INTERFACE, From b419761189989cada2101c9c005e2e27aebdf223 Mon Sep 17 00:00:00 2001 From: Emmanuel Fleury Date: Fri, 20 Nov 2020 21:25:28 +0100 Subject: [PATCH 8/8] Fix signedness warning in tests/onceinit.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit tests/onceinit.c: In function ‘stress_concurrent_initializers’: tests/onceinit.c:267:17: error: comparison of integer expressions of different signedness: ‘int’ and ‘long unsigned int’ 267 | for (i = 0; i < G_N_ELEMENTS (initializers); i++) | ^ --- tests/onceinit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/onceinit.c b/tests/onceinit.c index 9788efcbd..4f30739ca 100644 --- a/tests/onceinit.c +++ b/tests/onceinit.c @@ -259,7 +259,7 @@ stress_concurrent_initializers (void *user_data) LIST_256_TEST_INITIALIZERS (stress3), LIST_256_TEST_INITIALIZERS (stress4), }; - int i; + gsize i; /* sync to main thread */ g_mutex_lock (&tmutex); g_mutex_unlock (&tmutex);