Blame 0161-cli-fix-testing-of-DBus-API-return-codes.patch

69165ba
From b5c28f6c7ce86fc53048d5c51a4850a82f48f876 Mon Sep 17 00:00:00 2001
69165ba
From: Jakub Filak <jfilak@redhat.com>
69165ba
Date: Tue, 11 Aug 2015 10:01:53 +0200
69165ba
Subject: [PATCH] cli: fix testing of DBus API return codes
69165ba
69165ba
The DBus wrapper functions uses ERR_PTR to report an error, so the
69165ba
callers has to test the returned pointers for NULL and for ERR_PTR.
69165ba
69165ba
Related: rhbz#1224984
69165ba
69165ba
Signed-off-by: Jakub Filak <jfilak@redhat.com>
69165ba
---
69165ba
 src/cli/list.c   | 3 +++
69165ba
 src/cli/status.c | 5 ++++-
69165ba
 2 files changed, 7 insertions(+), 1 deletion(-)
69165ba
69165ba
diff --git a/src/cli/list.c b/src/cli/list.c
69165ba
index c76e4fb..e688d2f 100644
69165ba
--- a/src/cli/list.c
69165ba
+++ b/src/cli/list.c
69165ba
@@ -36,6 +36,9 @@ static problem_data_t *load_problem_data(const char *problem_id)
69165ba
 
69165ba
     /* First, check if there is a problem with the passed id */
69165ba
     GList *problems = get_problems_over_dbus(g_cli_authenticate);
69165ba
+    if (problems == ERR_PTR)
69165ba
+        return NULL;
69165ba
+
69165ba
     GList *item = g_list_find_custom(problems, problem_id, (GCompareFunc)strcmp);
69165ba
 
69165ba
     /* (git requires at least 5 char hash prefix, we do the same) */
69165ba
diff --git a/src/cli/status.c b/src/cli/status.c
69165ba
index 0635289..3620cea 100644
69165ba
--- a/src/cli/status.c
69165ba
+++ b/src/cli/status.c
69165ba
@@ -27,6 +27,9 @@ static unsigned int count_problem_dirs(unsigned long since)
69165ba
     unsigned count = 0;
69165ba
 
69165ba
     GList *problems = get_problems_over_dbus(g_cli_authenticate);
69165ba
+    if (problems == ERR_PTR)
69165ba
+        return count;
69165ba
+
69165ba
     for (GList *iter = problems; iter != NULL; iter = g_list_next(iter))
69165ba
     {
69165ba
         const char *problem_id = (const char *)iter->data;
69165ba
@@ -37,7 +40,7 @@ static unsigned int count_problem_dirs(unsigned long since)
69165ba
         }
69165ba
 
69165ba
         char *time_str = load_text_over_dbus(problem_id, FILENAME_LAST_OCCURRENCE);
69165ba
-        if (time_str == NULL)
69165ba
+        if (time_str == ERR_PTR || time_str == NULL)
69165ba
         {
69165ba
             log_debug("Not counting problem %s: failed to get time element", problem_id);
69165ba
             continue;
69165ba
-- 
69165ba
2.4.3
69165ba