[gvfs/wip/hadess/afc-error-codes: 1/3] afc: Simplify setting error codes



commit 4c7af079f65a0d4da0a41cd18be0c8ace2c64725
Author: Bastien Nocera <hadess hadess net>
Date:   Tue Feb 11 11:01:01 2020 +0100

    afc: Simplify setting error codes
    
    We don't need to go to another function to get an error code when our
    switch function does that already.
    
    The "unhandled" AFC errors are now slightly less precise, but it's
    still possible to get the meaning of that code from the AFC headers
    directly (for developers), and not visible for end-users anyway.

 daemon/gvfsbackendafc.c | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)
---
diff --git a/daemon/gvfsbackendafc.c b/daemon/gvfsbackendafc.c
index d51b21e6..3169b792 100644
--- a/daemon/gvfsbackendafc.c
+++ b/daemon/gvfsbackendafc.c
@@ -200,40 +200,37 @@ g_vfs_backend_afc_close_connection (GVfsBackendAfc *self)
 static int
 g_vfs_backend_afc_check (afc_error_t cond, GVfsJob *job)
 {
-  GIOErrorEnum error;
-
   if (G_LIKELY(cond == AFC_E_SUCCESS))
         return 0;
 
-  error = g_io_error_from_afc_error (cond);
   switch (cond)
     {
     case AFC_E_INTERNAL_ERROR:
-      g_vfs_job_failed (job, G_IO_ERROR, error,
+      g_vfs_job_failed (job, G_IO_ERROR, G_IO_ERROR_FAILED,
                         _("Internal Apple File Control error"));
       break;
     case AFC_E_OBJECT_NOT_FOUND:
-      g_vfs_job_failed (job, G_IO_ERROR, error,
+      g_vfs_job_failed (job, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
                         _("File doesn’t exist"));
       break;
     case AFC_E_DIR_NOT_EMPTY:
-      g_vfs_job_failed (job, G_IO_ERROR, error,
+      g_vfs_job_failed (job, G_IO_ERROR, G_IO_ERROR_NOT_EMPTY,
                         _("Directory not empty"));
       break;
     case AFC_E_OP_TIMEOUT:
-      g_vfs_job_failed (job, G_IO_ERROR, error,
+      g_vfs_job_failed (job, G_IO_ERROR, G_IO_ERROR_TIMED_OUT,
                         _("The device did not respond"));
       break;
     case AFC_E_NOT_ENOUGH_DATA:
-      g_vfs_job_failed (job, G_IO_ERROR, error,
+      g_vfs_job_failed (job, G_IO_ERROR, G_IO_ERROR_CLOSED,
                         _("The connection was interrupted"));
       break;
     case AFC_E_MUX_ERROR:
-      g_vfs_job_failed (job, G_IO_ERROR, error,
+      g_vfs_job_failed (job, G_IO_ERROR, G_IO_ERROR_FAILED,
                         _("Invalid Apple File Control data received"));
       break;
     default:
-      g_vfs_job_failed (job, G_IO_ERROR, error,
+      g_vfs_job_failed (job, G_IO_ERROR, G_IO_ERROR_FAILED,
                         _("Unhandled Apple File Control error (%d)"), cond);
       break;
     }


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