lslebodn / rpms / ding-libs

Forked from rpms/ding-libs 6 years ago
Clone
Blob Blame History Raw
From f4249d9eb263992f2804f8dc65de68e0964f9d1c Mon Sep 17 00:00:00 2001
From: Alexander Scheel <ascheel@redhat.com>
Date: Thu, 3 Aug 2017 08:14:02 -0400
Subject: [PATCH] INI: Add INI_MS_DETECT merge notifications
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

In ini_config_augment, INI_MS_DETECT is supposed to detect
duplicate sections. Previously this was exposed only as
a return status of EEXIST. This updates the behavior to
return an error_list with warnings of files containing
one or more duplicate sections.

Signed-off-by: Alexander Scheel <ascheel@redhat.com>
Reviewed-by: Michal Židek <mzidek@redhat.com>

Merges: https://pagure.io/SSSD/ding-libs/issue/3167
(cherry picked from commit fd539954e68ae49e6670f49e3ff3300cac3e4739)
---
 ini/ini_augment.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/ini/ini_augment.c b/ini/ini_augment.c
index 8e57c6a..0855381 100644
--- a/ini/ini_augment.c
+++ b/ini/ini_augment.c
@@ -185,7 +185,7 @@ static int ini_aug_regex_prepare(const char *patterns[],
                 ini_aug_add_string(ra_err,
                                    "Failed to process expression: %s."
                                    " Compilation returned error: %s",
-                                   *pat, err_str);
+                                   pat, err_str);
                 free(err_str);
 
                 /* All error processing is done - advance to next pattern */
@@ -814,6 +814,8 @@ static int ini_aug_apply(struct ini_cfgobj *cfg,
                        ((merge_flags & INI_MV2S_MASK) == INI_MV2S_DETECT)))) {
                         TRACE_ERROR_NUMBER("Got error in detect mode", error);
                         /* Fall through! */
+                    ini_aug_add_string(ra_err, "Duplicate section detected "
+                                       "in snippet: %s.", snip_name);
                 }
                 else {
                     ini_aug_add_string(ra_err,
@@ -944,14 +946,6 @@ int ini_config_augment(struct ini_cfgobj *base_cfg,
                           ra_err,
                           ra_ok,
                           result_cfg);
-    if (error) {
-        TRACE_ERROR_NUMBER("Failed to process snippet list.",
-                           error);
-        ref_array_destroy(ra_list);
-        ref_array_destroy(ra_err);
-        ref_array_destroy(ra_ok);
-        return error;
-    }
 
     /* Cleanup */
     ref_array_destroy(ra_list);
-- 
2.13.2