[Spice-devel] [spice-gtk 1/4] smartcard: Report failure when software reader is missing

Christophe Fergeau cfergeau at redhat.com
Wed Jun 19 08:33:24 PDT 2013


As there is no easy way to know if the SpiceSmartcardManager
has an associated software reader or not, it's better to report
failure instead of g_return_if_fail on attempts to use
spice_smartcard_manager_insert/remove_card with no software reader
available.
---
 gtk/smartcard-manager.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/gtk/smartcard-manager.c b/gtk/smartcard-manager.c
index 51f228a..3b86dfb 100644
--- a/gtk/smartcard-manager.c
+++ b/gtk/smartcard-manager.c
@@ -552,7 +552,8 @@ gboolean spice_smartcard_manager_insert_card(SpiceSmartcardManager *manager)
 {
     VCardEmulError status;
 
-    g_return_val_if_fail(manager->priv->software_reader != NULL, FALSE);
+    if (manager->priv->software_reader != NULL)
+        return FALSE;
 
     status = vcard_emul_force_card_insert(manager->priv->software_reader);
 
@@ -574,7 +575,8 @@ gboolean spice_smartcard_manager_remove_card(SpiceSmartcardManager *manager)
 {
     VCardEmulError status;
 
-    g_return_val_if_fail(manager->priv->software_reader != NULL, FALSE);
+    if (manager->priv->software_reader != NULL)
+        return FALSE;
 
     status = vcard_emul_force_card_remove(manager->priv->software_reader);
 
-- 
1.8.2.1



More information about the Spice-devel mailing list