diff options
Diffstat (limited to 'tools/crm_diff.c')
-rw-r--r-- | tools/crm_diff.c | 43 |
1 files changed, 12 insertions, 31 deletions
diff --git a/tools/crm_diff.c b/tools/crm_diff.c index efe2fcf..9925ea7 100644 --- a/tools/crm_diff.c +++ b/tools/crm_diff.c @@ -108,7 +108,7 @@ print_patch(xmlNode *patch) { char *buffer = dump_xml_formatted(patch); - printf("%s", pcmk__s(buffer, "<null>\n")); + printf("%s", buffer); free(buffer); fflush(stdout); } @@ -152,7 +152,7 @@ log_patch_cib_versions(xmlNode *patch) const char *digest = NULL; xml_patch_versions(patch, add, del); - fmt = crm_element_value(patch, "format"); + fmt = crm_element_value(patch, PCMK_XA_FORMAT); digest = crm_element_value(patch, XML_ATTR_DIGEST); if (add[2] != del[2] || add[1] != del[1] || add[0] != del[0]) { @@ -166,7 +166,7 @@ strip_patch_cib_version(xmlNode *patch, const char **vfields, size_t nvfields) { int format = 1; - crm_element_value_int(patch, "format", &format); + crm_element_value_int(patch, PCMK_XA_FORMAT, &format); if (format == 2) { xmlNode *version_xml = find_xml_node(patch, "version", FALSE); @@ -208,21 +208,13 @@ static int generate_patch(xmlNode *object_1, xmlNode *object_2, const char *xml_file_2, gboolean as_cib, gboolean no_version) { - xmlNode *output = NULL; - int rc = pcmk_rc_ok; - - pcmk__output_t *logger_out = NULL; - int out_rc = pcmk_rc_no_output; - int temp_rc = pcmk_rc_no_output; - const char *vfields[] = { XML_ATTR_GENERATION_ADMIN, XML_ATTR_GENERATION, XML_ATTR_NUMUPDATES, }; - rc = pcmk__log_output_new(&logger_out); - CRM_CHECK(rc == pcmk_rc_ok, return rc); + xmlNode *output = NULL; /* If we're ignoring the version, make the version information * identical, so it isn't detected as a change. */ @@ -244,21 +236,13 @@ generate_patch(xmlNode *object_1, xmlNode *object_2, const char *xml_file_2, output = xml_create_patchset(0, object_1, object_2, NULL, FALSE); - pcmk__output_set_log_level(logger_out, LOG_INFO); - out_rc = pcmk__xml_show_changes(logger_out, object_2); - + pcmk__log_xml_changes(LOG_INFO, object_2); xml_accept_changes(object_2); if (output == NULL) { - goto done; // rc == pcmk_rc_ok + return pcmk_rc_ok; // No changes } - /* pcmk_rc_error means there's non-empty diff. - * @COMPAT: Choose a more descriptive return code, like one that maps to - * CRM_EX_DIGEST? - */ - rc = pcmk_rc_error; - patchset_process_digest(output, object_1, object_2, as_cib); if (as_cib) { @@ -268,18 +252,15 @@ generate_patch(xmlNode *object_1, xmlNode *object_2, const char *xml_file_2, strip_patch_cib_version(output, vfields, PCMK__NELEM(vfields)); } - pcmk__output_set_log_level(logger_out, LOG_NOTICE); - temp_rc = logger_out->message(logger_out, "xml-patchset", output); - out_rc = pcmk__output_select_rc(out_rc, temp_rc); - + pcmk__log_xml_patchset(LOG_NOTICE, output); print_patch(output); free_xml(output); -done: - logger_out->finish(logger_out, pcmk_rc2exitc(out_rc), true, NULL); - pcmk__output_free(logger_out); - - return rc; + /* pcmk_rc_error means there's a non-empty diff. + * @COMPAT Choose a more descriptive return code, like one that maps to + * CRM_EX_DIGEST? + */ + return pcmk_rc_error; } static GOptionContext * |