[gvfs/mtp-1.14.0: 9/49] Restructure more error handling.
- From: Philip Langdale <philipl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gvfs/mtp-1.14.0: 9/49] Restructure more error handling.
- Date: Sat, 3 Nov 2012 23:01:27 +0000 (UTC)
commit 7c43f440373baa20de3cba0f4f9f2601dcb93bbb
Author: Philip Langdale <philipl cloudera com>
Date: Fri Aug 3 14:40:29 2012 -0700
Restructure more error handling.
daemon/gvfsbackendmtp.c | 93 ++++++++++++++++++++++++-----------------------
1 files changed, 48 insertions(+), 45 deletions(-)
---
diff --git a/daemon/gvfsbackendmtp.c b/daemon/gvfsbackendmtp.c
index 9638108..4859512 100644
--- a/daemon/gvfsbackendmtp.c
+++ b/daemon/gvfsbackendmtp.c
@@ -835,34 +835,36 @@ do_make_directory (GVfsBackend *backend,
g_vfs_job_failed (G_VFS_JOB (job),
G_IO_ERROR, G_IO_ERROR_FAILED,
"Can't make directory in this location.");
- } else {
- LIBMTP_mtpdevice_t *device;
- device = get_device(backend, elements[1], G_VFS_JOB(job));
- if (device == NULL) {
- g_vfs_job_failed (G_VFS_JOB (job),
- G_IO_ERROR, G_IO_ERROR_FAILED,
- "Device does not exist");
- g_mutex_unlock (&G_VFS_BACKEND_MTP(backend)->mutex);
- return;
- }
+ goto exit;
+ }
- int parent_id = 0;
+ LIBMTP_mtpdevice_t *device;
+ device = get_device(backend, elements[1], G_VFS_JOB(job));
+ if (device == NULL) {
+ g_vfs_job_failed (G_VFS_JOB (job),
+ G_IO_ERROR, G_IO_ERROR_FAILED,
+ "Device does not exist");
+ goto exit;
+ }
- if (ne > 4) {
- parent_id = strtol(elements[ne-2], NULL, 10);
- }
+ int parent_id = 0;
+ if (ne > 4) {
+ parent_id = strtol(elements[ne-2], NULL, 10);
+ }
- int ret = LIBMTP_Create_Folder(device, elements[ne-1], parent_id, strtol(elements[2], NULL, 10));
- if (ret != 0) {
- LIBMTP_Dump_Errorstack(device);
- LIBMTP_Clear_Errorstack(device);
- g_vfs_job_failed (G_VFS_JOB (job),
- G_IO_ERROR, G_IO_ERROR_FAILED,
- "Error while creating directory.");
- } else {
- g_vfs_job_succeeded (G_VFS_JOB (job));
- }
+ int ret = LIBMTP_Create_Folder(device, elements[ne-1], parent_id, strtol(elements[2], NULL, 10));
+ if (ret != 0) {
+ LIBMTP_Dump_Errorstack(device);
+ LIBMTP_Clear_Errorstack(device);
+ g_vfs_job_failed (G_VFS_JOB (job),
+ G_IO_ERROR, G_IO_ERROR_FAILED,
+ "Error while creating directory.");
+ goto exit;
}
+
+ g_vfs_job_succeeded (G_VFS_JOB (job));
+
+ exit:
g_strfreev(elements);
g_mutex_unlock (&G_VFS_BACKEND_MTP(backend)->mutex);
}
@@ -884,29 +886,30 @@ do_delete (GVfsBackend *backend,
g_vfs_job_failed (G_VFS_JOB (job),
G_IO_ERROR, G_IO_ERROR_FAILED,
"Can't delete entity.");
- } else {
- LIBMTP_mtpdevice_t *device;
- device = get_device(backend, elements[1], G_VFS_JOB(job));
- if (device == NULL) {
- g_vfs_job_failed (G_VFS_JOB (job),
- G_IO_ERROR, G_IO_ERROR_FAILED,
- "Device does not exist");
- g_strfreev(elements);
- g_mutex_unlock (&G_VFS_BACKEND_MTP(backend)->mutex);
- return;
- }
+ goto exit;
+ }
- int ret = LIBMTP_Delete_Object(device, strtol(elements[ne-1], NULL, 10));
- if (ret != 0) {
- LIBMTP_Dump_Errorstack(device);
- LIBMTP_Clear_Errorstack(device);
- g_vfs_job_failed (G_VFS_JOB (job),
- G_IO_ERROR, G_IO_ERROR_FAILED,
- "Error while deleting entity.");
- } else {
- g_vfs_job_succeeded (G_VFS_JOB (job));
- }
+ LIBMTP_mtpdevice_t *device;
+ device = get_device(backend, elements[1], G_VFS_JOB(job));
+ if (device == NULL) {
+ g_vfs_job_failed (G_VFS_JOB (job),
+ G_IO_ERROR, G_IO_ERROR_FAILED,
+ "Device does not exist");
+ goto exit;
+ }
+
+ int ret = LIBMTP_Delete_Object(device, strtol(elements[ne-1], NULL, 10));
+ if (ret != 0) {
+ LIBMTP_Dump_Errorstack(device);
+ LIBMTP_Clear_Errorstack(device);
+ g_vfs_job_failed (G_VFS_JOB (job),
+ G_IO_ERROR, G_IO_ERROR_FAILED,
+ "Error while deleting entity.");
+ goto exit;
}
+ g_vfs_job_succeeded (G_VFS_JOB (job));
+
+ exit:
g_strfreev(elements);
g_mutex_unlock (&G_VFS_BACKEND_MTP(backend)->mutex);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]