Skip to content

Commit f4e20d3

Browse files
committed
Refactor: libcib: Move process_replace_xpath() downward
This will make the next commit easier to review. Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
1 parent da0e13c commit f4e20d3

1 file changed

Lines changed: 44 additions & 44 deletions

File tree

lib/cib/cib_ops.c

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -741,50 +741,6 @@ cib__process_query(const char *op, int options, const char *section,
741741
return process_query_section(options, section, *cib, answer);
742742
}
743743

744-
static int
745-
process_replace_xpath(const char *op, int options, const char *xpath,
746-
xmlNode *input, xmlNode *cib)
747-
{
748-
int num_results = 0;
749-
int rc = pcmk_rc_ok;
750-
xmlXPathObject *xpath_obj = pcmk__xpath_search(cib->doc, xpath);
751-
752-
num_results = pcmk__xpath_num_results(xpath_obj);
753-
if (num_results == 0) {
754-
pcmk__debug("%s: %s does not exist", op, xpath);
755-
rc = ENXIO;
756-
goto done;
757-
}
758-
759-
for (int i = 0; i < num_results; i++) {
760-
xmlNode *match = NULL;
761-
xmlNode *parent = NULL;
762-
xmlChar *path = NULL;
763-
764-
match = pcmk__xpath_result(xpath_obj, i);
765-
if (match == NULL) {
766-
continue;
767-
}
768-
769-
path = xmlGetNodePath(match);
770-
pcmk__debug("Processing %s op for %s with %s", op, xpath, path);
771-
free(path);
772-
773-
parent = match->parent;
774-
775-
pcmk__xml_free(match);
776-
pcmk__xml_copy(parent, input);
777-
778-
if (!pcmk__is_set(options, cib_multiple)) {
779-
break;
780-
}
781-
}
782-
783-
done:
784-
xmlXPathFreeObject(xpath_obj);
785-
return rc;
786-
}
787-
788744
static bool
789745
replace_cib_digest_matches(xmlNode *request, xmlNode *input)
790746
{
@@ -870,6 +826,50 @@ replace_cib(xmlNode *request, xmlNode *input, xmlNode **cib)
870826
return pcmk_rc_ok;
871827
}
872828

829+
static int
830+
process_replace_xpath(const char *op, int options, const char *xpath,
831+
xmlNode *input, xmlNode *cib)
832+
{
833+
int num_results = 0;
834+
int rc = pcmk_rc_ok;
835+
xmlXPathObject *xpath_obj = pcmk__xpath_search(cib->doc, xpath);
836+
837+
num_results = pcmk__xpath_num_results(xpath_obj);
838+
if (num_results == 0) {
839+
pcmk__debug("%s: %s does not exist", op, xpath);
840+
rc = ENXIO;
841+
goto done;
842+
}
843+
844+
for (int i = 0; i < num_results; i++) {
845+
xmlNode *match = NULL;
846+
xmlNode *parent = NULL;
847+
xmlChar *path = NULL;
848+
849+
match = pcmk__xpath_result(xpath_obj, i);
850+
if (match == NULL) {
851+
continue;
852+
}
853+
854+
path = xmlGetNodePath(match);
855+
pcmk__debug("Processing %s op for %s with %s", op, xpath, path);
856+
free(path);
857+
858+
parent = match->parent;
859+
860+
pcmk__xml_free(match);
861+
pcmk__xml_copy(parent, input);
862+
863+
if (!pcmk__is_set(options, cib_multiple)) {
864+
break;
865+
}
866+
}
867+
868+
done:
869+
xmlXPathFreeObject(xpath_obj);
870+
return rc;
871+
}
872+
873873
static int
874874
process_replace_section(const char *section, xmlNode *request, xmlNode *input,
875875
xmlNode **cib)

0 commit comments

Comments
 (0)