pacemaker/0017-Refactor-libcrmcommon-avoid-new-as-variable-name.patch
Jan Pokorný 436eae4e1e
2.0.0-0.1.rc2 - Update for new upstream tarball
... for release candidate: Pacemaker-2.0.0-rc2,
  for full details, see included ChangeLog file or
  https://github.com/ClusterLabs/pacemaker/releases/tag/Pacemaker-2.0.0-rc2

Adapt spec file more akin to upstream version including:
. out-of-tree change from 1.1.18-2 build got subsumed (508ad52e7)
. %%{_sysconfdir}/pacemaker path got properly owned
  (-cli package; f6e3ab98d)
. -libs package started to properly declare Requires(pre): shadow-utils
  (293fcc1e8 + b3d49d210)
. some build conditionals and dependencies dropped for no longer
  (snmp, esmtp; f24bdc6f2 and 1f7374884, respectively) or never
  being relevant (~bison, byacc, flex; 61aef8af4)
. some dependencies were constrained with new or higher lower bounds:
  corosync needs to be of version 2+ unconditionally (ccd58fe29),
  ditto some others components (~GLib, 1ac2e7cbb), plus both 2 and 3
  versions of Python are now (comprehensively for the auxiliary
  functionality where used) supported upstream with the latter being
  a better fit (453355f8f)
. package descriptions got to reflect the drop of legacy low-level
  cluster infrastructures (55ab749bf)

Adapt spec file akin to current packaging guidelines including:
. drop some redundant/futile expressions (defattr, "-n %%{name}-libs"
  instead of plain "libs", "timezone hack"), add some notes for future
. make -cts and -doc packages noarch (former enabled with 088a5e7d4)
. simplify "systemd_requires" macro invocation, and relax it to
  "systemd_ordering" for -remote package where possible so as not
  to drag systemd into a lightweight system setup (e.g. container)
  needlessly
