[Xfce4-commits] <garcon:master> Drop goto statements.
Nick Schermer
nick at xfce.org
Mon Aug 17 19:08:02 CEST 2009
Updating branch refs/heads/master
to 3a83f39488a0547f1c6c1c0043411af52e2eec92 (commit)
from 53b235e05771f5bd7ac44c4efc987a46b5ffb88a (commit)
commit 3a83f39488a0547f1c6c1c0043411af52e2eec92
Author: Nick Schermer <nick at xfce.org>
Date: Mon Aug 17 19:06:29 2009 +0200
Drop goto statements.
garcon/garcon-menu-directory.c | 14 ++++++++------
garcon/garcon-menu-item.c | 20 ++++++++++----------
2 files changed, 18 insertions(+), 16 deletions(-)
diff --git a/garcon/garcon-menu-directory.c b/garcon/garcon-menu-directory.c
index c486c83..95fb9b8 100644
--- a/garcon/garcon-menu-directory.c
+++ b/garcon/garcon-menu-directory.c
@@ -320,7 +320,7 @@ garcon_menu_directory_new (GFile *file)
GarconMenuDirectory *directory = NULL;
gchar *contents;
gsize length;
- GKeyFile *rc = NULL;
+ GKeyFile *rc;
gchar *name;
gchar *comment;
gchar *icon;
@@ -339,7 +339,11 @@ garcon_menu_directory_new (GFile *file)
succeed = g_key_file_load_from_data (rc, contents, length, G_KEY_FILE_NONE, NULL);
g_free (contents);
if (G_UNLIKELY (!succeed))
- goto error;
+ {
+ /* Cleanup and leave */
+ g_key_file_free (rc);
+ return NULL;
+ }
/* Parse name, exec command and icon name */
name = g_key_file_get_locale_string (rc, "Desktop Entry", "Name", NULL, NULL);
@@ -356,7 +360,7 @@ garcon_menu_directory_new (GFile *file)
"no-display", no_display,
NULL);
- /* Cleanup */
+ /* Free strings */
g_free (name);
g_free (comment);
g_free (icon);
@@ -366,10 +370,8 @@ garcon_menu_directory_new (GFile *file)
directory->priv->not_show_in = g_key_file_get_string_list (rc, "Desktop Entry", "NotShowIn", NULL, NULL);
directory->priv->hidden = g_key_file_get_boolean (rc, "Desktop Entry", "Hidden", NULL);
-error:
/* Cleanup */
- if (G_LIKELY (rc != NULL))
- g_key_file_free (rc);
+ g_key_file_free (rc);
return directory;
}
diff --git a/garcon/garcon-menu-item.c b/garcon/garcon-menu-item.c
index f3a1d95..0e5bea0 100644
--- a/garcon/garcon-menu-item.c
+++ b/garcon/garcon-menu-item.c
@@ -529,7 +529,7 @@ GarconMenuItem *
garcon_menu_item_new (GFile *file)
{
GarconMenuItem *item = NULL;
- GKeyFile *rc = NULL;
+ GKeyFile *rc;
gchar *contents;
gsize length;
gboolean succeed;
@@ -557,12 +557,14 @@ garcon_menu_item_new (GFile *file)
rc = g_key_file_new ();
succeed = g_key_file_load_from_data (rc, contents, length, G_KEY_FILE_NONE, NULL);
g_free (contents);
- if (G_UNLIKELY (!succeed))
- goto error;
- /* Abort if the file has been marked as "deleted"/hidden */
- if (G_UNLIKELY (g_key_file_get_boolean (rc, "Desktop Entry", "Hidden", NULL)))
- goto error;
+ /* Abort if loading failed or the file has been marked as "deleted"/hidden */
+ if (!succeed || g_key_file_get_boolean (rc, "Desktop Entry", "Hidden", NULL))
+ {
+ /* Cleanup and leave */
+ g_key_file_free (rc);
+ return NULL;
+ }
/* Parse name, exec command and icon name */
name = g_key_file_get_locale_string (rc, "Desktop Entry", "Name", NULL, NULL);
@@ -628,10 +630,8 @@ garcon_menu_item_new (GFile *file)
g_free (icon);
g_free (path);
-error:
- /* Close file handle */
- if (G_LIKELY (rc != NULL))
- g_key_file_free (rc);
+ /* Cleanup */
+ g_key_file_free (rc);
return item;
}
More information about the Xfce4-commits
mailing list