File bsc#1207319-0001-Refactor-libpacemaker-unify-bailing-out-in-pcmk__inj.patch of Package pacemaker.29737
From 7e8c700c9b1bd39c98186dbd70ca8bbeba56eb1c Mon Sep 17 00:00:00 2001
From: "Gao,Yan" <ygao@suse.com>
Date: Wed, 25 Jan 2023 11:03:07 +0100
Subject: [PATCH 1/2] Refactor: libpacemaker: unify bailing out in
pcmk__inject_node()
For further reuse.
---
lib/pacemaker/pcmk_injections.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/lib/pacemaker/pcmk_injections.c b/lib/pacemaker/pcmk_injections.c
index 459e5b7a7..6b945199e 100644
--- a/lib/pacemaker/pcmk_injections.c
+++ b/lib/pacemaker/pcmk_injections.c
@@ -224,6 +224,7 @@ pcmk__inject_node(cib_t *cib_conn, const char *node, const char *uuid)
int rc = pcmk_ok;
xmlNode *cib_object = NULL;
char *xpath = crm_strdup_printf(XPATH_NODE_STATE, node);
+ bool duplicate = false;
if (pcmk__simulate_node_config) {
create_node_entry(cib_conn, node);
@@ -235,10 +236,8 @@ pcmk__inject_node(cib_t *cib_conn, const char *node, const char *uuid)
if ((cib_object != NULL) && (ID(cib_object) == NULL)) {
crm_err("Detected multiple node_state entries for xpath=%s, bailing",
xpath);
- crm_log_xml_warn(cib_object, "Duplicates");
- free(xpath);
- crm_exit(CRM_EX_SOFTWARE);
- return NULL; // not reached, but makes static analysis happy
+ duplicate = true;
+ goto done;
}
if (rc == -ENXIO) {
@@ -263,7 +262,15 @@ pcmk__inject_node(cib_t *cib_conn, const char *node, const char *uuid)
crm_trace("Injecting node state for %s (rc=%d)", node, rc);
}
+done:
free(xpath);
+
+ if (duplicate) {
+ crm_log_xml_warn(cib_object, "Duplicates");
+ crm_exit(CRM_EX_SOFTWARE);
+ return NULL; // not reached, but makes static analysis happy
+ }
+
CRM_ASSERT(rc == pcmk_ok);
return cib_object;
}
--
2.35.3