Blame SOURCES/Fix-error-handling-in-gp_config_from_dir.patch

c530df
From 8603c619ca9bc923534d83ee432ddd756f285d4c Mon Sep 17 00:00:00 2001
c530df
From: Alexander Scheel <ascheel@redhat.com>
c530df
Date: Wed, 12 Jul 2017 09:26:52 -0400
c530df
Subject: [PATCH] Fix error handling in gp_config_from_dir
c530df
c530df
Signed-off-by: Alexander Scheel <ascheel@redhat.com>
c530df
[rharwood@redhat.com: c99, refactor some existing code]
c530df
Reviewed-by: Robbie Harwood <rharwood@redhat.com>
c530df
Merges: #204
c530df
(cherry picked from commit eb880e93ed4a48c67ac27b4d5194f0f7786da83e)
c530df
---
c530df
 proxy/src/gp_config.c | 24 ++++++++++++++----------
c530df
 1 file changed, 14 insertions(+), 10 deletions(-)
c530df
c530df
diff --git a/proxy/src/gp_config.c b/proxy/src/gp_config.c
c530df
index 8fd60a3..07f7c8d 100644
c530df
--- a/proxy/src/gp_config.c
c530df
+++ b/proxy/src/gp_config.c
c530df
@@ -798,17 +798,21 @@ static int gp_config_from_dir(const char *config_dir,
c530df
                              &error_list,
c530df
                              NULL);
c530df
     if (ret) {
c530df
-        if (error_list) {
c530df
-            uint32_t i;
c530df
-            uint32_t len = ref_array_getlen(error_list, &i);
c530df
-            for (i = 0; i < len; i++) {
c530df
-                GPDEBUG("Error when reading config directory: %s\n",
c530df
-                        (const char *) ref_array_get(error_list, i, NULL));
c530df
-            }
c530df
-            ref_array_destroy(error_list);
c530df
-        } else {
c530df
-            GPDEBUG("Error when reading config directory number: %d\n", ret);
c530df
+        uint32_t len;
c530df
+
c530df
+        if (!error_list) {
c530df
+            GPAUDIT("Error when reading config directory number: %d\n", ret);
c530df
+            return ret;
c530df
         }
c530df
+
c530df
+        len = ref_array_len(error_list);
c530df
+        for (uint32_t i = 0; i < len; i++) {
c530df
+            /* libini has an unfixable bug where error strings are (char **) */
c530df
+            GPAUDIT("Error when reading config directory: %s\n",
c530df
+                    *(char **)ref_array_get(error_list, i, NULL));
c530df
+        }
c530df
+
c530df
+        ref_array_destroy(error_list);
c530df
         return ret;
c530df
     }
c530df