HomeClusterLabs Projects

Refactor: libcrmcommon: Simplify replace_xml_child() somewhat

Description

Refactor: libcrmcommon: Simplify replace_xml_child() somewhat

update == NULL can never happen thanks to the CRM_CHECK() at the top.
The later check causes some confusion, making it look as though either
delete_only==true or a update==NULL can trigger a deletion. In reality
only delete_only==true can do that.

There's no need for child_of_child or can_delete in the last block. We
can simply reassign parent as child, use a for-loop for improved
readability, return true if we find a match in a sub-tree, or return
false by default.

There are more simplifications coming. I'm breaking it up because this
function has been difficult to reason about in its current form.

Signed-off-by: Reid Wahl <nrwahl@protonmail.com>

Details

Provenance
nrwahl2Authored on Feb 11 2024, 5:08 AM
Parents
rPa966aeea6093: Merge pull request #3386 from nrwahl2/nrwahl2-xml_attrs2
Branches
Unknown
Tags
Unknown