From ac42183c33b6dbb05c9c9af52fcacb2805ddb3b6 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Tue, 27 Mar 2018 16:46:55 +0100 Subject: [PATCH] Initialize variable The `mount_monitor` variable is only set if the boolean `with_mount_monitor` variable is set to TRUE, but the compiler does not know that, so it'll warn when calling `g_clear_object()` even if the clearing operation is gated with the same boolean. Initializing with NULL does not cost us anything, and eliminates a conditional branch. https://bugzilla.gnome.org/show_bug.cgi?id=794732 --- gio/tests/g-file-info-filesystem-readonly.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/gio/tests/g-file-info-filesystem-readonly.c b/gio/tests/g-file-info-filesystem-readonly.c index 9a185b081..c2b0aa518 100644 --- a/gio/tests/g-file-info-filesystem-readonly.c +++ b/gio/tests/g-file-info-filesystem-readonly.c @@ -29,7 +29,7 @@ test_filesystem_readonly (gconstpointer with_mount_monitor) { GFileInfo *file_info; GFile *mounted_file; - GUnixMountMonitor *mount_monitor; + GUnixMountMonitor *mount_monitor = NULL; gchar *bindfs, *fusermount; gchar *command_mount, *command_mount_ro, *command_umount; gchar *curdir, *dir_to_mount, *dir_mountpoint; @@ -62,9 +62,7 @@ test_filesystem_readonly (gconstpointer with_mount_monitor) } if (with_mount_monitor) - { - mount_monitor = g_unix_mount_monitor_get (); - } + mount_monitor = g_unix_mount_monitor_get (); /* Use bindfs, which does not need root privileges, to mount the contents of one dir * into another dir (and do the mount as readonly as per passed '-o ro' option) */ @@ -125,9 +123,7 @@ test_filesystem_readonly (gconstpointer with_mount_monitor) } /* Clean up */ - if (with_mount_monitor) - g_clear_object (&mount_monitor); - + g_clear_object (&mount_monitor); g_clear_object (&file_info); g_clear_object (&mounted_file); g_spawn_command_line_sync (command_umount, NULL, NULL, NULL, NULL); /* unmount */