From 8f5ec0dad328cbb498fe2f60bd465f0e4c5d4cad Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Thu, 19 Aug 2010 18:24:53 -0400 Subject: [PATCH] Fix misc compiler warnings in (mostly) test programs --- gio/gdbusmessage.c | 2 +- gio/gio.symbols | 1 - gio/tests/file.c | 17 +++++++++++++++-- gio/tests/g-icon.c | 2 +- glib/tests/date.c | 2 +- glib/tests/node.c | 2 +- glib/tests/shell.c | 4 ++-- tests/gobject/ifaceproperties.c | 2 +- 8 files changed, 22 insertions(+), 10 deletions(-) diff --git a/gio/gdbusmessage.c b/gio/gdbusmessage.c index 51e36ca7f..2a9d53fe4 100644 --- a/gio/gdbusmessage.c +++ b/gio/gdbusmessage.c @@ -899,7 +899,7 @@ read_string (GMemoryInputStream *mis, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT, _("Wanted to read %lu bytes but got EOF"), - to_read); + (gulong)to_read); goto fail; } diff --git a/gio/gio.symbols b/gio/gio.symbols index 801dfdfd9..a45889362 100644 --- a/gio/gio.symbols +++ b/gio/gio.symbols @@ -101,7 +101,6 @@ g_app_info_get_default_for_uri_scheme g_app_info_reset_type_associations #endif #endif -#endif #if IN_HEADER(__G_DESKTOP_APP_INFO_H__) diff --git a/gio/tests/file.c b/gio/tests/file.c index dc914b297..a8903ab28 100644 --- a/gio/tests/file.c +++ b/gio/tests/file.c @@ -396,6 +396,7 @@ test_create_delete (gconstpointer d) { GError *error; CreateDeleteData *data; + int tmpfd; data = g_new0 (CreateDeleteData, 1); @@ -403,7 +404,12 @@ test_create_delete (gconstpointer d) data->data = "abcdefghijklmnopqrstuvxyzABCDEFGHIJKLMNOPQRSTUVXYZ0123456789"; data->pos = 0; - data->monitor_path = tempnam ("/tmp", "g_file_create_delete_"); + /* Using tempnam() would be easier here, but causes a compile warning */ + tmpfd = g_file_open_tmp ("g_file_create_delete_XXXXXX", + &data->monitor_path, NULL); + g_assert_cmpint (tmpfd, !=, -1); + close (tmpfd); + remove (data->monitor_path); data->file = g_file_new_for_path (data->monitor_path); g_assert (!g_file_query_exists (data->file, NULL)); @@ -521,6 +527,7 @@ test_replace_load (void) { ReplaceLoadData *data; gchar *path; + int tmpfd; data = g_new0 (ReplaceLoadData, 1); data->again = TRUE; @@ -553,7 +560,13 @@ test_replace_load (void) " * make a backup of @file.\n" " **/\n"; - path = tempnam ("/tmp", "g_file_replace_load_"); + /* Using tempnam() would be easier here, but causes a compile warning */ + tmpfd = g_file_open_tmp ("g_file_replace_load_XXXXXX", + &path, NULL); + g_assert_cmpint (tmpfd, !=, -1); + close (tmpfd); + remove (path); + data->file = g_file_new_for_path (path); g_assert (!g_file_query_exists (data->file, NULL)); diff --git a/gio/tests/g-icon.c b/gio/tests/g-icon.c index 8efa7aa70..c194f7fd2 100644 --- a/gio/tests/g-icon.c +++ b/gio/tests/g-icon.c @@ -257,7 +257,7 @@ test_themed_icon (void) g_assert_cmpstr (names[0], ==, "first"); g_assert_cmpstr (names[1], ==, "testicon"); g_assert_cmpstr (names[2], ==, "last"); - g_assert_cmpuint (g_icon_hash (icon1), ==, 3193088045); + g_assert_cmpuint (g_icon_hash (icon1), ==, 3193088045U); icon2 = g_themed_icon_new_from_names ((gchar**)names2, -1); g_assert (g_icon_equal (icon1, icon2)); diff --git a/glib/tests/date.c b/glib/tests/date.c index 5fbd3899b..a9a9993f8 100644 --- a/glib/tests/date.c +++ b/glib/tests/date.c @@ -250,7 +250,7 @@ main (int argc, char** argv) gint i; /* Try to get all the leap year cases. */ - GDateYear check_years[] = { + int check_years[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 98, 99, 100, 101, 102, 103, 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, diff --git a/glib/tests/node.c b/glib/tests/node.c index 4f733bf15..5638b26c1 100644 --- a/glib/tests/node.c +++ b/glib/tests/node.c @@ -356,7 +356,7 @@ copy_up (gconstpointer src, l = GPOINTER_TO_INT (src); u = g_ascii_toupper (l); - return GINT_TO_POINTER (u); + return GINT_TO_POINTER ((int)u); } static void diff --git a/glib/tests/shell.c b/glib/tests/shell.c index e3f21bd04..c1862b6f5 100644 --- a/glib/tests/shell.c +++ b/glib/tests/shell.c @@ -68,11 +68,11 @@ static CmdlineTest cmdline_tests[] = }; static gboolean -strv_equal (const gchar **a, const gchar **b) +strv_equal (gchar **a, gchar **b) { gint i; - if (g_strv_length ((gchar**)a) != g_strv_length ((gchar **)b)) + if (g_strv_length (a) != g_strv_length (b)) return FALSE; for (i = 0; a[i]; i++) diff --git a/tests/gobject/ifaceproperties.c b/tests/gobject/ifaceproperties.c index 382edd549..3b758ccbc 100644 --- a/tests/gobject/ifaceproperties.c +++ b/tests/gobject/ifaceproperties.c @@ -425,7 +425,7 @@ main (gint argc, GObjectClass *object_class; TestIfaceClass *iface_vtable; GParamSpec **properties; - gint n_properties; + guint n_properties; gint val1, val2, val3, val4;