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