. adjust, in a compatible way, common ldconfig invocation with
  post{,un} scriptlets
  (https://fedoraproject.org/wiki/Changes/Removing_ldconfig_scriptlets)
. drop some more unuseful conditionals (upstart_job)

Apply some regression fixes on top as patches (PR #1457, #1459)

Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
2018-04-13 18:27:39 +02:00

197 lines
7.8 KiB
Diff

From 550a68817af8eaad45bfd001bba3782cba7e0d02 Mon Sep 17 00:00:00 2001
From: Ken Gaillot <kgaillot@redhat.com>
Date: Wed, 11 Apr 2018 10:35:31 -0500
Subject: [PATCH 17/17] Refactor: libcrmcommon: avoid "new" as variable name
confuses cppcheck
---
lib/common/xml.c | 69 +++++++++++++++++++++++++-----------------------
1 file changed, 36 insertions(+), 33 deletions(-)
diff --git a/lib/common/xml.c b/lib/common/xml.c
index 7781d48a0..0bb64e5fb 100644
--- a/lib/common/xml.c
+++ b/lib/common/xml.c
@@ -4040,19 +4040,19 @@ apply_xml_diff(xmlNode *old_xml, xmlNode * diff, xmlNode **new_xml)
}
static void
-__xml_diff_object(xmlNode * old, xmlNode * new)
+__xml_diff_object(xmlNode *old_xml, xmlNode *new_xml)
{
xmlNode *cIter = NULL;
xmlAttr *pIter = NULL;
- CRM_CHECK(new != NULL, return);
- if(old == NULL) {
- crm_node_created(new);
- __xml_acl_post_process(new); /* Check creation is allowed */
+ CRM_CHECK(new_xml != NULL, return);
+ if (old_xml == NULL) {
+ crm_node_created(new_xml);
+ __xml_acl_post_process(new_xml); // Check creation is allowed
return;
} else {
- xml_private_t *p = new->_private;
+ xml_private_t *p = new_xml->_private;
if(p->flags & xpf_processed) {
/* Avoid re-comparing nodes */
@@ -4061,39 +4061,40 @@ __xml_diff_object(xmlNode * old, xmlNode * new)
p->flags |= xpf_processed;
}
- for (pIter = crm_first_attr(new); pIter != NULL; pIter = pIter->next) {
+ for (pIter = crm_first_attr(new_xml); pIter != NULL; pIter = pIter->next) {
xml_private_t *p = pIter->_private;
/* Assume everything was just created and take it from there */
p->flags |= xpf_created;
}
- for (pIter = crm_first_attr(old); pIter != NULL; ) {
+ for (pIter = crm_first_attr(old_xml); pIter != NULL; ) {
xmlAttr *prop = pIter;
xml_private_t *p = NULL;
const char *name = (const char *)pIter->name;
- const char *old_value = crm_element_value(old, name);
- xmlAttr *exists = xmlHasProp(new, pIter->name);
+ const char *old_value = crm_element_value(old_xml, name);
+ xmlAttr *exists = xmlHasProp(new_xml, pIter->name);
pIter = pIter->next;
if(exists == NULL) {
- p = new->doc->_private;
+ p = new_xml->doc->_private;
/* Prevent the dirty flag being set recursively upwards */
clear_bit(p->flags, xpf_tracking);
- exists = xmlSetProp(new, (const xmlChar *)name, (const xmlChar *)old_value);
+ exists = xmlSetProp(new_xml, (const xmlChar *) name,
+ (const xmlChar *) old_value);
set_bit(p->flags, xpf_tracking);
p = exists->_private;
p->flags = 0;
- crm_trace("Lost %s@%s=%s", old->name, name, old_value);
- xml_remove_prop(new, name);
+ crm_trace("Lost %s@%s=%s", old_xml->name, name, old_value);
+ xml_remove_prop(new_xml, name);
} else {
int p_new = __xml_offset((xmlNode*)exists);
int p_old = __xml_offset((xmlNode*)prop);
- const char *value = crm_element_value(new, name);
+ const char *value = crm_element_value(new_xml, name);
p = exists->_private;
p->flags = (p->flags & ~xpf_created);
@@ -4102,16 +4103,18 @@ __xml_diff_object(xmlNode * old, xmlNode * new)
/* Restore the original value, so we can call crm_xml_add(),
* which checks ACLs
*/
- char *vcopy = crm_element_value_copy(new, name);
+ char *vcopy = crm_element_value_copy(new_xml, name);
- crm_trace("Modified %s@%s %s->%s", old->name, name, old_value, vcopy);
- xmlSetProp(new, prop->name, (const xmlChar *)old_value);
- crm_xml_add(new, name, vcopy);
+ crm_trace("Modified %s@%s %s->%s",
+ old_xml->name, name, old_value, vcopy);
+ xmlSetProp(new_xml, prop->name, (const xmlChar *) old_value);
+ crm_xml_add(new_xml, name, vcopy);
free(vcopy);
} else if(p_old != p_new) {
- crm_info("Moved %s@%s (%d -> %d)", old->name, name, p_old, p_new);
- __xml_node_dirty(new);
+ crm_info("Moved %s@%s (%d -> %d)",
+ old_xml->name, name, p_old, p_new);
+ __xml_node_dirty(new_xml);
p->flags |= xpf_dirty|xpf_moved;
if(p_old > p_new) {
@@ -4126,21 +4129,21 @@ __xml_diff_object(xmlNode * old, xmlNode * new)
}
}
- for (pIter = crm_first_attr(new); pIter != NULL; ) {
+ for (pIter = crm_first_attr(new_xml); pIter != NULL; ) {
xmlAttr *prop = pIter;
xml_private_t *p = pIter->_private;
pIter = pIter->next;
if(is_set(p->flags, xpf_created)) {
char *name = strdup((const char *)prop->name);
- char *value = crm_element_value_copy(new, name);
+ char *value = crm_element_value_copy(new_xml, name);
- crm_trace("Created %s@%s=%s", new->name, name, value);
+ crm_trace("Created %s@%s=%s", new_xml->name, name, value);
/* Remove plus create won't work as it will modify the relative attribute ordering */
- if(__xml_acl_check(new, name, xpf_acl_write)) {
+ if (__xml_acl_check(new_xml, name, xpf_acl_write)) {
crm_attr_dirty(prop);
} else {
- xmlUnsetProp(new, prop->name); /* Remove - change not allowed */
+ xmlUnsetProp(new_xml, prop->name); /* Remove - change not allowed */
}
free(value);
@@ -4148,9 +4151,9 @@ __xml_diff_object(xmlNode * old, xmlNode * new)
}
}
- for (cIter = __xml_first_child(old); cIter != NULL; ) {
+ for (cIter = __xml_first_child(old_xml); cIter != NULL; ) {
xmlNode *old_child = cIter;
- xmlNode *new_child = find_element(new, cIter, TRUE);
+ xmlNode *new_child = find_element(new_xml, cIter, TRUE);
cIter = __xml_next(cIter);
if(new_child) {
@@ -4158,7 +4161,7 @@ __xml_diff_object(xmlNode * old, xmlNode * new)
} else {
/* Create then free (which will check the acls if necessary) */
- xmlNode *candidate = add_node_copy(new, old_child);
+ xmlNode *candidate = add_node_copy(new_xml, old_child);
xmlNode *top = xmlDocGetRootElement(candidate->doc);
__xml_node_clean(candidate);
@@ -4166,7 +4169,7 @@ __xml_diff_object(xmlNode * old, xmlNode * new)
/* Record the old position */
free_xml_with_position(candidate, __xml_offset(old_child));
- if (find_element(new, old_child, TRUE) == NULL) {
+ if (find_element(new_xml, old_child, TRUE) == NULL) {
xml_private_t *p = old_child->_private;
p->flags |= xpf_skip;
@@ -4174,9 +4177,9 @@ __xml_diff_object(xmlNode * old, xmlNode * new)
}
}
- for (cIter = __xml_first_child(new); cIter != NULL; ) {
+ for (cIter = __xml_first_child(new_xml); cIter != NULL; ) {
xmlNode *new_child = cIter;
- xmlNode *old_child = find_element(old, cIter, TRUE);
+ xmlNode *old_child = find_element(old_xml, cIter, TRUE);
cIter = __xml_next(cIter);
if(old_child == NULL) {
@@ -4194,7 +4197,7 @@ __xml_diff_object(xmlNode * old, xmlNode * new)
crm_info("%s.%s moved from %d to %d",
new_child->name, ID(new_child), p_old, p_new);
- __xml_node_dirty(new);
+ __xml_node_dirty(new_xml);
p->flags |= xpf_moved;
if(p_old > p_new) {
--
2.17.0