[gnome-settings-daemon] smartcard: Fix a g_task_return_error(task, NULL) call
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon] smartcard: Fix a g_task_return_error(task, NULL) call
- Date: Tue, 24 Jan 2017 09:59:32 +0000 (UTC)
commit b719bc0999998508b14ad8b05412fd7431bcd4f3
Author: Philip Withnall <withnall endlessm com>
Date: Thu Jan 19 20:24:28 2017 +0000
smartcard: Fix a g_task_return_error(task, NULL) call
It’s possible for activate_all_drivers_async_finish() to return FALSE
without an error set, in the case that there were no drivers to activate
(but there were no errors either).
Fix it to return a new error code
(GSD_SMARTCARD_MANAGER_ERROR_NO_DRIVERS) in that case, to preserve the
invariant that a FALSE return value means an error, thus fixing a
warning I saw in my journal:
gnome-settings-[641]: g_task_return_error: assertion 'error != NULL' failed
https://bugzilla.gnome.org/show_bug.cgi?id=777508
plugins/smartcard/gsd-smartcard-manager.c | 6 +++++-
plugins/smartcard/gsd-smartcard-manager.h | 3 ++-
2 files changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/plugins/smartcard/gsd-smartcard-manager.c b/plugins/smartcard/gsd-smartcard-manager.c
index 7fef9c5..a624542 100644
--- a/plugins/smartcard/gsd-smartcard-manager.c
+++ b/plugins/smartcard/gsd-smartcard-manager.c
@@ -511,7 +511,9 @@ try_to_complete_all_drivers_activation (GTask *task)
if (operation->activated_drivers_count > 0)
g_task_return_boolean (task, TRUE);
else
- g_task_return_boolean (task, FALSE);
+ g_task_return_new_error (task, GSD_SMARTCARD_MANAGER_ERROR,
+ GSD_SMARTCARD_MANAGER_ERROR_NO_DRIVERS,
+ "No smartcards exist to be activated.");
g_object_unref (task);
}
@@ -581,6 +583,8 @@ activate_all_drivers_async (GsdSmartcardManager *self,
try_to_complete_all_drivers_activation (task);
}
+/* Will error with %GSD_SMARTCARD_MANAGER_ERROR_NO_DRIVERS if there were no
+ * drivers to activate.. */
static gboolean
activate_all_drivers_async_finish (GsdSmartcardManager *self,
GAsyncResult *result,
diff --git a/plugins/smartcard/gsd-smartcard-manager.h b/plugins/smartcard/gsd-smartcard-manager.h
index 935c35d..13eb403 100644
--- a/plugins/smartcard/gsd-smartcard-manager.h
+++ b/plugins/smartcard/gsd-smartcard-manager.h
@@ -60,7 +60,8 @@ typedef enum
GSD_SMARTCARD_MANAGER_ERROR_LOADING_DRIVER,
GSD_SMARTCARD_MANAGER_ERROR_WATCHING_FOR_EVENTS,
GSD_SMARTCARD_MANAGER_ERROR_REPORTING_EVENTS,
- GSD_SMARTCARD_MANAGER_ERROR_FINDING_SMARTCARD
+ GSD_SMARTCARD_MANAGER_ERROR_FINDING_SMARTCARD,
+ GSD_SMARTCARD_MANAGER_ERROR_NO_DRIVERS,
} GsdSmartcardManagerError;
GType gsd_smartcard_manager_get_type (void);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]