From 5241d96b2188f285dfd60a4b85f9d1cdf7ccb124 Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Thu, 6 Mar 2008 09:53:35 +0000 Subject: [PATCH] Fix sparse warnings (#519489) 2008-03-06 Alexander Larsson * gdesktopappinfo.c: * gfilemonitor.c: * gthemedicon.c: * gunionvolumemonitor.c: * gunixmounts.c: * tests/g-file.c: * tests/live-g-file.c: * xdgmime/xdgmimecache.c: Fix sparse warnings (#519489) svn path=/trunk/; revision=6632 --- gio/ChangeLog | 12 ++++++++ gio/gdesktopappinfo.c | 2 +- gio/gfilemonitor.c | 2 +- gio/gthemedicon.c | 1 - gio/gunionvolumemonitor.c | 4 +-- gio/gunixmounts.c | 1 - gio/tests/g-file.c | 2 +- gio/tests/live-g-file.c | 77 +++++----------------------------------------- gio/xdgmime/xdgmimecache.c | 2 +- 9 files changed, 26 insertions(+), 77 deletions(-) diff --git a/gio/ChangeLog b/gio/ChangeLog index 9376039..461e55b 100644 --- a/gio/ChangeLog +++ b/gio/ChangeLog @@ -1,3 +1,15 @@ +2008-03-06 Alexander Larsson + + * gdesktopappinfo.c: + * gfilemonitor.c: + * gthemedicon.c: + * gunionvolumemonitor.c: + * gunixmounts.c: + * tests/g-file.c: + * tests/live-g-file.c: + * xdgmime/xdgmimecache.c: + Fix sparse warnings (#519489) + 2008-03-05 Alexander Larsson * gfilemonitor.c: diff --git a/gio/gdesktopappinfo.c b/gio/gdesktopappinfo.c index 6de26c9..b6c7c5b 100644 --- a/gio/gdesktopappinfo.c +++ b/gio/gdesktopappinfo.c @@ -2544,7 +2544,7 @@ g_desktop_app_info_lookup_get_default_for_uri_scheme (GDesktopAppInfoLookup *loo { GDesktopAppInfoLookupIface *iface; - g_return_val_if_fail (G_IS_DESKTOP_APP_INFO_LOOKUP (lookup), FALSE); + g_return_val_if_fail (G_IS_DESKTOP_APP_INFO_LOOKUP (lookup), NULL); iface = G_DESKTOP_APP_INFO_LOOKUP_GET_IFACE (lookup); diff --git a/gio/gfilemonitor.c b/gio/gfilemonitor.c index dd985ee..d61f1f9 100644 --- a/gio/gfilemonitor.c +++ b/gio/gfilemonitor.c @@ -365,7 +365,7 @@ emit_in_idle (GFileMonitor *monitor, source = g_idle_source_new (); g_source_set_priority (source, 0); - g_source_set_callback (source, emit_cb, change, file_change_free); + g_source_set_callback (source, emit_cb, change, (GDestroyNotify)file_change_free); g_source_attach (source, NULL); g_source_unref (source); } diff --git a/gio/gthemedicon.c b/gio/gthemedicon.c index 8c0f53f..c40c57d 100644 --- a/gio/gthemedicon.c +++ b/gio/gthemedicon.c @@ -226,7 +226,6 @@ void g_themed_icon_append_name (GThemedIcon *icon, const char *iconname) { guint num_names; - char **new_names; g_return_if_fail (G_IS_THEMED_ICON (icon)); g_return_if_fail (iconname != NULL); diff --git a/gio/gunionvolumemonitor.c b/gio/gunionvolumemonitor.c index 2a4152f..afb487e 100644 --- a/gio/gunionvolumemonitor.c +++ b/gio/gunionvolumemonitor.c @@ -456,7 +456,7 @@ get_default_native_class (gpointer data) * instance on the first call. */ static GNativeVolumeMonitorClass * -get_native_class () +get_native_class (void) { static GOnce once_init = G_ONCE_INIT; GTypeClass *type_class; @@ -464,7 +464,7 @@ get_native_class () type_class = NULL; g_once (&once_init, (GThreadFunc)get_default_native_class, &type_class); - if (type_class == NULL && once_init.retval != G_TYPE_INVALID) + if (type_class == NULL && once_init.retval != GUINT_TO_POINTER(G_TYPE_INVALID)) type_class = g_type_class_ref ((GType)once_init.retval); return (GNativeVolumeMonitorClass *)type_class; diff --git a/gio/gunixmounts.c b/gio/gunixmounts.c index 6f0ab0b..486a21b 100644 --- a/gio/gunixmounts.c +++ b/gio/gunixmounts.c @@ -1865,7 +1865,6 @@ g_unix_mount_guess_can_eject (GUnixMountEntry *mount_entry) gboolean g_unix_mount_guess_should_display (GUnixMountEntry *mount_entry) { - GUnixMountType guessed_type; const char *mount_path; /* Never display internal mountpoints */ diff --git a/gio/tests/g-file.c b/gio/tests/g-file.c index af74fd6..d512c93 100644 --- a/gio/tests/g-file.c +++ b/gio/tests/g-file.c @@ -436,7 +436,7 @@ static void roundtrip_parent_child (const gboolean use_uri, const gboolean under_root_descending, const char *path, const char *dir_holder) { - GFile *files[6] = {0}; + GFile *files[6] = {NULL}; int i; if (use_uri) diff --git a/gio/tests/live-g-file.c b/gio/tests/live-g-file.c index 7c731bd..fe851d2 100644 --- a/gio/tests/live-g-file.c +++ b/gio/tests/live-g-file.c @@ -26,9 +26,7 @@ #include #include - #define PATTERN_FILE_SIZE 0x10000 - #define TEST_HANDLE_SPECIAL TRUE enum StructureExtraFlags @@ -71,7 +69,7 @@ struct StructureItem #define TEST_TARGET_FILE "target-file" -const struct StructureItem sample_struct[] = { +static const struct StructureItem sample_struct[] = { /* filename link file_type create_flags mode | handle_special | extra_flags */ {"dir1", NULL, G_FILE_TYPE_DIRECTORY, G_FILE_CREATE_NONE, 0, 0, TEST_DELETE_NORMAL | TEST_DELETE_NON_EMPTY | TEST_REPLACE | TEST_OPEN}, {"dir1/subdir", NULL, G_FILE_TYPE_DIRECTORY, G_FILE_CREATE_NONE, 0, 0, TEST_COPY | TEST_COPY_ERROR_RECURSE | TEST_APPEND}, @@ -100,22 +98,13 @@ const struct StructureItem sample_struct[] = { {"lost_symlink", "nowhere", G_FILE_TYPE_SYMBOLIC_LINK, G_FILE_CREATE_NONE, 0, 0, TEST_COPY | TEST_DELETE_NORMAL | TEST_OPEN | TEST_INVALID_SYMLINK}, }; - - - static gboolean write_test; static gboolean verbose; static gboolean posix_compat; #define log(msg...) if (verbose) g_print (msg) - - - - - - -GFile * +static GFile * create_empty_file (GFile * parent, const char *filename, GFileCreateFlags create_flags) { @@ -124,7 +113,6 @@ create_empty_file (GFile * parent, const char *filename, GError *error; GFileOutputStream *outs; - child = g_file_get_child (parent, filename); g_assert (child != NULL); @@ -138,7 +126,7 @@ create_empty_file (GFile * parent, const char *filename, return child; } -GFile * +static GFile * create_empty_dir (GFile * parent, const char *filename) { GFile *child; @@ -154,7 +142,7 @@ create_empty_dir (GFile * parent, const char *filename) return child; } -GFile * +static GFile * create_symlink (GFile * parent, const char *filename, const char *points_to) { GFile *child; @@ -182,7 +170,6 @@ test_create_structure (gconstpointer test_data) int i; struct StructureItem item; - g_assert (test_data != NULL); log ("\n Going to create testing structure in '%s'...\n", (char *) test_data); @@ -194,7 +181,6 @@ test_create_structure (gconstpointer test_data) res = g_file_make_directory (root, NULL, NULL); /* don't care about errors here */ - /* create any other items */ for (i = 0; i < G_N_ELEMENTS (sample_struct); i++) { @@ -270,11 +256,7 @@ test_create_structure (gconstpointer test_data) g_object_unref (root); } - - - - -GFile * +static GFile * file_exists (GFile * parent, const char *filename, gboolean * result) { GFile *child; @@ -292,7 +274,7 @@ file_exists (GFile * parent, const char *filename, gboolean * result) return child; } -void +static void test_attributes (struct StructureItem item, GFileInfo * info) { GFileType ftype; @@ -381,7 +363,6 @@ test_attributes (struct StructureItem item, GFileInfo * info) } } - static void test_initial_structure (gconstpointer test_data) { @@ -406,7 +387,6 @@ test_initial_structure (gconstpointer test_data) res = g_file_query_exists (root, NULL); g_assert_cmpint (res, ==, TRUE); - /* test the structure */ for (i = 0; i < G_N_ELEMENTS (sample_struct); i++) { @@ -433,7 +413,6 @@ test_initial_structure (gconstpointer test_data) g_object_unref (child); } - /* read and test the pattern file */ log (" Testing pattern file...\n"); child = file_exists (root, "pattern_file", &res); @@ -484,12 +463,7 @@ test_initial_structure (gconstpointer test_data) g_object_unref (root); } - - - - - -void +static void traverse_recurse_dirs (GFile * parent, GFile * root) { gboolean res; @@ -501,7 +475,6 @@ traverse_recurse_dirs (GFile * parent, GFile * root) int i; gboolean found; - g_assert (root != NULL); error = NULL; @@ -547,7 +520,6 @@ traverse_recurse_dirs (GFile * parent, GFile * root) } g_assert (error == NULL); - error = NULL; res = g_file_enumerator_close (enumerator, NULL, &error); g_assert_cmpint (res, ==, TRUE); @@ -656,12 +628,7 @@ test_enumerate (gconstpointer test_data) g_object_unref (root); } - - - - - -void +static void do_copy_move (GFile * root, struct StructureItem item, const char *target_dir, enum StructureExtraFlags extra_flags) { @@ -695,7 +662,6 @@ do_copy_move (GFile * root, struct StructureItem item, const char *target_dir, log (" res = %d, error code %d = %s\n", res, error->code, error->message); - /* copying file/directory to itself (".") */ if (((item.extra_flags & TEST_NOT_EXISTS) != TEST_NOT_EXISTS) && (extra_flags == TEST_ALREADY_EXISTS)) @@ -758,7 +724,6 @@ test_copy_move (gconstpointer test_data) int i; struct StructureItem item; - log ("\n"); g_assert (test_data != NULL); @@ -814,10 +779,6 @@ test_copy_move (gconstpointer test_data) g_object_unref (root); } - - - - static void test_create (gconstpointer test_data) { @@ -828,7 +789,6 @@ test_create (gconstpointer test_data) struct StructureItem item; GFileOutputStream *os; - g_assert (test_data != NULL); log ("\n"); @@ -837,7 +797,6 @@ test_create (gconstpointer test_data) res = g_file_query_exists (root, NULL); g_assert_cmpint (res, ==, TRUE); - for (i = 0; i < G_N_ELEMENTS (sample_struct); i++) { item = sample_struct[i]; @@ -866,7 +825,6 @@ test_create (gconstpointer test_data) if (error) log (" error code %d = %s\n", error->code, error->message); - if (((item.extra_flags & TEST_NOT_EXISTS) == 0) && ((item.extra_flags & TEST_CREATE) == TEST_CREATE)) { @@ -909,9 +867,6 @@ test_create (gconstpointer test_data) g_object_unref (root); } - - - static void test_open (gconstpointer test_data) { @@ -922,7 +877,6 @@ test_open (gconstpointer test_data) struct StructureItem item; GFileInputStream *input_stream; - g_assert (test_data != NULL); log ("\n"); @@ -931,7 +885,6 @@ test_open (gconstpointer test_data) res = g_file_query_exists (root, NULL); g_assert_cmpint (res, ==, TRUE); - for (i = 0; i < G_N_ELEMENTS (sample_struct); i++) { item = sample_struct[i]; @@ -984,10 +937,6 @@ test_open (gconstpointer test_data) g_object_unref (root); } - - - - static void test_delete (gconstpointer test_data) { @@ -998,7 +947,6 @@ test_delete (gconstpointer test_data) int i; struct StructureItem item; - g_assert (test_data != NULL); log ("\n"); @@ -1055,19 +1003,12 @@ test_delete (gconstpointer test_data) g_error_free (error); } - g_object_unref (child); } } g_object_unref (root); } - - - - - - int main (int argc, char *argv[]) { @@ -1115,8 +1056,6 @@ main (int argc, char *argv[]) } target_path = strdup (argv[1]); - - /* Write test - create new testing structure */ if (write_test || create_struct) g_test_add_data_func ("/live-g-file/create_structure", target_path, diff --git a/gio/xdgmime/xdgmimecache.c b/gio/xdgmime/xdgmimecache.c index 5182a6a..884074e 100644 --- a/gio/xdgmime/xdgmimecache.c +++ b/gio/xdgmime/xdgmimecache.c @@ -910,7 +910,7 @@ _xdg_mime_cache_list_mime_parents (const char *mime) } } } - all_parents[p++] = 0; + all_parents[p++] = NULL; result = (char **) malloc (p * sizeof (char *)); memcpy (result, all_parents, p * sizeof (char *)); -- 2.7.4