File bsc#1207319-0001-Refactor-libpacemaker-unify-bailing-out-in-pcmk__inj.patch of Package pacemaker.29727
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_sched_transition.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
Index: pacemaker-2.1.2+20211124.ada5c3b36/lib/pacemaker/pcmk_sched_transition.c
===================================================================
--- pacemaker-2.1.2+20211124.ada5c3b36.orig/lib/pacemaker/pcmk_sched_transition.c
+++ pacemaker-2.1.2+20211124.ada5c3b36/lib/pacemaker/pcmk_sched_transition.c
@@ -157,6 +157,7 @@ inject_node_state(cib_t * cib_conn, cons
int rc = pcmk_ok;
xmlNode *cib_object = NULL;
char *xpath = crm_strdup_printf(NODE_TEMPLATE, node);
+ bool duplicate = false;
if (bringing_nodes_online) {
create_node_entry(cib_conn, node);
@@ -167,10 +168,8 @@ inject_node_state(cib_t * cib_conn, cons
if (cib_object && 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) {
@@ -195,7 +194,15 @@ inject_node_state(cib_t * cib_conn, cons
crm_trace("injecting node state for %s. rc is %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;
}