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

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