[gvfs] [FTP] clarify code



commit 586a4e0a2ca6d3c021e8eaf509fb689e0d398082
Author: Benjamin Otte <otte gnome org>
Date:   Tue May 26 20:23:25 2009 +0200

    [FTP] clarify code
    
    Don't use:
      if (error)
        /* error handling */
      else
        /* normal code */;
      return;
    
    Instead use:
      if (error) {
        /* error handling */
        return;
      }
      /* normal code */
      return;
    
    This avoids lots of indentation for normal code and clarifies what the
    default flow of the code is.
---
 daemon/gvfsbackendftp.c |   86 +++++++++++++++++++++++-----------------------
 1 files changed, 43 insertions(+), 43 deletions(-)

diff --git a/daemon/gvfsbackendftp.c b/daemon/gvfsbackendftp.c
index 08d10aa..7eec44b 100644
--- a/daemon/gvfsbackendftp.c
+++ b/daemon/gvfsbackendftp.c
@@ -1625,55 +1625,55 @@ try_login:
     {
       ftp_connection_pop_job (conn);
       ftp_connection_free (conn);
+      g_object_unref (addr);
+      return;
     }
-  else
-    {
-      if (prompt && !anonymous)
-	{
-	  /* a prompt was created, so we have to save the password */
-	  g_vfs_keyring_save_password (ftp->user,
-				       g_network_address_get_hostname (addr),
-				       NULL,
-				       "ftp",
-				       NULL,
-				       NULL,
-				       port == 21 ? 0 : port,
-				       ftp->password,
-				       password_save);
-	  g_free (prompt);
-	}
 
-      mount_spec = g_mount_spec_new ("ftp");
-      g_mount_spec_set (mount_spec, "host", g_network_address_get_hostname (addr));
-      if (port != 21)
-	{
-	  char *port_str = g_strdup_printf ("%u", port);
-	  g_mount_spec_set (mount_spec, "port", port_str);
-	  g_free (port_str);
-	}
+  if (prompt && !anonymous)
+    {
+      /* a prompt was created, so we have to save the password */
+      g_vfs_keyring_save_password (ftp->user,
+                                   g_network_address_get_hostname (addr),
+                                   NULL,
+                                   "ftp",
+                                   NULL,
+                                   NULL,
+                                   port == 21 ? 0 : port,
+                                   ftp->password,
+                                   password_save);
+      g_free (prompt);
+    }
+
+  mount_spec = g_mount_spec_new ("ftp");
+  g_mount_spec_set (mount_spec, "host", g_network_address_get_hostname (addr));
+  if (port != 21)
+    {
+      char *port_str = g_strdup_printf ("%u", port);
+      g_mount_spec_set (mount_spec, "port", port_str);
+      g_free (port_str);
+    }
 
-      if (ftp->has_initial_user)
-        g_mount_spec_set (mount_spec, "user", ftp->user);
-          
-      if (g_str_equal (ftp->user, "anonymous"))
-        display_name = g_strdup_printf (_("ftp on %s"), ftp->host_display_name);
-      else
-	{
-	  /* Translators: the first %s is the username, the second the host name */
-	  display_name = g_strdup_printf (_("ftp as %s on %s"), ftp->user, ftp->host_display_name);
-	}
-      g_vfs_backend_set_mount_spec (backend, mount_spec);
-      g_mount_spec_unref (mount_spec);
+  if (ftp->has_initial_user)
+    g_mount_spec_set (mount_spec, "user", ftp->user);
+      
+  if (g_str_equal (ftp->user, "anonymous"))
+    display_name = g_strdup_printf (_("ftp on %s"), ftp->host_display_name);
+  else
+    {
+      /* Translators: the first %s is the username, the second the host name */
+      display_name = g_strdup_printf (_("ftp as %s on %s"), ftp->user, ftp->host_display_name);
+    }
+  g_vfs_backend_set_mount_spec (backend, mount_spec);
+  g_mount_spec_unref (mount_spec);
 
-      g_vfs_backend_set_display_name (backend, display_name);
-      g_free (display_name);
-      g_vfs_backend_set_icon_name (backend, "folder-remote");
+  g_vfs_backend_set_display_name (backend, display_name);
+  g_free (display_name);
+  g_vfs_backend_set_icon_name (backend, "folder-remote");
 
-      ftp->connections = 1;
-      ftp->max_connections = G_MAXUINT;
-      ftp->queue = g_queue_new ();
-      g_vfs_backend_ftp_push_connection (ftp, conn);
-    }
+  ftp->connections = 1;
+  ftp->max_connections = G_MAXUINT;
+  ftp->queue = g_queue_new ();
+  g_vfs_backend_ftp_push_connection (ftp, conn);
   
   g_object_unref (addr);
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]