[gnome-logs/wip/field-length: 2/4] Set a GError when calling gl_journal_get_data()



commit 0325f69e86d9bcb8790624c109f6da9bb23a75f6
Author: David King <davidk gnome org>
Date:   Wed Oct 23 18:13:03 2013 +0100

    Set a GError when calling gl_journal_get_data()

 src/gl-journal.c |   44 ++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 40 insertions(+), 4 deletions(-)
---
diff --git a/src/gl-journal.c b/src/gl-journal.c
index eb2d9b6..998440e 100644
--- a/src/gl-journal.c
+++ b/src/gl-journal.c
@@ -174,6 +174,7 @@ _gl_journal_query_result (GlJournal *self)
     GlJournalResult *result;
     gint ret;
     sd_journal *journal;
+    GError *error = NULL;
     gchar *priority;
 
     priv = gl_journal_get_instance_private (self);
@@ -230,15 +231,50 @@ _gl_journal_query_result (GlJournal *self)
         goto out;
     }
 
-    /* FIXME: Pass in a GError and check the result. */
-    result->comm = gl_journal_get_data (self, "_COMM", NULL);
-    result->kernel_device = gl_journal_get_data (self, "_KERNEL_DEVICE", NULL);
-    result->audit_session = gl_journal_get_data (self, "_AUDIT_SESSION", NULL);
     result->message = gl_journal_get_data (self, "MESSAGE", NULL);
+
+    if (error != NULL)
+    {
+        g_warning ("%s", error->message);
+        g_clear_error (&error);
+        free (result->cursor);
+        free (result->catalog);
+        goto out;
+    }
+
     priority = gl_journal_get_data (self, "PRIORITY", NULL);
+
+    if (error != NULL)
+    {
+        g_warning ("%s", error->message);
+        g_clear_error (&error);
+        free (result->cursor);
+        free (result->catalog);
+        g_free (result->message);
+        goto out;
+    }
+
     result->priority = atoi (priority);
     g_free (priority);
 
+    result->comm = gl_journal_get_data (self, "_COMM", &error);
+
+    if (error != NULL)
+    {
+        g_debug ("%s", error->message);
+        g_clear_error (&error);
+    }
+
+    result->kernel_device = gl_journal_get_data (self, "_KERNEL_DEVICE", NULL);
+
+    if (error != NULL)
+    {
+        g_debug ("%s", error->message);
+        g_clear_error (&error);
+    }
+
+    result->audit_session = gl_journal_get_data (self, "_AUDIT_SESSION", NULL);
+
     return result;
 
 out:


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