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

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