36fd7e2
From 0c3a29b70992627481af789dab50247728bcedf1 Mon Sep 17 00:00:00 2001
36fd7e2
From: Jakub Filak <jfilak@redhat.com>
36fd7e2
Date: Tue, 11 Aug 2015 09:54:55 +0200
36fd7e2
Subject: [PATCH] dbus-api: unify reporting of errors
36fd7e2
36fd7e2
User ERR_PTR for failures in all functions because some of the functions
36fd7e2
use NULL as a valid response (NULL is an empty GList).
36fd7e2
36fd7e2
Related: rhbz#1224984
36fd7e2
36fd7e2
Signed-off-by: Jakub Filak <jfilak@redhat.com>
36fd7e2
---
36fd7e2
 src/include/libabrt.h      | 16 +++++++++-------
36fd7e2
 src/lib/problem_api_dbus.c |  2 +-
36fd7e2
 2 files changed, 10 insertions(+), 8 deletions(-)
36fd7e2
36fd7e2
diff --git a/src/include/libabrt.h b/src/include/libabrt.h
36fd7e2
index 4e73a0d..da565f9 100644
36fd7e2
--- a/src/include/libabrt.h
36fd7e2
+++ b/src/include/libabrt.h
36fd7e2
@@ -163,7 +163,7 @@ void koops_print_suspicious_strings_filtered(const regex_t **filterout);
36fd7e2
 
36fd7e2
   Requires authorization
36fd7e2
 
36fd7e2
-  @return 0 if successfull non-zeru on failure
36fd7e2
+  @return 0 if successful; non-zero on failure
36fd7e2
 */
36fd7e2
 int chown_dir_over_dbus(const char *problem_dir_path);
36fd7e2
 
36fd7e2
@@ -181,7 +181,7 @@ int test_exist_over_dbus(const char *problem_id, const char *element_name);
36fd7e2
 
36fd7e2
   Might require authorization
36fd7e2
 
36fd7e2
-  @return Positive number if such the proble is complete, 0 if doesn't and negative number if an error occurs.
36fd7e2
+  @return Positive number if the problem is complete, 0 if doesn't and negative number if an error occurs.
36fd7e2
  */
36fd7e2
 int dbus_problem_is_complete(const char *problem_id);
36fd7e2
 
36fd7e2
@@ -198,7 +198,8 @@ char *load_text_over_dbus(const char *problem_id, const char *element_name);
36fd7e2
  @brief Delets multiple problems specified by their id (as returned from problem_data_save)
36fd7e2
 
36fd7e2
  @param problem_dir_paths List of problem ids
36fd7e2
- @return 0 if operation was successfull, non-zero on failure
36fd7e2
+
36fd7e2
+ @return 0 if operation was successful, non-zero on failure
36fd7e2
 */
36fd7e2
 
36fd7e2
 int delete_problem_dirs_over_dbus(const GList *problem_dir_paths);
36fd7e2
@@ -206,21 +207,21 @@ int delete_problem_dirs_over_dbus(const GList *problem_dir_paths);
36fd7e2
 /**
36fd7e2
   @brief Fetches given problem elements for specified problem id
36fd7e2
 
36fd7e2
-  @return on failures returns non zero value and emits error message
36fd7e2
+  @return returns non-zero value on failures and prints error message
36fd7e2
 */
36fd7e2
 int fill_problem_data_over_dbus(const char *problem_dir_path, const char **elements, problem_data_t *problem_data);
36fd7e2
 
36fd7e2
 /**
36fd7e2
   @brief Fetches problem information for specified problem id
36fd7e2
 
36fd7e2
-  @return problem_data_t or NULL on failure
36fd7e2
+  @return a valid pointer to problem_data_t or ERR_PTR on failure
36fd7e2
 */
36fd7e2
 problem_data_t *get_problem_data_dbus(const char *problem_dir_path);
36fd7e2
 
36fd7e2
 /**
36fd7e2
   @brief Fetches full problem data for specified problem id
36fd7e2
 
36fd7e2
-  @return problem_data_t or ERR_PTR on failure
36fd7e2
+  @return a valid pointer to problem_data_t or ERR_PTR on failure
36fd7e2
 */
36fd7e2
 problem_data_t *get_full_problem_data_over_dbus(const char *problem_dir_path);
36fd7e2
 
36fd7e2
@@ -228,7 +229,8 @@ problem_data_t *get_full_problem_data_over_dbus(const char *problem_dir_path);
36fd7e2
   @brief Fetches all problems from problem database
36fd7e2
 
36fd7e2
   @param authorize If set to true will try to fetch even problems owned by other users (will require root authorization over policy kit)
36fd7e2
-  @return List of problem ids or NULL on failure
36fd7e2
+
36fd7e2
+  @return List of problem ids or ERR_PTR on failure (NULL is an empty list)
36fd7e2
 */
36fd7e2
 GList *get_problems_over_dbus(bool authorize);
36fd7e2
 
36fd7e2
diff --git a/src/lib/problem_api_dbus.c b/src/lib/problem_api_dbus.c
36fd7e2
index ce5c47b..0bf86e2 100644
36fd7e2
--- a/src/lib/problem_api_dbus.c
36fd7e2
+++ b/src/lib/problem_api_dbus.c
36fd7e2
@@ -165,7 +165,7 @@ problem_data_t *get_problem_data_dbus(const char *problem_dir_path)
36fd7e2
     {
36fd7e2
         error_msg(_("Can't get problem data from abrt-dbus"));
36fd7e2
         problem_data_free(pd);
36fd7e2
-        return NULL;
36fd7e2
+        return ERR_PTR;
36fd7e2
     }
36fd7e2
 
36fd7e2
     return pd;
36fd7e2
-- 
36fd7e2
2.4.3
36fd7e2