Skip to content

Commit

Permalink
Refactor: tools: Drop cib_xml_copy function arguments
Browse files Browse the repository at this point in the history
The caller doesn't set or use the contents, so it's clearer to use local
variables.

Signed-off-by: Reid Wahl <[email protected]>
  • Loading branch information
nrwahl2 committed Oct 31, 2024
1 parent 47237fb commit 9ff48f5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
26 changes: 13 additions & 13 deletions tools/crm_resource.c
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,7 @@ cleanup(pcmk__output_t *out, pcmk_resource_t *rsc, pcmk_node_t *node)
}

static int
clear_constraints(pcmk__output_t *out, xmlNodePtr *cib_xml_copy)
clear_constraints(pcmk__output_t *out)
{
GList *before = NULL;
GList *after = NULL;
Expand Down Expand Up @@ -945,19 +945,20 @@ clear_constraints(pcmk__output_t *out, xmlNodePtr *cib_xml_copy)
}

if (!out->is_quiet(out)) {
rc = cib_conn->cmds->query(cib_conn, NULL, cib_xml_copy, cib_sync_call);
xmlNode *cib_xml = NULL;

rc = cib_conn->cmds->query(cib_conn, NULL, &cib_xml, cib_sync_call);
rc = pcmk_legacy2rc(rc);

if (rc != pcmk_rc_ok) {
g_set_error(&error, PCMK__RC_ERROR, rc,
_("Could not get modified CIB: %s\n"), pcmk_rc_str(rc));
g_list_free(before);
pcmk__xml_free(*cib_xml_copy);
*cib_xml_copy = NULL;
pcmk__xml_free(cib_xml);
return rc;
}

scheduler->input = *cib_xml_copy;
scheduler->input = cib_xml;
cluster_status(scheduler);

after = build_constraint_list(scheduler->input);
Expand All @@ -976,11 +977,12 @@ clear_constraints(pcmk__output_t *out, xmlNodePtr *cib_xml_copy)
}

static int
initialize_scheduler_data(xmlNodePtr *cib_xml_copy)
initialize_scheduler_data(void)
{
xmlNode *cib_xml = NULL;
int rc = pcmk_rc_ok;

rc = cib_conn->cmds->query(cib_conn, NULL, cib_xml_copy, cib_sync_call);
rc = cib_conn->cmds->query(cib_conn, NULL, &cib_xml, cib_sync_call);
rc = pcmk_legacy2rc(rc);

if (rc == pcmk_rc_ok) {
Expand All @@ -990,13 +992,12 @@ initialize_scheduler_data(xmlNodePtr *cib_xml_copy)
} else {
pcmk__set_scheduler_flags(scheduler, pcmk__sched_no_counts);
scheduler->priv->out = out;
rc = update_scheduler_input(scheduler, cib_xml_copy);
rc = update_scheduler_input(scheduler, &cib_xml);
}
}

if (rc != pcmk_rc_ok) {
pcmk__xml_free(*cib_xml_copy);
*cib_xml_copy = NULL;
pcmk__xml_free(cib_xml);
return rc;
}

Expand Down Expand Up @@ -1442,7 +1443,6 @@ build_arg_context(pcmk__common_args_t *args, GOptionGroup **group) {
int
main(int argc, char **argv)
{
xmlNode *cib_xml_copy = NULL;
pcmk_resource_t *rsc = NULL;
pcmk_node_t *node = NULL;
uint32_t find_flags = 0;
Expand Down Expand Up @@ -1645,7 +1645,7 @@ main(int argc, char **argv)

// Populate scheduler data from XML file if specified or CIB query otherwise
if (is_scheduler_required()) {
rc = initialize_scheduler_data(&cib_xml_copy);
rc = initialize_scheduler_data();
if (rc != pcmk_rc_ok) {
exit_code = pcmk_rc2exitc(rc);
goto done;
Expand Down Expand Up @@ -1864,7 +1864,7 @@ main(int argc, char **argv)
break;

case cmd_clear:
rc = clear_constraints(out, &cib_xml_copy);
rc = clear_constraints(out);
break;

case cmd_move:
Expand Down
4 changes: 2 additions & 2 deletions tools/crm_resource_runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -1319,8 +1319,8 @@ static void display_list(pcmk__output_t *out, GList *items, const char *tag)
* \param[in,out] xml XML to use as input
*
* \return Standard Pacemaker return code
* \note On success, caller is responsible for freeing memory allocated for
* scheduler->priv->now.
* \note On success, \p scheduler takes ownership of \p xml, and the caller is
* responsible for freeing memory allocated for \c scheduler->priv->now.
*/
int
update_scheduler_input(pcmk_scheduler_t *scheduler, xmlNode **xml)
Expand Down

0 comments on commit 9ff48f5

Please sign in to comment.