[gvfs] afc: Add guards against the operation mode not being set



commit 828d6ae24a6cd7325b7c885dd7a64b6030536cc0
Author: Bastien Nocera <hadess hadess net>
Date:   Wed Mar 23 17:06:36 2016 +0100

    afc: Add guards against the operation mode not being set
    
    We usually did:
    if mode == AFC; <foo> else <bar>
    
    To guard against the mode not actually being HouseArrest in the else
    branch, change this to:
    if mode == AFC; <foo> else if mode == HOUSE_ARREST ; <bar> ; else ; <baz>
    
    https://bugzilla.gnome.org/show_bug.cgi?id=764099

 daemon/gvfsbackendafc.c |   18 +++++++++++++++---
 1 files changed, 15 insertions(+), 3 deletions(-)
---
diff --git a/daemon/gvfsbackendafc.c b/daemon/gvfsbackendafc.c
index e1773d8..11cd00c 100644
--- a/daemon/gvfsbackendafc.c
+++ b/daemon/gvfsbackendafc.c
@@ -157,7 +157,7 @@ g_vfs_backend_afc_close_connection (GVfsBackendAfc *self)
         {
           afc_client_free (self->afc_cli);
         }
-      else
+      else if (self->mode == ACCESS_MODE_HOUSE_ARREST)
         {
           if (self->apps != NULL)
             {
@@ -176,6 +176,10 @@ g_vfs_backend_afc_close_connection (GVfsBackendAfc *self)
             }
           g_mutex_clear (&self->apps_lock);
         }
+      else
+        {
+          g_assert_not_reached ();
+        }
       g_free (self->model);
       self->model = NULL;
       idevice_free (self->dev);
@@ -1835,7 +1839,7 @@ g_vfs_backend_afc_enumerate (GVfsBackend *backend,
           return;
         }
     }
-  else
+  else if (self->mode == ACCESS_MODE_HOUSE_ARREST)
     {
       char *app;
 
@@ -1890,6 +1894,10 @@ g_vfs_backend_afc_enumerate (GVfsBackend *backend,
             }
         }
     }
+  else
+    {
+      g_assert_not_reached ();
+    }
 
   trailing_slash = g_str_has_suffix (new_path ? new_path : path, "/");
 
@@ -1955,7 +1963,7 @@ g_vfs_backend_afc_query_info (GVfsBackend *backend,
           return;
         }
     }
-  else
+  else if (self->mode == ACCESS_MODE_HOUSE_ARREST)
     {
       char *app;
       gboolean is_doc_root;
@@ -2004,6 +2012,10 @@ g_vfs_backend_afc_query_info (GVfsBackend *backend,
             }
         }
     }
+  else
+    {
+      g_assert_not_reached ();
+    }
 
   ptr = strrchr (new_path ? new_path : path, '/');
   if (ptr && ptr[1] != '\0')


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