[next] telepathy-glib: logger: don't assume @error is not NULL

Guillaume Desmottes gdesmott at kemper.freedesktop.org
Mon May 26 05:16:00 PDT 2014


Module: telepathy-glib
Branch: next
Commit: 1a6710c4fcea8e043c8bf62585152f192d8de973
URL:    http://cgit.freedesktop.org/telepathy/telepathy-glib/commit/?id=1a6710c4fcea8e043c8bf62585152f192d8de973

Author: Guillaume Desmottes <guillaume.desmottes at collabora.co.uk>
Date:   Wed May 21 10:53:34 2014 +0200

logger: don't assume @error is not NULL

https://bugs.freedesktop.org/show_bug.cgi?id=79006

---

 telepathy-logger/log-store-sqlite.c |   15 ++++++++-------
 telepathy-logger/log-store-xml.c    |    3 ++-
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/telepathy-logger/log-store-sqlite.c b/telepathy-logger/log-store-sqlite.c
index 53c1a76..44cf6b2 100644
--- a/telepathy-logger/log-store-sqlite.c
+++ b/telepathy-logger/log-store-sqlite.c
@@ -534,8 +534,8 @@ out:
     sqlite3_finalize (sql);
 
   /* check that we set an error if appropriate */
-  g_assert ((retval == TRUE && *error == NULL) ||
-            (retval == FALSE && *error != NULL));
+  g_assert ((retval == TRUE && (error == NULL || *error == NULL)) ||
+            (retval == FALSE && (error == NULL || *error != NULL)));
 
   return retval;
 }
@@ -579,8 +579,8 @@ tpl_log_store_sqlite_add_event (TplLogStore *self,
 
 out:
   /* check that we set an error if appropriate */
-  g_assert ((retval == TRUE && *error == NULL) ||
-            (retval == FALSE && *error != NULL));
+  g_assert ((retval == TRUE && (error == NULL || *error == NULL)) ||
+            (retval == FALSE && (error == NULL || *error != NULL)));
 
   DEBUG ("returning with %d", retval);
   return retval;
@@ -746,7 +746,8 @@ out:
   /* check that we set an error if appropriate
    * NOTE: retval == NULL && *error !=
    * NULL doesn't apply to this method, since NULL is also for an empty list */
-  g_assert ((retval != NULL && *error == NULL) || retval == NULL);
+  g_assert ((retval != NULL && (error == NULL || *error == NULL)) ||
+      retval == NULL);
 
   return retval;
 }
@@ -903,8 +904,8 @@ out:
     sqlite3_finalize (sql);
 
   /* check that we set an error if appropriate */
-  g_assert ((retval == TRUE && *error == NULL) ||
-            (retval == FALSE && *error != NULL));
+  g_assert ((retval == TRUE && (error == NULL || *error == NULL)) ||
+            (retval == FALSE && (error == NULL || *error != NULL)));
 
   return retval;
 }
diff --git a/telepathy-logger/log-store-xml.c b/telepathy-logger/log-store-xml.c
index 22acfe8..8021fb9 100644
--- a/telepathy-logger/log-store-xml.c
+++ b/telepathy-logger/log-store-xml.c
@@ -451,7 +451,8 @@ add_text_event (TplLogStoreXml *self,
   bus_connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, error);
   if (bus_connection == NULL)
     {
-      DEBUG ("Error acquiring bus connection: %s", (*error)->message);
+      DEBUG ("Error acquiring bus connection: %s",
+          error != NULL ? (*error)->message : "(no GError available)");
       goto out;
     }
 



More information about the telepathy-commits mailing list