diff --git a/cts/cli/regression.dates.exp b/cts/cli/regression.dates.exp index b72d92ae688..bb0378ab81d 100644 --- a/cts/cli/regression.dates.exp +++ b/cts/cli/regression.dates.exp @@ -64,7 +64,7 @@ iso8601: Invalid interval specified: P1Y/2019-02-29 00:00:00Z =#=#=#= End test: Invalid period - [P1Y/2019-02-29 00:00:00Z] - Invalid parameter (2) =#=#=#= * Passed: iso8601 - Invalid period - [P1Y/2019-02-29 00:00:00Z] =#=#=#= Begin test: Invalid period - [2019-01-01 00:00:00Z/P] =#=#=#= -crm_time_parse_duration error: 'P' is not a valid ISO 8601 time duration because nothing follows 'P' +pcmk__time_parse_duration error: 'P' is not a valid ISO 8601 time duration because nothing follows 'P' iso8601: Invalid interval specified: 2019-01-01 00:00:00Z/P =#=#=#= End test: Invalid period - [2019-01-01 00:00:00Z/P] - Invalid parameter (2) =#=#=#= * Passed: iso8601 - Invalid period - [2019-01-01 00:00:00Z/P] diff --git a/cts/cts-cli.in b/cts/cts-cli.in index 8f557ce4b45..b111a6055b7 100644 --- a/cts/cts-cli.in +++ b/cts/cts-cli.in @@ -251,7 +251,6 @@ def sanitize_output(s): (r'(requested), v->current); + pcmk__str_update(&v->requested, v->current); } if (private_updates) { diff --git a/daemons/controld/controld_control.c b/daemons/controld/controld_control.c index fece662991c..f05401f88ab 100644 --- a/daemons/controld/controld_control.c +++ b/daemons/controld/controld_control.c @@ -65,7 +65,7 @@ do_ha_control(long long action, enum crmd_fsa_cause cause, controld_election_init(); - pcmk__str_update(&(controld_globals.our_uuid), + pcmk__str_update(&controld_globals.our_uuid, pcmk__cluster_get_xml_id(node)); if (controld_globals.our_uuid == NULL) { @@ -614,7 +614,7 @@ config_query_callback(xmlNode * msg, int call_id, int rc, xmlNode * output, void controld_globals.node_pending_timeout /= 1000; value = g_hash_table_lookup(config_hash, PCMK_OPT_CLUSTER_NAME); - pcmk__str_update(&(controld_globals.cluster_name), value); + pcmk__str_update(&controld_globals.cluster_name, value); // Let subcomponents initialize their own static variables controld_configure_election(config_hash); diff --git a/daemons/controld/controld_execd.c b/daemons/controld/controld_execd.c index 4c33460cac0..b7ad0cf699a 100644 --- a/daemons/controld/controld_execd.c +++ b/daemons/controld/controld_execd.c @@ -559,12 +559,12 @@ build_active_RAs(lrm_state_t * lrm_state, xmlNode * rsc_list) pcmk__xe_set(xml_rsc, PCMK__META_CONTAINER, container); } } - controld_add_resource_history_xml(xml_rsc, &(entry->rsc), entry->failed, + controld_add_resource_history_xml(xml_rsc, &entry->rsc, entry->failed, lrm_state->node_name); - controld_add_resource_history_xml(xml_rsc, &(entry->rsc), entry->last, + controld_add_resource_history_xml(xml_rsc, &entry->rsc, entry->last, lrm_state->node_name); for (gIter = entry->recurring_op_list; gIter != NULL; gIter = gIter->next) { - controld_add_resource_history_xml(xml_rsc, &(entry->rsc), gIter->data, + controld_add_resource_history_xml(xml_rsc, &entry->rsc, gIter->data, lrm_state->node_name); } } @@ -1627,7 +1627,7 @@ construct_op(const lrm_state_t *lrm_state, const xmlNode *rsc_op, pcmk__scan_min_int(op_timeout, &op->timeout, 0); if (pcmk__uint_from_hash(params, CRM_META "_" PCMK_META_INTERVAL, 0, - &(op->interval_ms)) != pcmk_rc_ok) { + &op->interval_ms) != pcmk_rc_ok) { op->interval_ms = 0; } @@ -2017,7 +2017,7 @@ do_lrm_rsc_op(lrm_state_t *lrm_state, lrmd_rsc_info_t *rsc, xmlNode *msg, pending->rsc_id = pcmk__str_copy(rsc->id); pending->start_time = time(NULL); pending->user_data = pcmk__str_copy(op->user_data); - pcmk__xe_get_time(msg, PCMK_OPT_SHUTDOWN_LOCK, &(pending->lock_time)); + pcmk__xe_get_time(msg, PCMK_OPT_SHUTDOWN_LOCK, &pending->lock_time); g_hash_table_replace(lrm_state->active_ops, call_id_s, pending); if ((op->interval_ms > 0) diff --git a/daemons/controld/controld_remote_ra.c b/daemons/controld/controld_remote_ra.c index 23a5512d3df..06d5b4e17e9 100644 --- a/daemons/controld/controld_remote_ra.c +++ b/daemons/controld/controld_remote_ra.c @@ -105,7 +105,7 @@ free_cmd(void *user_data) free(cmd->rsc_id); free(cmd->action); free(cmd->userdata); - pcmk__reset_result(&(cmd->result)); + pcmk__reset_result(&cmd->result); lrmd_key_value_freeall(cmd->params); free(cmd); } @@ -344,7 +344,7 @@ static void check_remote_node_state(const remote_ra_cmd_t *cmd) { /* Only successful actions can change node state */ - if (!pcmk__result_ok(&(cmd->result))) { + if (!pcmk__result_ok(&cmd->result)) { return; } @@ -416,7 +416,7 @@ report_remote_ra_result(remote_ra_cmd_t * cmd) cmd->result.exit_reason); if (pcmk__is_set(cmd->status, cmd_reported_success) - && !pcmk__result_ok(&(cmd->result))) { + && !pcmk__result_ok(&cmd->result)) { op.t_rcchange = time(NULL); /* This edge case will likely never ever occur, but if it does the @@ -486,7 +486,7 @@ retry_start_cmd_cb(void *data) if (remaining > 0) { rc = handle_remote_ra_start(lrm_state, cmd, remaining * 1000); } else { - pcmk__set_result(&(cmd->result), PCMK_OCF_UNKNOWN_ERROR, + pcmk__set_result(&cmd->result, PCMK_OCF_UNKNOWN_ERROR, PCMK_EXEC_TIMEOUT, "Not enough time remains to retry remote connection"); } @@ -535,7 +535,7 @@ monitor_timeout_cb(void *data) pcmk__info("Timed out waiting for remote poke response from %s%s", cmd->rsc_id, ((lrm_state != NULL)? "" : " (no LRM state)")); cmd->monitor_timeout_id = 0; - pcmk__set_result(&(cmd->result), PCMK_OCF_UNKNOWN_ERROR, PCMK_EXEC_TIMEOUT, + pcmk__set_result(&cmd->result, PCMK_OCF_UNKNOWN_ERROR, PCMK_EXEC_TIMEOUT, "Remote executor did not respond"); if (lrm_state && lrm_state->remote_ra_data) { @@ -676,7 +676,7 @@ remote_lrm_op_callback(lrmd_event_data_t * op) if ((op->connection_rc == -ENOKEY) || (op->connection_rc == -EKEYREJECTED)) { // Hard error, don't retry - pcmk__set_result(&(cmd->result), PCMK_OCF_INVALID_PARAM, + pcmk__set_result(&cmd->result, PCMK_OCF_INVALID_PARAM, PCMK_EXEC_ERROR, pcmk_strerror(op->connection_rc)); @@ -690,7 +690,7 @@ remote_lrm_op_callback(lrmd_event_data_t * op) pcmk__trace("Not enough time before timeout (%ds) to " "reschedule start", remaining); - pcmk__format_result(&(cmd->result), PCMK_OCF_UNKNOWN_ERROR, + pcmk__format_result(&cmd->result, PCMK_OCF_UNKNOWN_ERROR, PCMK_EXEC_TIMEOUT, "%s without enough time to retry", pcmk_strerror(op->connection_rc)); @@ -698,7 +698,7 @@ remote_lrm_op_callback(lrmd_event_data_t * op) } else { lrm_state_reset_tables(lrm_state, TRUE); - pcmk__set_result(&(cmd->result), PCMK_OCF_OK, PCMK_EXEC_DONE, NULL); + pcmk__set_result(&cmd->result, PCMK_OCF_OK, PCMK_EXEC_DONE, NULL); lrm_remote_set_flags(lrm_state, remote_active); } @@ -719,7 +719,7 @@ remote_lrm_op_callback(lrmd_event_data_t * op) * For this function, if we get the poke pack, it is always a success. Pokes * only fail if the send fails, or the response times out. */ if (!pcmk__is_set(cmd->status, cmd_reported_success)) { - pcmk__set_result(&(cmd->result), PCMK_OCF_OK, PCMK_EXEC_DONE, NULL); + pcmk__set_result(&cmd->result, PCMK_OCF_OK, PCMK_EXEC_DONE, NULL); report_remote_ra_result(cmd); cmd_set_flags(cmd, cmd_reported_success); } @@ -741,7 +741,7 @@ remote_lrm_op_callback(lrmd_event_data_t * op) if (pcmk__is_set(ra_data->status, remote_active) && !pcmk__is_set(cmd->status, cmd_cancel)) { - pcmk__set_result(&(cmd->result), PCMK_OCF_UNKNOWN_ERROR, + pcmk__set_result(&cmd->result, PCMK_OCF_UNKNOWN_ERROR, PCMK_EXEC_ERROR, "Remote connection unexpectedly dropped " "during monitor"); @@ -791,7 +791,7 @@ handle_remote_ra_stop(lrm_state_t * lrm_state, remote_ra_cmd_t * cmd) lrm_state->remote_ra_data->cur_cmd = NULL; if (cmd) { - pcmk__set_result(&(cmd->result), PCMK_OCF_OK, PCMK_EXEC_DONE, NULL); + pcmk__set_result(&cmd->result, PCMK_OCF_OK, PCMK_EXEC_DONE, NULL); report_remote_ra_result(cmd); } } @@ -825,7 +825,7 @@ handle_remote_ra_start(lrm_state_t * lrm_state, remote_ra_cmd_t * cmd, int timeo rc = controld_connect_remote_executor(lrm_state, server, port, timeout_used); if (rc != pcmk_rc_ok) { - pcmk__format_result(&(cmd->result), PCMK_OCF_UNKNOWN_ERROR, + pcmk__format_result(&cmd->result, PCMK_OCF_UNKNOWN_ERROR, PCMK_EXEC_ERROR, "Could not connect to Pacemaker Remote node %s: %s", lrm_state->node_name, pcmk_rc_str(rc)); @@ -877,12 +877,12 @@ handle_remote_ra_exec(void *user_data) if (lrm_state_is_connected(lrm_state) == TRUE) { rc = lrm_state_poke_connection(lrm_state); if (rc < 0) { - pcmk__set_result(&(cmd->result), PCMK_OCF_UNKNOWN_ERROR, + pcmk__set_result(&cmd->result, PCMK_OCF_UNKNOWN_ERROR, PCMK_EXEC_ERROR, pcmk_strerror(rc)); } } else { rc = -1; - pcmk__set_result(&(cmd->result), PCMK_OCF_NOT_RUNNING, + pcmk__set_result(&cmd->result, PCMK_OCF_NOT_RUNNING, PCMK_EXEC_DONE, "Remote connection inactive"); } @@ -918,7 +918,7 @@ handle_remote_ra_exec(void *user_data) } else if (strcmp(cmd->action, PCMK_ACTION_MIGRATE_TO) == 0) { lrm_remote_clear_flags(lrm_state, takeover_complete); lrm_remote_set_flags(lrm_state, expect_takeover); - pcmk__set_result(&(cmd->result), PCMK_OCF_OK, PCMK_EXEC_DONE, NULL); + pcmk__set_result(&cmd->result, PCMK_OCF_OK, PCMK_EXEC_DONE, NULL); report_remote_ra_result(cmd); } else if (pcmk__str_any_of(cmd->action, PCMK_ACTION_RELOAD, @@ -932,7 +932,7 @@ handle_remote_ra_exec(void *user_data) * of "reload-agent". An OCF 1.1 "reload" would be a no-op anyway, * so this would work for that purpose as well. */ - pcmk__set_result(&(cmd->result), PCMK_OCF_OK, PCMK_EXEC_DONE, NULL); + pcmk__set_result(&cmd->result, PCMK_OCF_OK, PCMK_EXEC_DONE, NULL); report_remote_ra_result(cmd); } @@ -1031,7 +1031,7 @@ fail_all_monitor_cmds(GList * list) for (gIter = rm_list; gIter != NULL; gIter = gIter->next) { cmd = gIter->data; - pcmk__set_result(&(cmd->result), PCMK_OCF_UNKNOWN_ERROR, + pcmk__set_result(&cmd->result, PCMK_OCF_UNKNOWN_ERROR, PCMK_EXEC_ERROR, "Lost connection to remote executor"); pcmk__trace("Pre-emptively failing %s %s (interval=%u, %s)", cmd->action, cmd->rsc_id, cmd->interval_ms, cmd->userdata); diff --git a/daemons/controld/controld_timers.c b/daemons/controld/controld_timers.c index 72410e4ffd3..90138ee716c 100644 --- a/daemons/controld/controld_timers.c +++ b/daemons/controld/controld_timers.c @@ -331,26 +331,26 @@ controld_configure_fsa_timers(GHashTable *options) // Election timer value = g_hash_table_lookup(options, PCMK_OPT_DC_DEADTIME); - pcmk_parse_interval_spec(value, &(election_timer->period_ms)); + pcmk_parse_interval_spec(value, &election_timer->period_ms); // Integration timer value = g_hash_table_lookup(options, PCMK_OPT_JOIN_INTEGRATION_TIMEOUT); - pcmk_parse_interval_spec(value, &(integration_timer->period_ms)); + pcmk_parse_interval_spec(value, &integration_timer->period_ms); // Finalization timer value = g_hash_table_lookup(options, PCMK_OPT_JOIN_FINALIZATION_TIMEOUT); - pcmk_parse_interval_spec(value, &(finalization_timer->period_ms)); + pcmk_parse_interval_spec(value, &finalization_timer->period_ms); // Shutdown escalation timer value = g_hash_table_lookup(options, PCMK_OPT_SHUTDOWN_ESCALATION); - pcmk_parse_interval_spec(value, &(shutdown_escalation_timer->period_ms)); + pcmk_parse_interval_spec(value, &shutdown_escalation_timer->period_ms); pcmk__debug("Shutdown escalation occurs if DC has not responded to request " "in %ums", shutdown_escalation_timer->period_ms); // Transition timer value = g_hash_table_lookup(options, PCMK_OPT_TRANSITION_DELAY); - pcmk_parse_interval_spec(value, &(transition_timer->period_ms)); + pcmk_parse_interval_spec(value, &transition_timer->period_ms); // Recheck interval value = g_hash_table_lookup(options, PCMK_OPT_CLUSTER_RECHECK_INTERVAL); diff --git a/daemons/controld/controld_utils.c b/daemons/controld/controld_utils.c index 7775ea40a9d..fa67e90dbb5 100644 --- a/daemons/controld/controld_utils.c +++ b/daemons/controld/controld_utils.c @@ -1,5 +1,5 @@ /* - * Copyright 2004-2025 the Pacemaker project contributors + * Copyright 2004-2026 the Pacemaker project contributors * * The version control history for this file may have further details. * @@ -693,8 +693,8 @@ update_dc(xmlNode * msg) } controld_globals.dc_name = NULL; // freed as last_dc - pcmk__str_update(&(controld_globals.dc_name), welcome_from); - pcmk__str_update(&(controld_globals.dc_version), dc_version); + pcmk__str_update(&controld_globals.dc_name, welcome_from); + pcmk__str_update(&controld_globals.dc_version, dc_version); if (pcmk__str_eq(controld_globals.dc_name, last_dc, pcmk__str_casei)) { /* do nothing */ diff --git a/daemons/controld/pacemaker-controld.c b/daemons/controld/pacemaker-controld.c index 2e8564fb90f..58f17e004b1 100644 --- a/daemons/controld/pacemaker-controld.c +++ b/daemons/controld/pacemaker-controld.c @@ -162,7 +162,7 @@ main(int argc, char **argv) goto done; } - if (pcmk__log_output_new(&(controld_globals.logger_out)) != pcmk_rc_ok) { + if (pcmk__log_output_new(&controld_globals.logger_out) != pcmk_rc_ok) { exit_code = CRM_EX_FATAL; goto done; } diff --git a/daemons/execd/execd_alerts.c b/daemons/execd/execd_alerts.c index d4391c41498..5d1f9e3e7fa 100644 --- a/daemons/execd/execd_alerts.c +++ b/daemons/execd/execd_alerts.c @@ -135,7 +135,7 @@ execd_process_alert_exec(pcmk__client_t *client, xmlNode *request) cb_data->client_id = pcmk__str_copy(client->id); - pcmk__xe_get_int(request, PCMK__XA_LRMD_CALLID, &(cb_data->call_id)); + pcmk__xe_get_int(request, PCMK__XA_LRMD_CALLID, &cb_data->call_id); action = services_alert_create(alert_id, alert_path, alert_timeout, params, alert_sequence_no, cb_data); diff --git a/daemons/execd/execd_commands.c b/daemons/execd/execd_commands.c index ba1698ef6dd..a035506cc4d 100644 --- a/daemons/execd/execd_commands.c +++ b/daemons/execd/execd_commands.c @@ -369,7 +369,7 @@ free_lrmd_cmd(lrmd_cmd_t * cmd) g_clear_pointer(&cmd->params, g_hash_table_destroy); - pcmk__reset_result(&(cmd->result)); + pcmk__reset_result(&cmd->result); free(cmd->origin); free(cmd->action); free(cmd->real_action); @@ -399,7 +399,7 @@ stonith_recurring_op_helper(void *data) rsc->recurring_ops = g_list_remove(rsc->recurring_ops, cmd); rsc->pending_ops = g_list_append(rsc->pending_ops, cmd); #ifdef PCMK__TIME_USE_CGT - get_current_time(&(cmd->t_queue), &(cmd->t_first_queue)); + get_current_time(&cmd->t_queue, &cmd->t_first_queue); #endif mainloop_set_trigger(rsc->work); @@ -539,7 +539,7 @@ schedule_lrmd_cmd(lrmd_rsc_t * rsc, lrmd_cmd_t * cmd) rsc->pending_ops = g_list_append(rsc->pending_ops, cmd); #ifdef PCMK__TIME_USE_CGT - get_current_time(&(cmd->t_queue), &(cmd->t_first_queue)); + get_current_time(&cmd->t_queue, &cmd->t_first_queue); #endif mainloop_set_trigger(rsc->work); @@ -611,8 +611,8 @@ send_cmd_complete_notify(lrmd_cmd_t * cmd) int queue_time = 0; #ifdef PCMK__TIME_USE_CGT - exec_time = time_diff_ms(NULL, &(cmd->t_run)); - queue_time = time_diff_ms(&cmd->t_run, &(cmd->t_queue)); + exec_time = time_diff_ms(NULL, &cmd->t_run); + queue_time = time_diff_ms(&cmd->t_run, &cmd->t_queue); #endif log_finished(cmd, exec_time, queue_time); @@ -733,7 +733,7 @@ cmd_reset(lrmd_cmd_t * cmd) #endif cmd->epoch_last_run = 0; - pcmk__reset_result(&(cmd->result)); + pcmk__reset_result(&cmd->result); cmd->result.execution_status = PCMK_EXEC_DONE; } @@ -855,8 +855,8 @@ action_complete(svc_action_t * action) // Cast variable instead of function return to keep compilers happy code = services_result2ocf(action->standard, cmd->action, action->rc); - pcmk__set_result(&(cmd->result), (int) code, - action->status, services__exit_reason(action)); + pcmk__set_result(&cmd->result, (int) code, action->status, + services__exit_reason(action)); rsc = cmd->rsc_id ? g_hash_table_lookup(rsc_list, cmd->rsc_id) : NULL; @@ -875,7 +875,7 @@ action_complete(svc_action_t * action) goto finalize; } - if (pcmk__result_ok(&(cmd->result)) + if (pcmk__result_ok(&cmd->result) && pcmk__strcase_any_of(cmd->action, PCMK_ACTION_START, PCMK_ACTION_STOP, NULL)) { /* Getting results for when a start or stop action completes is now @@ -886,7 +886,7 @@ action_complete(svc_action_t * action) * @TODO When monitors are handled in the same way, this function * can either be drastically simplified or done away with entirely. */ - services__copy_result(action, &(cmd->result)); + services__copy_result(action, &cmd->result); goto finalize; } else if (cmd->result.execution_status == PCMK_EXEC_PENDING && @@ -902,13 +902,13 @@ action_complete(svc_action_t * action) if (cmd->result.execution_status == PCMK_EXEC_PENDING) { goagain = true; - } else if (pcmk__result_ok(&(cmd->result)) + } else if (pcmk__result_ok(&cmd->result) && pcmk__str_eq(cmd->real_action, PCMK_ACTION_STOP, pcmk__str_casei)) { goagain = true; } else { - int time_sum = time_diff_ms(NULL, &(cmd->t_first_run)); + int time_sum = time_diff_ms(NULL, &cmd->t_first_run); int timeout_left = cmd->timeout_orig - time_sum; pcmk__debug("%s systemd %s is now complete (elapsed=%dms, " @@ -948,7 +948,7 @@ action_complete(svc_action_t * action) cmd->rsc_id, cmd->action, cmd->result.exit_status, g_strchomp(ctime(&cmd->epoch_rcchange)), cmd->timeout_orig); - pcmk__set_result(&(cmd->result), PCMK_OCF_UNKNOWN_ERROR, + pcmk__set_result(&cmd->result, PCMK_OCF_UNKNOWN_ERROR, PCMK_EXEC_TIMEOUT, "Investigate reason for timeout, and adjust " "configured operation timeout if necessary"); @@ -961,7 +961,7 @@ action_complete(svc_action_t * action) goto finalize; } - time_sum = time_diff_ms(NULL, &(cmd->t_first_run)); + time_sum = time_diff_ms(NULL, &cmd->t_first_run); timeout_left = cmd->timeout_orig - time_sum; delay = cmd->timeout_orig / 10; @@ -974,7 +974,7 @@ action_complete(svc_action_t * action) cmd->start_delay = delay; cmd->timeout = timeout_left; - if (pcmk__result_ok(&(cmd->result))) { + if (pcmk__result_ok(&cmd->result)) { pcmk__debug("%s %s may still be in progress: re-scheduling " "(elapsed=%dms, remaining=%dms, start_delay=%dms)", cmd->rsc_id, cmd->real_action, time_sum, timeout_left, @@ -1009,7 +1009,7 @@ action_complete(svc_action_t * action) "remaining=%dms)", cmd->rsc_id, pcmk__s(cmd->real_action, cmd->action), cmd->result.exit_status, time_sum, timeout_left); - pcmk__set_result(&(cmd->result), PCMK_OCF_UNKNOWN_ERROR, + pcmk__set_result(&cmd->result, PCMK_OCF_UNKNOWN_ERROR, PCMK_EXEC_TIMEOUT, "Investigate reason for timeout, and adjust " "configured operation timeout if necessary"); @@ -1018,7 +1018,7 @@ action_complete(svc_action_t * action) #endif finalize: - pcmk__set_result_output(&(cmd->result), services__grab_stdout(action), + pcmk__set_result_output(&cmd->result, services__grab_stdout(action), services__grab_stderr(action)); cmd_finalize(cmd, rsc); } @@ -1092,7 +1092,7 @@ fencing_rsc_action_complete(lrmd_cmd_t *cmd, int exit_status, pcmk__set_result(&cmd->result, exit_status, execution_status, exit_reason); // Certain successful actions change the known state of the resource - if ((rsc != NULL) && pcmk__result_ok(&(cmd->result))) { + if ((rsc != NULL) && pcmk__result_ok(&cmd->result)) { if (pcmk__str_eq(cmd->action, PCMK_ACTION_START, pcmk__str_casei)) { pcmk__set_result(&rsc->fence_probe_result, CRM_EX_OK, @@ -1371,14 +1371,14 @@ execute_nonstonith_action(lrmd_rsc_t *rsc, lrmd_cmd_t *cmd) params_copy, cmd->service_flags); if (action == NULL) { - pcmk__set_result(&(cmd->result), PCMK_OCF_UNKNOWN_ERROR, - PCMK_EXEC_ERROR, strerror(ENOMEM)); + pcmk__set_result(&cmd->result, PCMK_OCF_UNKNOWN_ERROR, PCMK_EXEC_ERROR, + strerror(ENOMEM)); cmd_finalize(cmd, rsc); return; } if (action->rc != PCMK_OCF_UNKNOWN) { - services__copy_result(action, &(cmd->result)); + services__copy_result(action, &cmd->result); services_action_free(action); cmd_finalize(cmd, rsc); return; @@ -1403,7 +1403,7 @@ execute_nonstonith_action(lrmd_rsc_t *rsc, lrmd_cmd_t *cmd) * called cmd_finalize(), which in this case should only reset (not * free) cmd. */ - services__copy_result(action, &(cmd->result)); + services__copy_result(action, &cmd->result); services_action_free(action); } } @@ -1435,7 +1435,7 @@ execute_resource_action(void *user_data) g_list_free_1(first); #ifdef PCMK__TIME_USE_CGT - get_current_time(&(cmd->t_run), &(cmd->t_first_run)); + get_current_time(&cmd->t_run, &cmd->t_first_run); #endif cmd->epoch_last_run = time(NULL); } diff --git a/daemons/fenced/fenced_commands.c b/daemons/fenced/fenced_commands.c index 6d92c57507b..9c8f0667b36 100644 --- a/daemons/fenced/fenced_commands.c +++ b/daemons/fenced/fenced_commands.c @@ -541,12 +541,12 @@ create_async_command(xmlNode *msg) return NULL; } - pcmk__xe_get_int(msg, PCMK__XA_ST_CALLID, &(cmd->id)); - pcmk__xe_get_int(msg, PCMK__XA_ST_DELAY, &(cmd->start_delay)); - pcmk__xe_get_int(msg, PCMK__XA_ST_TIMEOUT, &(cmd->default_timeout)); + pcmk__xe_get_int(msg, PCMK__XA_ST_CALLID, &cmd->id); + pcmk__xe_get_int(msg, PCMK__XA_ST_DELAY, &cmd->start_delay); + pcmk__xe_get_int(msg, PCMK__XA_ST_TIMEOUT, &cmd->default_timeout); cmd->timeout = cmd->default_timeout; - rc = pcmk__xe_get_flags(msg, PCMK__XA_ST_CALLOPT, &(cmd->options), + rc = pcmk__xe_get_flags(msg, PCMK__XA_ST_CALLOPT, &cmd->options, st_opt_none); if (rc != pcmk_rc_ok) { pcmk__warn("Couldn't parse options from request: %s", pcmk_rc_str(rc)); @@ -1179,7 +1179,7 @@ build_device_from_xml(const xmlNode *dev) } value = g_hash_table_lookup(device->params, PCMK_FENCING_HOST_MAP); - device->aliases = build_port_aliases(value, &(device->targets)); + device->aliases = build_port_aliases(value, &device->targets); value = target_list_type(device); if (!pcmk__str_eq(value, PCMK_VALUE_STATIC_LIST, pcmk__str_casei) diff --git a/daemons/fenced/fenced_remote.c b/daemons/fenced/fenced_remote.c index 9e05e87fb07..9d59d054e81 100644 --- a/daemons/fenced/fenced_remote.c +++ b/daemons/fenced/fenced_remote.c @@ -1179,10 +1179,10 @@ create_remote_stonith_op(const char *client, xmlNode *request, gboolean peer) op = pcmk__assert_alloc(1, sizeof(remote_fencing_op_t)); - pcmk__xe_get_int(request, PCMK__XA_ST_TIMEOUT, &(op->base_timeout)); + pcmk__xe_get_int(request, PCMK__XA_ST_TIMEOUT, &op->base_timeout); // Value -1 means disable any static/random fencing delays - pcmk__xe_get_int(request, PCMK__XA_ST_DELAY, &(op->client_delay)); + pcmk__xe_get_int(request, PCMK__XA_ST_DELAY, &op->client_delay); if (peer) { op->id = pcmk__xe_get_copy(dev, PCMK__XA_ST_REMOTE_OP); @@ -1230,14 +1230,14 @@ create_remote_stonith_op(const char *client, xmlNode *request, gboolean peer) // @TODO Figure out how to avoid copying XML here op->request = pcmk__xml_copy(NULL, request); - rc = pcmk__xe_get_flags(request, PCMK__XA_ST_CALLOPT, &(op->call_options), + rc = pcmk__xe_get_flags(request, PCMK__XA_ST_CALLOPT, &op->call_options, 0U); if (rc != pcmk_rc_ok) { pcmk__warn("Couldn't parse options from request %s: %s", op->id, pcmk_rc_str(rc)); } - pcmk__xe_get_int(request, PCMK__XA_ST_CALLID, &(op->client_callid)); + pcmk__xe_get_int(request, PCMK__XA_ST_CALLID, &op->client_callid); pcmk__trace("%s new fencing op %s ('%s' targeting %s for client %s, base " "timeout %ds, %u %s expected)", @@ -1259,7 +1259,7 @@ create_remote_stonith_op(const char *client, xmlNode *request, gboolean peer) stonith__clear_call_options(op->call_options, op->id, st_opt_cs_nodeid); if ((node != NULL) && (node->name != NULL)) { - pcmk__str_update(&(op->target), node->name); + pcmk__str_update(&op->target, node->name); } else { pcmk__warn("Could not expand nodeid '%s' into a host name", @@ -2259,7 +2259,7 @@ add_device_properties(const xmlNode *xml, remote_fencing_op_t *op, // Nodes <2.1.5 won't set this, so assume unfencing in that case rc = pcmk__xe_get_flags(xml, PCMK__XA_ST_DEVICE_SUPPORT_FLAGS, - &(props->device_support_flags), + &props->device_support_flags, fenced_df_supports_on); if (rc != pcmk_rc_ok) { pcmk__warn("Couldn't determine device support for %s " diff --git a/daemons/pacemakerd/pcmkd_subdaemons.c b/daemons/pacemakerd/pcmkd_subdaemons.c index 6637d7de73a..63152d29df0 100644 --- a/daemons/pacemakerd/pcmkd_subdaemons.c +++ b/daemons/pacemakerd/pcmkd_subdaemons.c @@ -149,7 +149,7 @@ check_next_subdaemon(void *user_data) { static int next_child = 0; - pcmkd_child_t *child = &(pcmk_children[next_child]); + pcmkd_child_t *child = &pcmk_children[next_child]; const char *name = pcmk__server_name(child->server); const long long pid = PCMK__SPECIAL_PID_AS_0(child->pid); int rc = child_liveness(child); @@ -361,7 +361,7 @@ pcmk_shutdown_worker(void *user_data) } for (; phase >= 0; phase--) { - pcmkd_child_t *child = &(pcmk_children[phase]); + pcmkd_child_t *child = &pcmk_children[phase]; const char *name = pcmk__server_name(child->server); time_t now = 0; diff --git a/include/crm/common/iso8601.h b/include/crm/common/iso8601.h index 469a577cfc8..2d2b4566602 100644 --- a/include/crm/common/iso8601.h +++ b/include/crm/common/iso8601.h @@ -52,38 +52,8 @@ typedef struct crm_time_s crm_time_t; * A timezone of 'Z' denotes UTC time */ crm_time_t *crm_time_new(const char *string); -crm_time_t *crm_time_new_undefined(void); void crm_time_free(crm_time_t * dt); -bool crm_time_is_defined(const crm_time_t *t); -char *crm_time_as_string(const crm_time_t *dt, int flags); - -#define crm_time_log_date 0x001 -#define crm_time_log_timeofday 0x002 -#define crm_time_log_with_timezone 0x004 -#define crm_time_log_duration 0x008 - -#define crm_time_ordinal 0x010 -#define crm_time_weeks 0x020 -#define crm_time_seconds 0x100 -#define crm_time_epoch 0x200 -#define crm_time_usecs 0x400 - -crm_time_t *crm_time_parse_duration(const char *duration_str); -crm_time_t *crm_time_calculate_duration(const crm_time_t *dt, - const crm_time_t *value); - -int crm_time_compare(const crm_time_t *a, const crm_time_t *b); - -int crm_time_get_timeofday(const crm_time_t *dt, uint32_t *h, uint32_t *m, - uint32_t *s); -int crm_time_get_gregorian(const crm_time_t *dt, uint32_t *y, uint32_t *m, - uint32_t *d); -int crm_time_get_ordinal(const crm_time_t *dt, uint32_t *y, uint32_t *d); - -/* Time in seconds since 0000-01-01 00:00:00Z */ -long long crm_time_get_seconds(const crm_time_t *dt); - /* Time in seconds since 1970-01-01 00:00:00Z */ long long crm_time_get_seconds_since_epoch(const crm_time_t *dt); diff --git a/include/crm/common/iso8601_compat.h b/include/crm/common/iso8601_compat.h index fa83f4a2c36..3c08c6b3388 100644 --- a/include/crm/common/iso8601_compat.h +++ b/include/crm/common/iso8601_compat.h @@ -29,6 +29,33 @@ extern "C" { * release. */ +//! \deprecated Do not use +#define crm_time_log_date 0x001 + +//! \deprecated Do not use +#define crm_time_log_timeofday 0x002 + +//! \deprecated Do not use +#define crm_time_log_with_timezone 0x004 + +//! \deprecated Do not use +#define crm_time_log_duration 0x008 + +//! \deprecated Do not use +#define crm_time_ordinal 0x010 + +//! \deprecated Do not use +#define crm_time_weeks 0x020 + +//! \deprecated Do not use +#define crm_time_seconds 0x100 + +//! \deprecated Do not use +#define crm_time_epoch 0x200 + +//! \deprecated Do not use +#define crm_time_usecs 0x400 + //! \deprecated Do not use typedef struct crm_time_period_s { crm_time_t *start; @@ -79,6 +106,39 @@ void crm_time_free_period(crm_time_period_t *period); //! \deprecated Do not use crm_time_period_t *crm_time_parse_period(const char *period_str); +//! \deprecated Do not use +crm_time_t *crm_time_calculate_duration(const crm_time_t *dt, + const crm_time_t *value); + +//! \deprecated Do not use +crm_time_t *crm_time_parse_duration(const char *duration_str); + +//! \deprecated Do not use +crm_time_t *crm_time_new_undefined(void); + +//! \deprecated Do not use +bool crm_time_is_defined(const crm_time_t *t); + +//! \deprecated Do not use +char *crm_time_as_string(const crm_time_t *dt, int flags); + +//! \deprecated Do not use +int crm_time_compare(const crm_time_t *a, const crm_time_t *b); + +//! \deprecated Do not use +int crm_time_get_timeofday(const crm_time_t *dt, uint32_t *h, uint32_t *m, + uint32_t *s); + +//! \deprecated Do not use +int crm_time_get_gregorian(const crm_time_t *dt, uint32_t *y, uint32_t *m, + uint32_t *d); + +//! \deprecated Do not use +int crm_time_get_ordinal(const crm_time_t *dt, uint32_t *y, uint32_t *d); + +//! \deprecated Do not use +long long crm_time_get_seconds(const crm_time_t *dt); + #ifdef __cplusplus } #endif diff --git a/include/crm/common/iso8601_internal.h b/include/crm/common/iso8601_internal.h index 2761b0b7948..d4e435d824e 100644 --- a/include/crm/common/iso8601_internal.h +++ b/include/crm/common/iso8601_internal.h @@ -26,15 +26,124 @@ extern "C" { #endif +/* @COMPAT These must be kept in line with the deprecated crm_time_* flags until + * those are removed + */ +/*! + * \internal + * \brief Flags for formatting a \c crm_time_t object as a string + */ +enum pcmk__time_fmt_flags { + //! Include date (as YYYY-WW-D, YYYY-DDD, or YYYY-MM-DD (default)) + pcmk__time_fmt_date = (UINT32_C(1) << 0), + + //! Include time (as HH:MM:SS[.UUUUUU]('Z'| ('+'|'-')HH:MM)) + pcmk__time_fmt_time = (UINT32_C(1) << 1), + + /*! + * If \c pcmk__time_fmt_time is set: + * * If this flag is set and \c offset is not 0, include time zone as offset + * from UTC ( ('+'|'-')HH:MM). + * * Otherwise, include 'Z'. + * + * If \c pcmk__time_fmt_time is not set, this flag is ignored and neither + * the time zone nor 'Z' is included. + */ + pcmk__time_fmt_timezone = (UINT32_C(1) << 2), + + // @COMPAT Nothing sets this internally except tools/iso8601.c (deprecated) + /*! + * Format the \c crm_time_t object as a duration. The output contains the + * following fields: + * * YYYY year(s) + * * MM month(s) + * * DD day(s) + * * SECONDS[.UUUUUU] second(s) + * * If SECONDS >= 60, then the following fields in parentheses: + * * HOURS hour(s) + * * MINUTES minute(s) + * * SECONDS[.UUUUUU] second(s) + * + * \note This flag causes all other flags except \c pcmk__time_fmt_usecs to + * be ignored. + * \note Negative fields may be formatted incorrectly or confusingly. A + * duration should not really have negative fields, but they are + * allowed. + * \note The fields are separated by spaces. + * \note Years, months, and days are space-padded on the left. + * \note Fields with zero values are omitted, with the following exceptions: + * * If there are no nonzero date fields, the seconds field is + * formatted with a value of zero (plus usecs if requested). + * * Usecs are included if and only if the \c pcmk__time_fmt_usecs + * flag is set and either seconds will be formatted or usecs is + * nonzero. + */ + pcmk__time_fmt_duration = (UINT32_C(1) << 3), + + // @COMPAT Nothing sets this internally except tools/iso8601.c (deprecated) + /*! + * If \c pcmk__time_fmt_date is set and \c pcmk__time_fmt_weeks is not set, + * format date as YYYY-DDD + */ + pcmk__time_fmt_ordinal = (UINT32_C(1) << 4), + + // @COMPAT Nothing sets this internally except tools/iso8601.c (deprecated) + //! If \c pcmk__time_fmt_date is set, format date as YYYY-WW-D + pcmk__time_fmt_weeks = (UINT32_C(1) << 5), + + // @COMPAT Nothing sets this internally except tools/iso8601.c (deprecated) + /*! + * Format the \c crm_time_t object as the number of seconds since + * 0001-01-01T00:00:00. The output is in the format SECONDS[.UUUUUU], where + * usecs are included if and only if \c pcmk__time_fmt_usecs is set. + * + * \note This flag causes all other flags except \c pcmk__time_fmt_duration + * and \c pcmk__time_fmt_usecs to be ignored. + * \note If the \c crm_time_t object is a duration, then all years are + * treated as having 365 days and all months are treated as having 30 + * days, for the purpose of computing the number of seconds. + */ + pcmk__time_fmt_seconds = (UINT32_C(1) << 8), + + // @COMPAT Nothing sets this internally except tools/iso8601.c (deprecated) + /*! + * Format the \c crm_time_t object as the number of seconds since + * 1970-01-01T00:00:00 (the Unix epoch). The output is in the format + * SECONDS[.UUUUUU], where usecs are included if and only if + * \c pcmk__time_fmt_usecs is set. + * + * \note This flag causes all other flags except \c pcmk__time_fmt_duration, + * \c pcmk__time_fmt_seconds, and \c pcmk__time_fmt_usecs to be + * ignored. + * \note If the \c crm_time_t object is a duration, then all years are + * treated as having 365 days and all months are treated as having 30 + * days, for the purpose of computing the number of seconds. + */ + pcmk__time_fmt_epoch = (UINT32_C(1) << 9), + + /*! + * Format seconds as a floating-point value at microsecond resolution. If + * not set, seconds are truncated to an integer. + */ + pcmk__time_fmt_usecs = (UINT32_C(1) << 10), +}; + bool pcmk__time_valid_year(int year); +bool pcmk__time_is_initialized(const crm_time_t *dt); +long long pcmk__time_get_seconds(const crm_time_t *dt); void pcmk__time_get_ywd(const crm_time_t *dt, uint32_t *y, uint32_t *w, uint32_t *d); +char *pcmk__time_text(const crm_time_t *dt, int flags); char *pcmk__time_format_hr(const char *format, const crm_time_t *dt, int usec); char *pcmk__epoch2str(const time_t *source, uint32_t flags); char *pcmk__timespec2str(const struct timespec *ts, uint32_t flags); const char *pcmk__readable_interval(unsigned int interval_ms); + +crm_time_t *pcmk__time_parse_duration(const char *period_s); crm_time_t *pcmk__copy_timet(time_t source_sec); +int pcmk__time_compare(const crm_time_t *a, const crm_time_t *b); + void pcmk__time_log_as(const char *file, const char *function, int line, uint8_t level, const char *prefix, const crm_time_t *dt, uint32_t flags); diff --git a/include/crm/common/scheduler.h b/include/crm/common/scheduler.h index e7d3b27ac7b..b01f970a32b 100644 --- a/include/crm/common/scheduler.h +++ b/include/crm/common/scheduler.h @@ -10,19 +10,13 @@ #ifndef PCMK__CRM_COMMON_SCHEDULER__H #define PCMK__CRM_COMMON_SCHEDULER__H -#include -#include // time_t -#include // xmlNode -#include // GList, GHashTable +#include // bool +#include // uint64_t -#include // crm_time_t +#include // GList +#include // xmlNode -#include -#include -#include -#include -#include -#include +#include // pcmk_node_t, pcmk_scheduler_t #ifdef __cplusplus extern "C" { diff --git a/include/crm/pengine/status.h b/include/crm/pengine/status.h index 8d7722c72b0..d46428b6870 100644 --- a/include/crm/pengine/status.h +++ b/include/crm/pengine/status.h @@ -1,5 +1,5 @@ /* - * Copyright 2004-2025 the Pacemaker project contributors + * Copyright 2004-2026 the Pacemaker project contributors * * The version control history for this file may have further details. * @@ -12,7 +12,7 @@ # include // gboolean # include // bool -# include +# include // pe_find # include // pcmk_node_t, pcmk_resource_t, etc. # include diff --git a/include/pacemaker.h b/include/pacemaker.h index a766a964230..c474f2b18da 100644 --- a/include/pacemaker.h +++ b/include/pacemaker.h @@ -16,6 +16,7 @@ # include # include +# include // crm_time_t # include # include diff --git a/lib/cib/cib_client.c b/lib/cib/cib_client.c index 685613c403b..c598e704982 100644 --- a/lib/cib/cib_client.c +++ b/lib/cib/cib_client.c @@ -412,7 +412,7 @@ cib_client_fetch_schemas(cib_t *cib, xmlNode **output_data, const char *after_ve static void cib_client_set_user(cib_t *cib, const char *user) { - pcmk__str_update(&(cib->user), user); + pcmk__str_update(&cib->user, user); } static void diff --git a/lib/cib/cib_ops.c b/lib/cib/cib_ops.c index 2fb7d93ce12..41ead4081b2 100644 --- a/lib/cib/cib_ops.c +++ b/lib/cib/cib_ops.c @@ -148,7 +148,7 @@ cib__get_operation(const char *op, const cib__operation_t **operation) operation_table = pcmk__strkey_table(NULL, NULL); for (int lpc = 0; lpc < PCMK__NELEM(cib_ops); lpc++) { - const cib__operation_t *oper = &(cib_ops[lpc]); + const cib__operation_t *oper = &cib_ops[lpc]; g_hash_table_insert(operation_table, (void *) oper->name, (void *) oper); diff --git a/lib/cib/cib_remote.c b/lib/cib/cib_remote.c index 8ba9bb8909a..3ab13b2a283 100644 --- a/lib/cib/cib_remote.c +++ b/lib/cib/cib_remote.c @@ -472,7 +472,7 @@ cib_tls_signon(cib_t *cib, pcmk__remote_t *connection, gboolean event_channel) connection->tcp_socket = -1; connection->tls_session = NULL; rc = pcmk__connect_remote(private->server, private->port, 0, NULL, - &(connection->tcp_socket), NULL, NULL); + &connection->tcp_socket, NULL, NULL); if (rc != pcmk_rc_ok) { pcmk__info("Remote connection to %s:%d failed: %s " QB_XS " rc=%d", private->server, private->port, pcmk_rc_str(rc), rc); @@ -585,9 +585,9 @@ cib_remote_signon(cib_t *cib, const char *name, enum cib_conn_type type) /* If no pcmk__output_t is set, just assume that a text prompt * is good enough. */ - pcmk__text_prompt("Password", false, &(private->passwd)); + pcmk__text_prompt("Password", false, &private->passwd); } else { - private->out->prompt("Password", false, &(private->passwd)); + private->out->prompt("Password", false, &private->passwd); } } @@ -596,12 +596,12 @@ cib_remote_signon(cib_t *cib, const char *name, enum cib_conn_type type) goto done; } - rc = cib_tls_signon(cib, &(private->command), FALSE); + rc = cib_tls_signon(cib, &private->command, false); if (rc != pcmk_ok) { goto done; } - rc = cib_tls_signon(cib, &(private->callback), TRUE); + rc = cib_tls_signon(cib, &private->callback, true); done: if (rc == pcmk_ok) { diff --git a/lib/cluster/cpg.c b/lib/cluster/cpg.c index aa0a17076ff..c121a2f9d07 100644 --- a/lib/cluster/cpg.c +++ b/lib/cluster/cpg.c @@ -319,10 +319,10 @@ check_message_sanity(const pcmk__cpg_msg_t *msg) pcmk__err("%sCPG message %d from %s invalid: Claimed size of %d bytes " "is too small " QB_XS " from %s[%u] to %s@%s", (msg->is_compressed? "Compressed " : ""), - msg->id, ais_dest(&(msg->sender)), + msg->id, ais_dest(&msg->sender), (int) msg->header.size, msg_type2text(msg->sender.type), msg->sender.pid, - msg_type2text(msg->host.type), ais_dest(&(msg->host))); + msg_type2text(msg->host.type), ais_dest(&msg->host)); return false; } @@ -330,10 +330,10 @@ check_message_sanity(const pcmk__cpg_msg_t *msg) pcmk__err("%sCPG message %d from %s invalid: Sender indicated error %d " QB_XS " from %s[%u] to %s@%s", (msg->is_compressed? "Compressed " : ""), - msg->id, ais_dest(&(msg->sender)), + msg->id, ais_dest(&msg->sender), msg->header.error, msg_type2text(msg->sender.type), msg->sender.pid, - msg_type2text(msg->host.type), ais_dest(&(msg->host))); + msg_type2text(msg->host.type), ais_dest(&msg->host)); return false; } @@ -342,10 +342,10 @@ check_message_sanity(const pcmk__cpg_msg_t *msg) "inconsistent with payload size %d " QB_XS " from %s[%u] to %s@%s", (msg->is_compressed? "Compressed " : ""), - msg->id, ais_dest(&(msg->sender)), + msg->id, ais_dest(&msg->sender), (int) msg->header.size, (int) msg_data_len(msg), msg_type2text(msg->sender.type), msg->sender.pid, - msg_type2text(msg->host.type), ais_dest(&(msg->host))); + msg_type2text(msg->host.type), ais_dest(&msg->host)); return false; } @@ -357,9 +357,9 @@ check_message_sanity(const pcmk__cpg_msg_t *msg) || (msg->data[msg->size - 1] != '\0'))) { pcmk__err("CPG message %d from %s invalid: Payload does not end at " "byte %" PRIu32 " " QB_XS " from %s[%u] to %s@%s", - msg->id, ais_dest(&(msg->sender)), msg->size, + msg->id, ais_dest(&msg->sender), msg->size, msg_type2text(msg->sender.type), msg->sender.pid, - msg_type2text(msg->host.type), ais_dest(&(msg->host))); + msg_type2text(msg->host.type), ais_dest(&msg->host)); return false; } @@ -367,8 +367,8 @@ check_message_sanity(const pcmk__cpg_msg_t *msg) (int) msg->header.size, (msg->is_compressed? "compressed " : ""), msg->id, msg_type2text(msg->sender.type), msg->sender.pid, - ais_dest(&(msg->sender)), - msg_type2text(msg->host.type), ais_dest(&(msg->host))); + ais_dest(&msg->sender), + msg_type2text(msg->host.type), ais_dest(&msg->host)); return true; } @@ -477,7 +477,7 @@ pcmk__cpg_message_data(cpg_handle_t handle, uint32_t sender_id, uint32_t pid, free(uncompressed); pcmk__warn("Ignoring compressed CPG message %d from %s (ID %" PRIu32 " PID %" PRIu32 "): %s", - msg->id, ais_dest(&(msg->sender)), sender_id, pid, + msg->id, ais_dest(&msg->sender), sender_id, pid, pcmk_rc_str(rc)); return NULL; } @@ -490,7 +490,7 @@ pcmk__cpg_message_data(cpg_handle_t handle, uint32_t sender_id, uint32_t pid, pcmk__trace("Received %sCPG message %d from %s (ID %" PRIu32 " PID %" PRIu32 "): %.40s...", (msg->is_compressed? "compressed " : ""), - msg->id, ais_dest(&(msg->sender)), sender_id, pid, msg->data); + msg->id, ais_dest(&msg->sender), sender_id, pid, msg->data); return data; } diff --git a/lib/cluster/election.c b/lib/cluster/election.c index 1ca0d4597b1..db44bfdfccd 100644 --- a/lib/cluster/election.c +++ b/lib/cluster/election.c @@ -436,7 +436,7 @@ parse_election_message(const xmlNode *message, struct vote *vote) vote->version = pcmk__xe_get(message, PCMK_XA_VERSION); vote->election_owner = pcmk__xe_get(message, PCMK__XA_ELECTION_OWNER); - pcmk__xe_get_int(message, PCMK__XA_ELECTION_ID, &(vote->election_id)); + pcmk__xe_get_int(message, PCMK__XA_ELECTION_ID, &vote->election_id); if ((vote->op == NULL) || (vote->from == NULL) || (vote->version == NULL) || (vote->election_owner == NULL) || (vote->election_id < 0)) { @@ -455,7 +455,7 @@ parse_election_message(const xmlNode *message, struct vote *vote) */ if ((pcmk__xe_get_timeval(message, PCMK__XA_ELECTION_AGE_SEC, PCMK__XA_ELECTION_AGE_NANO_SEC, - &(vote->age)) != pcmk_rc_ok) + &vote->age) != pcmk_rc_ok) || (vote->age.tv_sec < 0) || (vote->age.tv_usec < 0)) { pcmk__warn("Cannot count election %s from %s because uptime is " @@ -705,7 +705,7 @@ election_count_vote(pcmk_cluster_t *cluster, const xmlNode *message, } else { char *loss_time = NULL; - loss_time = ctime(&(cluster->priv->election->last_election_loss)); + loss_time = ctime(&cluster->priv->election->last_election_loss); if (loss_time) { // Show only HH:MM:SS loss_time += 11; diff --git a/lib/common/cmdline.c b/lib/common/cmdline.c index 89e92ef560f..b3f29fb990b 100644 --- a/lib/common/cmdline.c +++ b/lib/common/cmdline.c @@ -70,7 +70,7 @@ pcmk__build_arg_context(pcmk__common_args_t *common_args, const char *fmts, GOptionGroup *main_group; GOptionEntry main_entries[3] = { - { "version", '$', 0, G_OPTION_ARG_NONE, &(common_args->version), + { "version", '$', 0, G_OPTION_ARG_NONE, &common_args->version, N_("Display software version and exit"), NULL }, { "verbose", 'V', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, bump_verbosity, @@ -91,10 +91,10 @@ pcmk__build_arg_context(pcmk__common_args_t *common_args, const char *fmts, if (fmts != NULL) { GOptionEntry output_entries[3] = { - { "output-as", 0, 0, G_OPTION_ARG_STRING, &(common_args->output_ty), + { "output-as", 0, 0, G_OPTION_ARG_STRING, &common_args->output_ty, NULL, N_("FORMAT") }, - { "output-to", 0, 0, G_OPTION_ARG_STRING, &(common_args->output_dest), + { "output-to", 0, 0, G_OPTION_ARG_STRING, &common_args->output_dest, N_( "Specify file name for output (or \"-\" for stdout)"), N_("DEST") }, { NULL } diff --git a/lib/common/crmcommon_private.h b/lib/common/crmcommon_private.h index a53ba60746e..55734a30e15 100644 --- a/lib/common/crmcommon_private.h +++ b/lib/common/crmcommon_private.h @@ -203,6 +203,14 @@ enum pcmk__time_component { pcmk__time_seconds, }; +G_GNUC_INTERNAL +void pcmk__time_get_timeofday(const crm_time_t *dt, uint32_t *hour, + uint32_t *minute, uint32_t *second); + +G_GNUC_INTERNAL +void pcmk__time_get_ymd(const crm_time_t *dt, uint32_t *year, uint32_t *month, + uint32_t *day); + G_GNUC_INTERNAL const char *pcmk__time_component_attr(enum pcmk__time_component component); diff --git a/lib/common/ipc_client.c b/lib/common/ipc_client.c index b3c3309351a..63529d52dc5 100644 --- a/lib/common/ipc_client.c +++ b/lib/common/ipc_client.c @@ -384,7 +384,7 @@ pcmk_poll_ipc(const pcmk_ipc_api_t *api, int timeout_ms) return EINVAL; } - rc = pcmk__ipc_fd(api->ipc, &(pollfd.fd)); + rc = pcmk__ipc_fd(api->ipc, &pollfd.fd); if (rc != pcmk_rc_ok) { pcmk__debug("Could not obtain file descriptor for %s IPC: %s", pcmk_ipc_name(api, true), pcmk_rc_str(rc)); @@ -440,7 +440,7 @@ connect_with_main_loop(pcmk_ipc_api_t *api) }; rc = pcmk__add_mainloop_ipc(api->ipc, G_PRIORITY_DEFAULT, api, - &callbacks, &(api->mainloop_io)); + &callbacks, &api->mainloop_io); if (rc != pcmk_rc_ok) { return rc; } @@ -1078,7 +1078,7 @@ crm_ipc_ready(crm_ipc_t *client) } client->pfd.revents = 0; - rc = poll(&(client->pfd), 1, 0); + rc = poll(&client->pfd, 1, 0); return (rc < 0)? -errno : rc; } @@ -1679,8 +1679,7 @@ pcmk__ipc_is_authentic_process_active(const char *name, uid_t refuid, struct pollfd pollfd = { 0, }; int poll_rc; - c = qb_ipcc_connect_async(name, 0, - &(pollfd.fd)); + c = qb_ipcc_connect_async(name, 0, &pollfd.fd); #else c = qb_ipcc_connect(name, 0); #endif diff --git a/lib/common/ipc_controld.c b/lib/common/ipc_controld.c index 21bfdf0ea39..7a119df5927 100644 --- a/lib/common/ipc_controld.c +++ b/lib/common/ipc_controld.c @@ -1,5 +1,5 @@ /* - * Copyright 2020-2025 the Pacemaker project contributors + * Copyright 2020-2026 the Pacemaker project contributors * * The version control history for this file may have further details. * @@ -138,7 +138,7 @@ set_node_info_data(pcmk_controld_api_reply_t *data, xmlNode *msg_data) * @TODO: Improve handling after pcmk__node_status_t is refactored to handle * layer-specific data better. */ - pcmk__xe_get_int(msg_data, PCMK_XA_ID, &(data->data.node_info.id)); + pcmk__xe_get_int(msg_data, PCMK_XA_ID, &data->data.node_info.id); data->data.node_info.uuid = pcmk__xe_get(msg_data, PCMK_XA_ID); data->data.node_info.uname = pcmk__xe_get(msg_data, PCMK_XA_UNAME); diff --git a/lib/common/iso8601.c b/lib/common/iso8601.c index 083bc15dccb..1db7c49c950 100644 --- a/lib/common/iso8601.c +++ b/lib/common/iso8601.c @@ -74,20 +74,6 @@ ((QB_ABS(usec) < QB_TIME_US_IN_SEC) \ && (((sec) == 0) || ((usec) == 0) || (((sec) < 0) == ((usec) < 0)))) -/*! - * \brief Allocate memory for an uninitialized time object - * - * \return Newly allocated time object (guaranteed not to be \c NULL) - * - * \note The caller is responsible for freeing the return value using - * \c crm_time_free(). - */ -crm_time_t * -crm_time_new_undefined(void) -{ - return pcmk__assert_alloc(1, sizeof(crm_time_t)); -} - /*! * \internal * \brief Check whether a year is positive and representable by four digits @@ -390,7 +376,7 @@ parse_time(const char *time_str, crm_time_t *a_time) tzset(); - if (!parse_hms(time_str, &(a_time->seconds))) { + if (!parse_hms(time_str, &a_time->seconds)) { return false; } @@ -409,7 +395,7 @@ parse_time(const char *time_str, crm_time_t *a_time) } } - if (!parse_offset(offset_s, &(a_time->offset))) { + if (!parse_offset(offset_s, &a_time->offset)) { return false; } @@ -454,7 +440,7 @@ valid_time(const crm_time_t *dt) static crm_time_t * parse_date(const char *date_str) { - const uint32_t flags = crm_time_log_date|crm_time_log_timeofday; + const uint32_t flags = pcmk__time_fmt_date|pcmk__time_fmt_time; const char *time_s = NULL; crm_time_t *dt = NULL; @@ -482,7 +468,7 @@ parse_date(const char *date_str) goto parse_time_segment; } - dt = crm_time_new_undefined(); + dt = pcmk__assert_alloc(1, sizeof(crm_time_t)); if ((strncasecmp(PCMK__VALUE_EPOCH, date_str, 5) == 0) && ((date_str[5] == '\0') @@ -633,19 +619,25 @@ parse_date(const char *date_str) static crm_time_t * copy_time_to_utc(const crm_time_t *dt) { - const uint32_t flags = crm_time_log_date - |crm_time_log_timeofday - |crm_time_log_with_timezone; + const uint32_t flags = pcmk__time_fmt_date + |pcmk__time_fmt_time + |pcmk__time_fmt_timezone; crm_time_t *utc = NULL; pcmk__assert(dt != NULL); - utc = crm_time_new_undefined(); + utc = pcmk__assert_alloc(1, sizeof(crm_time_t)); utc->years = dt->years; utc->days = dt->days; utc->seconds = dt->seconds; utc->offset = 0; + /* It makes no sense to convert a duration to UTC, but at time of writing, + * there are places where we may do it (for example, via public API + * functions). + */ + utc->duration = dt->duration; + if (dt->offset != 0) { crm_time_add_seconds(utc, -dt->offset); @@ -672,16 +664,21 @@ crm_time_new(const char *date_time) /*! * \brief Check whether a time object has been initialized yet * - * \param[in] t Time object to check + * \param[in] dt Time object to check * - * \return \c true if time object has been initialized, \c false otherwise + * \return \c true if time object has been initialized, or \c false otherwise */ bool -crm_time_is_defined(const crm_time_t *t) +pcmk__time_is_initialized(const crm_time_t *dt) { - // Any nonzero member indicates something has been done to t - return (t != NULL) && (t->years || t->months || t->days || t->seconds - || t->offset || t->duration); + // Any nonzero member indicates something has been done to dt + return (dt != NULL) + && ((dt->years != 0) + || (dt->months != 0) + || (dt->days != 0) + || (dt->seconds != 0) + || (dt->offset != 0) + || dt->duration); } void @@ -698,7 +695,7 @@ pcmk__time_log_as(const char *file, const char *function, int line, uint8_t level, const char *prefix, const crm_time_t *dt, uint32_t flags) { - char *date_s = crm_time_as_string(dt, flags); + char *date_s = pcmk__time_text(dt, flags); if (prefix != NULL) { char *old = date_s; @@ -715,18 +712,30 @@ pcmk__time_log_as(const char *file, const char *function, int line, free(date_s); } -int -crm_time_get_timeofday(const crm_time_t *dt, uint32_t *h, uint32_t *m, - uint32_t *s) +/*! + * \internal + * \brief Convert a time object's seconds field to hours, minutes, and seconds + * + * The resulting minutes and seconds are in the range [0, 59]. Accordingly, the + * number of hours is \p dt->seconds divided by \c SECONDS_IN_HOUR. See + * \c seconds_to_hms(). + * + * \param[in] dt Time object + * \param[out] hours Where to store hours + * \param[out] minutes Where to store minutes + * \param[out] seconds If not \c NULL, where to store seconds + */ +void +pcmk__time_get_timeofday(const crm_time_t *dt, uint32_t *hours, + uint32_t *minutes, uint32_t *seconds) { - pcmk__assert((dt != NULL) && (h != NULL) && (m != NULL) && (s != NULL)); - - seconds_to_hms(dt->seconds, h, m, s); - return TRUE; + pcmk__assert((dt != NULL) && (hours != NULL) && (minutes != NULL)); + seconds_to_hms(dt->seconds, hours, minutes, seconds); } +// Time in seconds since 0000-01-01 00:00:00Z long long -crm_time_get_seconds(const crm_time_t *dt) +pcmk__time_get_seconds(const crm_time_t *dt) { crm_time_t *utc = NULL; long long days = 0; @@ -768,57 +777,63 @@ crm_time_get_seconds(const crm_time_t *dt) return seconds; } -#define EPOCH_SECONDS 62135596800ULL /* Calculated using crm_time_get_seconds() */ +#define EPOCH_SECONDS 62135596800ULL // Calculated using pcmk__time_get_seconds long long crm_time_get_seconds_since_epoch(const crm_time_t *dt) { - return (dt == NULL)? 0 : (crm_time_get_seconds(dt) - EPOCH_SECONDS); + return (dt == NULL)? 0 : (pcmk__time_get_seconds(dt) - EPOCH_SECONDS); } -int -crm_time_get_gregorian(const crm_time_t *dt, uint32_t *y, uint32_t *m, - uint32_t *d) +/*! + * \internal + * \brief Convert a time object's years and seconds to year, month, and day + * + * \param[in] dt Time object + * \param[out] year Where to store year + * \param[out] month Where to store month + * \param[out] day Where to store day + * + * \note This has some incorrect behavior. See FIXME comments, and be mindful of + * public API when fixing these issues. + */ +void +pcmk__time_get_ymd(const crm_time_t *dt, uint32_t *year, uint32_t *month, + uint32_t *day) { - int months = 0; - int days = dt->days; - - pcmk__assert((dt != NULL) && (y != NULL) && (m != NULL) && (d != NULL)); - - if(dt->years != 0) { - for (months = 1; months <= 12 && days > 0; months++) { - int mdays = days_in_month_year(months, dt->years); - - if (mdays >= days) { - break; - } else { - days -= mdays; - } - } + pcmk__assert((dt != NULL) && (year != NULL) && (month != NULL) + && (day != NULL)); - } else if (dt->months) { - /* This is a duration including months, don't convert the days field */ - months = dt->months; + if (dt->years == 0) { + /* Assume this to be a duration and return the fields as they are. + * + * @FIXME This is a longstanding assumption. Nothing guarantees that + * this is actually a duration. However, it would be invalid as a date. + */ + CRM_LOG_ASSERT(dt->duration); - } else { - /* This is a duration not including months, still don't convert the days field */ + *year = dt->years; + *month = dt->months; + *day = dt->days; + return; } - *y = dt->years; - *m = months; - *d = days; - pcmk__trace("%.4d-%.3d -> %.4d-%.2d-%.2d", dt->years, dt->days, dt->years, - months, days); - return TRUE; -} + *year = dt->years; + *day = dt->days; -int -crm_time_get_ordinal(const crm_time_t *dt, uint32_t *y, uint32_t *d) -{ - pcmk__assert((dt != NULL) && (y != NULL) && (d != NULL)); + /* @FIXME This could also be a duration. It's incorrect to convert days to + * months in that case. + * + * @FIXME This could end with *month set to 13. + */ + for (*month = 1; *month <= 12; (*month)++) { + int mdays = days_in_month_year(*month, dt->years); - *y = dt->years; - *d = dt->days; - return TRUE; + if (mdays >= *day) { + return; + } + + *day -= mdays; + } } void @@ -908,23 +923,28 @@ sec_usec_as_string(long long sec, int usec, GString *buf) * \param[in] usec Microseconds to add to \p dt * \param[in] show_usec Whether to include microseconds in \p buf * \param[in,out] buf Result buffer + * + * \note This looks like it would produce incorrect output when \p dt has one or + * more negative fields. As a duration, however, it generally should not. */ static void duration_as_string(const crm_time_t *dt, int usec, bool show_usec, GString *buf) { pcmk__assert(valid_sec_usec(dt->seconds, usec)); - if (dt->years) { - g_string_append_printf(buf, "%4d year%s ", - dt->years, pcmk__plural_s(dt->years)); + if (dt->years != 0) { + g_string_append_printf(buf, "%4d year%s ", dt->years, + pcmk__plural_s(dt->years)); } - if (dt->months) { - g_string_append_printf(buf, "%2d month%s ", - dt->months, pcmk__plural_s(dt->months)); + + if (dt->months != 0) { + g_string_append_printf(buf, "%2d month%s ", dt->months, + pcmk__plural_s(dt->months)); } - if (dt->days) { - g_string_append_printf(buf, "%2d day%s ", - dt->days, pcmk__plural_s(dt->days)); + + if (dt->days != 0) { + g_string_append_printf(buf, "%2d day%s ", dt->days, + pcmk__plural_s(dt->days)); } // At least print seconds (and optionally usecs) @@ -934,34 +954,34 @@ duration_as_string(const crm_time_t *dt, int usec, bool show_usec, GString *buf) } else { g_string_append_printf(buf, "%d", dt->seconds); } + g_string_append_printf(buf, " second%s", pcmk__plural_s(dt->seconds)); } // More than one minute, so provide a more readable breakdown into units if (QB_ABS(dt->seconds) >= SECONDS_IN_MINUTE) { - uint32_t h = 0; - uint32_t m = 0; - uint32_t s = 0; - uint32_t u = QB_ABS(usec); + uint32_t hours = 0; + uint32_t minutes = 0; + uint32_t seconds = 0; bool print_sec_component = false; - seconds_to_hms(dt->seconds, &h, &m, &s); - print_sec_component = ((s != 0) || (show_usec && (u != 0))); + seconds_to_hms(dt->seconds, &hours, &minutes, &seconds); + print_sec_component = ((seconds != 0) || (show_usec && (usec != 0))); g_string_append(buf, " ("); - if (h) { - g_string_append_printf(buf, "%" PRIu32 " hour%s", - h, pcmk__plural_s(h)); + if (hours != 0) { + g_string_append_printf(buf, "%" PRIu32 " hour%s", hours, + pcmk__plural_s(hours)); - if ((m != 0) || print_sec_component) { + if ((minutes != 0) || print_sec_component) { g_string_append_c(buf, ' '); } } - if (m) { - g_string_append_printf(buf, "%" PRIu32 " minute%s", - m, pcmk__plural_s(m)); + if (minutes != 0) { + g_string_append_printf(buf, "%" PRIu32 " minute%s", minutes, + pcmk__plural_s(minutes)); if (print_sec_component) { g_string_append_c(buf, ' '); @@ -970,10 +990,11 @@ duration_as_string(const crm_time_t *dt, int usec, bool show_usec, GString *buf) if (print_sec_component) { if (show_usec) { - sec_usec_as_string(s, u, buf); + sec_usec_as_string(seconds, usec, buf); } else { - g_string_append_printf(buf, "%" PRIu32, s); + g_string_append_printf(buf, "%" PRIu32, seconds); } + g_string_append_printf(buf, " second%s", pcmk__plural_s(dt->seconds)); } @@ -1001,7 +1022,7 @@ time_as_string_common(const crm_time_t *dt, int usec, uint32_t flags) GString *buf = NULL; char *result = NULL; - if (!crm_time_is_defined(dt)) { + if (!pcmk__time_is_initialized(dt)) { return pcmk__str_copy(""); } @@ -1013,21 +1034,23 @@ time_as_string_common(const crm_time_t *dt, int usec, uint32_t flags) * These never depend on time zone. */ - if (pcmk__is_set(flags, crm_time_log_duration)) { - duration_as_string(dt, usec, pcmk__is_set(flags, crm_time_usecs), buf); + if (pcmk__is_set(flags, pcmk__time_fmt_duration)) { + duration_as_string(dt, usec, pcmk__is_set(flags, pcmk__time_fmt_usecs), + buf); goto done; } - if (pcmk__any_flags_set(flags, crm_time_seconds|crm_time_epoch)) { + if (pcmk__any_flags_set(flags, + pcmk__time_fmt_seconds|pcmk__time_fmt_epoch)) { long long seconds = 0; - if (pcmk__is_set(flags, crm_time_seconds)) { - seconds = crm_time_get_seconds(dt); + if (pcmk__is_set(flags, pcmk__time_fmt_seconds)) { + seconds = pcmk__time_get_seconds(dt); } else { seconds = crm_time_get_seconds_since_epoch(dt); } - if (pcmk__is_set(flags, crm_time_usecs)) { + if (pcmk__is_set(flags, pcmk__time_fmt_usecs)) { sec_usec_as_string(seconds, usec, buf); } else { g_string_append_printf(buf, "%lld", seconds); @@ -1036,15 +1059,15 @@ time_as_string_common(const crm_time_t *dt, int usec, uint32_t flags) } // Convert to UTC if local timezone was not requested - if ((dt->offset != 0) && !pcmk__is_set(flags, crm_time_log_with_timezone)) { + if ((dt->offset != 0) && !pcmk__is_set(flags, pcmk__time_fmt_timezone)) { utc = copy_time_to_utc(dt); dt = utc; } // As readable string - if (pcmk__is_set(flags, crm_time_log_date)) { - if (pcmk__is_set(flags, crm_time_weeks)) { // YYYY-WW-D + if (pcmk__is_set(flags, pcmk__time_fmt_date)) { + if (pcmk__is_set(flags, pcmk__time_fmt_weeks)) { // YYYY-WW-D if (dt->days > 0) { uint32_t y = 0; uint32_t w = 0; @@ -1056,47 +1079,37 @@ time_as_string_common(const crm_time_t *dt, int usec, uint32_t flags) y, w, d); } - } else if (pcmk__is_set(flags, crm_time_ordinal)) { // YYYY-DDD - uint32_t y = 0; - uint32_t d = 0; - - if (crm_time_get_ordinal(dt, &y, &d)) { - g_string_append_printf(buf, "%" PRIu32 "-%.3" PRIu32, y, d); - } + } else if (pcmk__is_set(flags, pcmk__time_fmt_ordinal)) { // YYYY-DDD + g_string_append_printf(buf, "%d-%.3d", dt->years, dt->days); } else { // YYYY-MM-DD uint32_t y = 0; uint32_t m = 0; uint32_t d = 0; - if (crm_time_get_gregorian(dt, &y, &m, &d)) { - g_string_append_printf(buf, - "%.4" PRIu32 "-%.2" PRIu32 "-%.2" PRIu32, - y, m, d); - } + pcmk__time_get_ymd(dt, &y, &m, &d); + g_string_append_printf(buf, + "%.4" PRIu32 "-%.2" PRIu32 "-%.2" PRIu32, + y, m, d); } } - if (pcmk__is_set(flags, crm_time_log_timeofday)) { + if (pcmk__is_set(flags, pcmk__time_fmt_time)) { uint32_t h = 0, m = 0, s = 0; if (buf->len > 0) { g_string_append_c(buf, ' '); } - if (crm_time_get_timeofday(dt, &h, &m, &s)) { - g_string_append_printf(buf, - "%.2" PRIu32 ":%.2" PRIu32 ":%.2" PRIu32, - h, m, s); + pcmk__time_get_timeofday(dt, &h, &m, &s); + g_string_append_printf(buf, "%.2" PRIu32 ":%.2" PRIu32 ":%.2" PRIu32, + h, m, s); - if (pcmk__is_set(flags, crm_time_usecs)) { - g_string_append_printf(buf, ".%06" PRIu32, QB_ABS(usec)); - } + if (pcmk__is_set(flags, pcmk__time_fmt_usecs)) { + g_string_append_printf(buf, ".%06" PRIu32, QB_ABS(usec)); } - if (pcmk__is_set(flags, crm_time_log_with_timezone) - && (dt->offset != 0)) { - + if (pcmk__is_set(flags, pcmk__time_fmt_timezone) && (dt->offset != 0)) { seconds_to_hms(dt->offset, &h, &m, NULL); g_string_append_printf(buf, " %c%.2" PRIu32 ":%.2" PRIu32, ((dt->offset < 0)? '-' : '+'), h, m); @@ -1114,15 +1127,16 @@ time_as_string_common(const crm_time_t *dt, int usec, uint32_t flags) } /*! - * \brief Get a string representation of a \p crm_time_t object + * \internal + * \brief Get a string representation of a \c crm_time_t object * - * \param[in] dt Time to convert to string - * \param[in] flags Group of \p crm_time_* string format options + * \param[in] dt Time to convert to string + * \param[in] flags Group of \c crm_time_* string format options * - * \note The caller is responsible for freeing the return value using \p free(). + * \note The caller is responsible for freeing the return value using \c free(). */ char * -crm_time_as_string(const crm_time_t *dt, int flags) +pcmk__time_text(const crm_time_t *dt, int flags) { return time_as_string_common(dt, 0, flags); } @@ -1282,18 +1296,19 @@ parse_duration_element(const char **element, const char *duration_s, } /*! + * \internal * \brief Parse a time duration from an ISO 8601 duration specification * * \param[in] period_s ISO 8601 duration specification (optionally followed by * whitespace, after which the rest of the string will be * ignored) * - * \return New time object on success, NULL (and set errno) otherwise - * \note It is the caller's responsibility to return the result using - * crm_time_free(). + * \return New time object on success, or \c NULL (and set \c errno) otherwise + * \note It is the caller's responsibility to free the result using + * \c crm_time_free(). */ crm_time_t * -crm_time_parse_duration(const char *period_s) +pcmk__time_parse_duration(const char *period_s) { bool is_time = false; crm_time_t *diff = NULL; @@ -1315,7 +1330,7 @@ crm_time_parse_duration(const char *period_s) goto invalid; } - diff = crm_time_new_undefined(); + diff = pcmk__assert_alloc(1, sizeof(crm_time_t)); for (const char *current = period_s + 1; current[0] && (current[0] != '/') && !isspace(current[0]); @@ -1337,17 +1352,20 @@ crm_time_parse_duration(const char *period_s) } } - if (!crm_time_is_defined(diff)) { + if (!pcmk__time_is_initialized(diff)) { pcmk__err("'%s' is not a valid ISO 8601 time duration because no " "amounts and units given", period_s); goto invalid; } - diff->duration = TRUE; + diff->duration = true; return diff; invalid: + /* @COMPAT Setting errno is required only for backward compatibility with + * crm_time_parse_duration() + */ crm_time_free(diff); errno = EINVAL; return NULL; @@ -1363,14 +1381,14 @@ crm_time_parse_duration(const char *period_s) void pcmk__set_time_if_earlier(crm_time_t *target, const crm_time_t *source) { - const int flags = crm_time_log_date - |crm_time_log_timeofday - |crm_time_log_with_timezone; + const int flags = pcmk__time_fmt_date + |pcmk__time_fmt_time + |pcmk__time_fmt_timezone; if ((target == NULL) || (source == NULL) - || (crm_time_is_defined(target) - && (crm_time_compare(source, target) >= 0))) { + || (pcmk__time_is_initialized(target) + && (pcmk__time_compare(source, target) >= 0))) { return; } @@ -1383,7 +1401,7 @@ pcmk__set_time_if_earlier(crm_time_t *target, const crm_time_t *source) crm_time_t * pcmk_copy_time(const crm_time_t *source) { - crm_time_t *target = crm_time_new_undefined(); + crm_time_t *target = pcmk__assert_alloc(1, sizeof(crm_time_t)); *target = *source; return target; @@ -1404,7 +1422,7 @@ crm_time_t * pcmk__copy_timet(time_t source_sec) { const struct tm *source = localtime(&source_sec); - crm_time_t *target = crm_time_new_undefined(); + crm_time_t *target = pcmk__assert_alloc(1, sizeof(crm_time_t)); int h_offset = 0; int m_offset = 0; @@ -1634,57 +1652,97 @@ subtract_time(const crm_time_t *dt1, const crm_time_t *dt2, bool as_duration) return result; } -crm_time_t * -crm_time_calculate_duration(const crm_time_t *dt, const crm_time_t *value) -{ - return subtract_time(dt, value, true); -} - crm_time_t * crm_time_subtract(const crm_time_t *dt, const crm_time_t *value) { return subtract_time(dt, value, false); } -#define do_cmp_field(l, r, field) \ - if(rc == 0) { \ - if(l->field > r->field) { \ - pcmk__trace("%s: %d > %d", \ - #field, l->field, r->field); \ - rc = 1; \ - } else if(l->field < r->field) { \ - pcmk__trace("%s: %d < %d", \ - #field, l->field, r->field); \ - rc = -1; \ - } \ - } - +/*! + * \internal + * \brief Compare two time objects + * + * Two time objects are equal if they're both \c NULL or if their corresponding + * \c years, \c days, and \c seconds fields are all equal. + * + * If only one time object is \c NULL, then it is considered to be the earlier + * time. + * + * Comparisons are performed after converting both time objects to UTC. + * + * \param[in] time1 First time object to compare + * \param[in] time2 Second time object to compare + * + * \retval -1 if \p time1 is earlier than \p time2 + * \retval 1 if \p time1 is later than \p time2 + * \retval 0 if \p time1 and \p time2 are equal + */ int -crm_time_compare(const crm_time_t *a, const crm_time_t *b) +pcmk__time_compare(const crm_time_t *time1, const crm_time_t *time2) { int rc = 0; - crm_time_t *t1 = NULL; - crm_time_t *t2 = NULL; + crm_time_t *utc1 = NULL; + crm_time_t *utc2 = NULL; - if ((a == NULL) && (b == NULL)) { - return 0; + if ((time1 == NULL) && (time2 == NULL)) { + goto done; + } + + if (time1 == NULL) { + rc = -1; + goto done; } - if (a == NULL) { - return -1; + + if (time2 == NULL) { + rc = 1; + goto done; } - if (b == NULL) { - return 1; + + utc1 = copy_time_to_utc(time1); + utc2 = copy_time_to_utc(time2); + + if (utc1->years < utc2->years) { + pcmk__trace("Years: %d < %d", utc1->years, utc2->years); + rc = -1; + goto done; } - t1 = copy_time_to_utc(a); - t2 = copy_time_to_utc(b); + if (utc1->years > utc2->years) { + pcmk__trace("Years: %d > %d", utc1->years, utc2->years); + rc = 1; + goto done; + } - do_cmp_field(t1, t2, years); - do_cmp_field(t1, t2, days); - do_cmp_field(t1, t2, seconds); + if (utc1->days < utc2->days) { + pcmk__trace("Days: %d < %d", utc1->days, utc2->days); + rc = -1; + goto done; + } - crm_time_free(t1); - crm_time_free(t2); + if (utc1->days > utc2->days) { + pcmk__trace("Days: %d > %d", utc1->days, utc2->days); + rc = 1; + goto done; + } + + if (utc1->seconds < utc2->seconds) { + pcmk__trace("Seconds: %d < %d", utc1->seconds, utc2->seconds); + rc = -1; + goto done; + } + + if (utc1->seconds > utc2->seconds) { + pcmk__trace("Seconds: %d > %d", utc1->seconds, utc2->seconds); + rc = 1; + goto done; + } + + pcmk__trace("Times equal: %d years, %d days, %d seconds", + utc1->years, utc1->days, utc1->seconds); + +done: + crm_time_free(utc1); + crm_time_free(utc2); return rc; } @@ -1765,7 +1823,7 @@ crm_time_add_months(crm_time_t *dt, int value) uint32_t day = 0; int days_in_month = 0; - crm_time_get_gregorian(dt, &year, &month, &day); + pcmk__time_get_ymd(dt, &year, &month, &day); if (value > 0) { for (int i = value; i > 0; i--) { @@ -2109,7 +2167,7 @@ pcmk__epoch2str(const time_t *source, uint32_t flags) } dt = pcmk__copy_timet(epoch_time); - result = crm_time_as_string(dt, flags); + result = pcmk__time_text(dt, flags); crm_time_free(dt); return result; @@ -2120,8 +2178,8 @@ pcmk__epoch2str(const time_t *source, uint32_t flags) * \brief Return a human-friendly string corresponding to seconds-and- * nanoseconds value * - * Time is shown with microsecond resolution if \p crm_time_usecs is in \p - * flags. + * Time is shown with microsecond resolution if \c pcmk__time_fmt_usecs is in + * \p flags. * * \param[in] ts Time in seconds and nanoseconds (or \p NULL for current * time) @@ -2251,9 +2309,9 @@ crm_time_january1_weekday(int year) void crm_time_set(crm_time_t *target, const crm_time_t *source) { - const uint32_t flags = crm_time_log_date - |crm_time_log_timeofday - |crm_time_log_with_timezone; + const uint32_t flags = pcmk__time_fmt_date + |pcmk__time_fmt_time + |pcmk__time_fmt_timezone; pcmk__trace("target=%p, source=%p", target, source); @@ -2335,7 +2393,7 @@ crm_time_parse_period(const char *period_str) period = pcmk__assert_alloc(1, sizeof(crm_time_period_t)); if (period_str[0] == 'P') { - period->diff = crm_time_parse_duration(period_str); + period->diff = pcmk__time_parse_duration(period_str); if (period->diff == NULL) { goto invalid; } @@ -2356,7 +2414,7 @@ crm_time_parse_period(const char *period_str) original); goto invalid; } - period->diff = crm_time_parse_duration(period_str); + period->diff = pcmk__time_parse_duration(period_str); if (period->diff == NULL) { goto invalid; } @@ -2412,5 +2470,73 @@ crm_time_parse_period(const char *period_str) return NULL; } +crm_time_t * +crm_time_calculate_duration(const crm_time_t *dt, const crm_time_t *value) +{ + return subtract_time(dt, value, true); +} + +crm_time_t * +crm_time_parse_duration(const char *period_s) +{ + return pcmk__time_parse_duration(period_s); +} + +crm_time_t * +crm_time_new_undefined(void) +{ + return pcmk__assert_alloc(1, sizeof(crm_time_t)); +} + +bool +crm_time_is_defined(const crm_time_t *t) +{ + return pcmk__time_is_initialized(t); +} + +char * +crm_time_as_string(const crm_time_t *dt, int flags) +{ + return pcmk__time_text(dt, flags); +} + +int +crm_time_compare(const crm_time_t *a, const crm_time_t *b) +{ + return pcmk__time_compare(a, b); +} + +int +crm_time_get_timeofday(const crm_time_t *dt, uint32_t *h, uint32_t *m, + uint32_t *s) +{ + pcmk__time_get_timeofday(dt, h, m, s); + return TRUE; +} + +int +crm_time_get_gregorian(const crm_time_t *dt, uint32_t *y, uint32_t *m, + uint32_t *d) +{ + pcmk__time_get_ymd(dt, y, m, d); + return TRUE; +} + +int +crm_time_get_ordinal(const crm_time_t *dt, uint32_t *y, uint32_t *d) +{ + pcmk__assert((dt != NULL) && (y != NULL) && (d != NULL)); + + *y = dt->years; + *d = dt->days; + return TRUE; +} + +long long +crm_time_get_seconds(const crm_time_t *dt) +{ + return pcmk__time_get_seconds(dt); +} + // LCOV_EXCL_STOP // End deprecated API diff --git a/lib/common/messages.c b/lib/common/messages.c index e7072ce8696..370550e867f 100644 --- a/lib/common/messages.c +++ b/lib/common/messages.c @@ -242,5 +242,5 @@ void pcmk__reset_request(pcmk__request_t *request) { g_clear_pointer(&request->op, free); - pcmk__reset_result(&(request->result)); + pcmk__reset_result(&request->result); } diff --git a/lib/common/nvpair.c b/lib/common/nvpair.c index 3f1bed26e02..b855da334b5 100644 --- a/lib/common/nvpair.c +++ b/lib/common/nvpair.c @@ -446,7 +446,7 @@ pcmk__unpack_nvpair_block(void *data, void *user_data) rule_xml = pcmk__xe_first_child(pair, PCMK_XE_RULE, NULL, NULL); if ((rule_xml != NULL) - && (pcmk_evaluate_rule(rule_xml, &(unpack_data->rule_input), + && (pcmk_evaluate_rule(rule_xml, &unpack_data->rule_input, unpack_data->next_change) != pcmk_rc_ok)) { return; } diff --git a/lib/common/patchset.c b/lib/common/patchset.c index 778be7ff9bd..ad4ad33b2b4 100644 --- a/lib/common/patchset.c +++ b/lib/common/patchset.c @@ -512,7 +512,7 @@ pcmk__xml_patchset_versions(const xmlNode *patchset, int source[3], for (int i = 0; i < PCMK__NELEM(vfields); i++) { if (source_xml != NULL) { if (pcmk__xe_get_int(source_xml, vfields[i], - &(source[i])) != pcmk_rc_ok) { + &source[i]) != pcmk_rc_ok) { return EINVAL; } pcmk__trace("Got source[%s]=%d", vfields[i], source[i]); @@ -524,7 +524,7 @@ pcmk__xml_patchset_versions(const xmlNode *patchset, int source[3], if (target_xml != NULL) { if (pcmk__xe_get_int(target_xml, vfields[i], - &(target[i])) != pcmk_rc_ok) { + &target[i]) != pcmk_rc_ok) { return EINVAL; } pcmk__trace("Got target[%s]=%d", vfields[i], target[i]); @@ -561,8 +561,7 @@ check_patchset_versions(const xmlNode *cib_root, const xmlNode *patchset) * Preserve behavior for xml_apply_patchset(). Use new behavior in a * future replacement. */ - if (pcmk__xe_get_int(cib_root, vfields[i], - &(current[i])) == pcmk_rc_ok) { + if (pcmk__xe_get_int(cib_root, vfields[i], ¤t[i]) == pcmk_rc_ok) { pcmk__trace("Got %d for current[%s]%s", current[i], vfields[i], ((current[i] < 0)? ", using 0" : "")); } else { @@ -1133,14 +1132,14 @@ xml_patch_versions(const xmlNode *patchset, int add[3], int del[3]) if (source != NULL) { for (int i = 0; i < PCMK__NELEM(vfields); i++) { - pcmk__xe_get_int(source, vfields[i], &(del[i])); + pcmk__xe_get_int(source, vfields[i], &del[i]); pcmk__trace("Got %d for del[%s]", del[i], vfields[i]); } } if (target != NULL) { for (int i = 0; i < PCMK__NELEM(vfields); i++) { - pcmk__xe_get_int(target, vfields[i], &(add[i])); + pcmk__xe_get_int(target, vfields[i], &add[i]); pcmk__trace("Got %d for add[%s]", add[i], vfields[i]); } } diff --git a/lib/common/remote.c b/lib/common/remote.c index a9ce088f3f1..a445c059ab2 100644 --- a/lib/common/remote.c +++ b/lib/common/remote.c @@ -202,11 +202,11 @@ remote_send_iovs(pcmk__remote_t *remote, struct iovec *iov, int iovs) for (int lpc = 0; (lpc < iovs) && (rc == pcmk_rc_ok); lpc++) { if (remote->tls_session) { - rc = send_tls(remote->tls_session, &(iov[lpc])); + rc = send_tls(remote->tls_session, &iov[lpc]); continue; } if (remote->tcp_socket >= 0) { - rc = send_plaintext(remote->tcp_socket, &(iov[lpc])); + rc = send_plaintext(remote->tcp_socket, &iov[lpc]); } else { rc = ESOCKTNOSUPPORT; } diff --git a/lib/common/rules.c b/lib/common/rules.c index b840245bc4c..97c14070d57 100644 --- a/lib/common/rules.c +++ b/lib/common/rules.c @@ -184,19 +184,19 @@ pcmk__evaluate_date_spec(const xmlNode *date_spec, const crm_time_t *now) } // Year, month, day - crm_time_get_gregorian(now, &(ranges[0].value), &(ranges[1].value), - &(ranges[2].value)); + pcmk__time_get_ymd(now, &ranges[0].value, &ranges[1].value, + &ranges[2].value); // Hour, minute, second - crm_time_get_timeofday(now, &(ranges[3].value), &(ranges[4].value), - &(ranges[5].value)); + pcmk__time_get_timeofday(now, &ranges[3].value, &ranges[4].value, + &ranges[5].value); - // Year (redundant) and day of year - crm_time_get_ordinal(now, &(ranges[0].value), &(ranges[6].value)); + // Day of year + ranges[6].value = now->days; // Week year, week of week year, day of week - pcmk__time_get_ywd(now, &(ranges[7].value), &(ranges[8].value), - &(ranges[9].value)); + pcmk__time_get_ywd(now, &ranges[7].value, &ranges[8].value, + &ranges[9].value); for (int i = 0; i < PCMK__NELEM(ranges); ++i) { int rc = check_range(date_spec, parent_id, ranges[i].attr, @@ -332,7 +332,7 @@ evaluate_in_range(const xmlNode *date_expression, const char *id, } } - if ((start != NULL) && (crm_time_compare(now, start) < 0)) { + if ((start != NULL) && (pcmk__time_compare(now, start) < 0)) { pcmk__set_time_if_earlier(next_change, start); crm_time_free(start); crm_time_free(end); @@ -340,7 +340,7 @@ evaluate_in_range(const xmlNode *date_expression, const char *id, } if (end != NULL) { - if (crm_time_compare(now, end) > 0) { + if (pcmk__time_compare(now, end) > 0) { crm_time_free(start); crm_time_free(end); return pcmk_rc_after_range; @@ -392,7 +392,7 @@ evaluate_gt(const xmlNode *date_expression, const char *id, return pcmk_rc_unpack_error; } - if (crm_time_compare(now, start) > 0) { + if (pcmk__time_compare(now, start) > 0) { crm_time_free(start); return pcmk_rc_within_range; } @@ -437,7 +437,7 @@ evaluate_lt(const xmlNode *date_expression, const char *id, return pcmk_rc_unpack_error; } - if (crm_time_compare(now, end) < 0) { + if (pcmk__time_compare(now, end) < 0) { pcmk__set_time_if_earlier(next_change, end); crm_time_free(end); return pcmk_rc_within_range; diff --git a/lib/common/schemas.c b/lib/common/schemas.c index 7f2c4b6c8bd..5c2dc92c569 100644 --- a/lib/common/schemas.c +++ b/lib/common/schemas.c @@ -164,9 +164,11 @@ version_from_filename(const char *filename, pcmk__schema_version_t *version) } if (g_str_has_suffix(filename, ".rng")) { - return sscanf(filename, "pacemaker-%hhu.%hhu.rng", &(version->v[0]), &(version->v[1])) == 2; + return sscanf(filename, "pacemaker-%hhu.%hhu.rng", &version->v[0], + &version->v[1]) == 2; } else { - return sscanf(filename, "pacemaker-%hhu.%hhu", &(version->v[0]), &(version->v[1])) == 2; + return sscanf(filename, "pacemaker-%hhu.%hhu", &version->v[0], + &version->v[1]) == 2; } } @@ -389,7 +391,7 @@ load_transforms_from_dir(const char *dir) unsigned char order = 0; // Placeholder only if (sscanf(namelist[i]->d_name, "upgrade-%hhu.%hhu-%hhu.xsl", - &(version.v[0]), &(version.v[1]), &order) == 3) { + &version.v[0], &version.v[1], &order) == 3) { char *version_s = pcmk__assert_asprintf("%hhu.%hhu", version.v[0], version.v[1]); @@ -771,7 +773,7 @@ validate_with(xmlDoc *doc, pcmk__schema_t *schema, schema->validator); switch (schema->validator) { case pcmk__schema_validator_rng: - cache = (relaxng_ctx_cache_t **) &(schema->cache); + cache = (relaxng_ctx_cache_t **) &schema->cache; valid = validate_with_relaxng(doc, error_handler, error_handler_context, file, cache); break; diff --git a/lib/common/strings.c b/lib/common/strings.c index 72ea9f02213..0a6feff7b19 100644 --- a/lib/common/strings.c +++ b/lib/common/strings.c @@ -372,10 +372,10 @@ pcmk_parse_interval_spec(const char *input, unsigned int *result_ms) } if (input[0] == 'P') { - crm_time_t *period_s = crm_time_parse_duration(input); + crm_time_t *period_s = pcmk__time_parse_duration(input); if (period_s != NULL) { - msec = crm_time_get_seconds(period_s); + msec = pcmk__time_get_seconds(period_s); msec = QB_MIN(msec, UINT_MAX / 1000) * 1000; crm_time_free(period_s); } diff --git a/lib/common/tests/iso8601/Makefile.am b/lib/common/tests/iso8601/Makefile.am index 92ac3b5b273..8dd1ef06f48 100644 --- a/lib/common/tests/iso8601/Makefile.am +++ b/lib/common/tests/iso8601/Makefile.am @@ -15,10 +15,10 @@ include $(top_srcdir)/mk/unittest.mk check_PROGRAMS = crm_time_add_days_test check_PROGRAMS += crm_time_add_seconds_test check_PROGRAMS += crm_time_add_years_test -check_PROGRAMS += crm_time_parse_duration_test check_PROGRAMS += pcmk__add_time_from_xml_test check_PROGRAMS += pcmk__readable_interval_test check_PROGRAMS += pcmk__set_time_if_earlier_test check_PROGRAMS += pcmk__time_format_hr_test +check_PROGRAMS += pcmk__time_parse_duration_test TESTS = $(check_PROGRAMS) diff --git a/lib/common/tests/iso8601/crm_time_add_days_test.c b/lib/common/tests/iso8601/crm_time_add_days_test.c index c9ad3616d78..b7995355b48 100644 --- a/lib/common/tests/iso8601/crm_time_add_days_test.c +++ b/lib/common/tests/iso8601/crm_time_add_days_test.c @@ -1,5 +1,5 @@ /* - * Copyright 2024-2025 the Pacemaker project contributors + * Copyright 2024-2026 the Pacemaker project contributors * * The version control history for this file may have further details. * @@ -27,7 +27,7 @@ assert_add_days(const char *orig_date_time, int days, assert_non_null(expected); crm_time_add_days(orig, days); - assert_int_equal(crm_time_compare(orig, expected), 0); + assert_int_equal(pcmk__time_compare(orig, expected), 0); crm_time_free(orig); crm_time_free(expected); diff --git a/lib/common/tests/iso8601/crm_time_add_seconds_test.c b/lib/common/tests/iso8601/crm_time_add_seconds_test.c index 4315d7dcb5d..6cb957e689b 100644 --- a/lib/common/tests/iso8601/crm_time_add_seconds_test.c +++ b/lib/common/tests/iso8601/crm_time_add_seconds_test.c @@ -1,5 +1,5 @@ /* - * Copyright 2024 the Pacemaker project contributors + * Copyright 2024-2026 the Pacemaker project contributors * * The version control history for this file may have further details. * @@ -27,7 +27,7 @@ assert_add_seconds(const char *orig_date_time, int seconds, assert_non_null(expected); crm_time_add_seconds(orig, seconds); - assert_int_equal(crm_time_compare(orig, expected), 0); + assert_int_equal(pcmk__time_compare(orig, expected), 0); crm_time_free(orig); crm_time_free(expected); diff --git a/lib/common/tests/iso8601/crm_time_add_years_test.c b/lib/common/tests/iso8601/crm_time_add_years_test.c index 8ea6b4d1c46..35831673cdb 100644 --- a/lib/common/tests/iso8601/crm_time_add_years_test.c +++ b/lib/common/tests/iso8601/crm_time_add_years_test.c @@ -1,5 +1,5 @@ /* - * Copyright 2024-2025 the Pacemaker project contributors + * Copyright 2024-2026 the Pacemaker project contributors * * The version control history for this file may have further details. * @@ -27,7 +27,7 @@ assert_add_years(const char *orig_date_time, int years, assert_non_null(expected); crm_time_add_years(orig, years); - assert_int_equal(crm_time_compare(orig, expected), 0); + assert_int_equal(pcmk__time_compare(orig, expected), 0); crm_time_free(orig); crm_time_free(expected); diff --git a/lib/common/tests/iso8601/crm_time_parse_duration_test.c b/lib/common/tests/iso8601/crm_time_parse_duration_test.c deleted file mode 100644 index 58015e82422..00000000000 --- a/lib/common/tests/iso8601/crm_time_parse_duration_test.c +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright 2024 the Pacemaker project contributors - * - * The version control history for this file may have further details. - * - * This source code is licensed under the GNU General Public License version 2 - * or later (GPLv2+) WITHOUT ANY WARRANTY. - */ - -#include - -#include - -#include -#include "crmcommon_private.h" - -static void -empty_arg(void **state) -{ - assert_null(crm_time_parse_duration(NULL)); - assert_null(crm_time_parse_duration("")); -} - -static void -invalid_arg(void **state) -{ - // Valid except doesn't start with P - assert_null(crm_time_parse_duration("X3Y6M4DT12H30M5S")); - - // Illegal character after P - assert_null(crm_time_parse_duration("P")); - assert_null(crm_time_parse_duration("P 3Y6M4DT12H30M5S")); - assert_null(crm_time_parse_duration("PX3Y6M4DT12H30M5S")); - - // Missing or invalid units - assert_null(crm_time_parse_duration("P3Y6M4DT12H30M5")); - assert_null(crm_time_parse_duration("P3Y6M4DT12H30M5X")); - assert_null(crm_time_parse_duration("P3X6M4DT12H30M5S")); - assert_null(crm_time_parse_duration("PT")); - assert_null(crm_time_parse_duration("P/")); - -#if 0 - // @TODO The current implementation treats these as valid - - // Units out of order - assert_null(crm_time_parse_duration("P6M3Y4DT12H30M5S")); - assert_null(crm_time_parse_duration("P6M3DT12HY430M5S")); - - // Same unit specified multiple times - assert_null(crm_time_parse_duration("P6Y4M3D1MT12H30M5S")); - - // Weeks mixed with other units - assert_null(crm_time_parse_duration("P6Y4M3W3D1MT12H30M5S")); - assert_null(crm_time_parse_duration("P3WT12H30M5S")); -#endif -} - -static void -overflow(void **state) -{ - // Too large - assert_null(crm_time_parse_duration("P2147483648Y6M4DT12H30M5S")); - assert_null(crm_time_parse_duration("P3Y2147483648M4DT12H30M5S")); - assert_null(crm_time_parse_duration("P3Y6M2147483648DT12H30M5S")); - assert_null(crm_time_parse_duration("P3Y6M4DT2147483648H30M5S")); - assert_null(crm_time_parse_duration("P3Y6M4DT12H2147483648M5S")); - assert_null(crm_time_parse_duration("P3Y6M4DT12H30MP2147483648S")); - - // Too small - assert_null(crm_time_parse_duration("P-2147483648Y6M4DT12H30M5S")); - assert_null(crm_time_parse_duration("P3Y-2147483648M4DT12H30M5S")); - assert_null(crm_time_parse_duration("P3Y6M-2147483648DT12H30M5S")); - assert_null(crm_time_parse_duration("P3Y6M4DT-2147483648H30M5S")); - assert_null(crm_time_parse_duration("P3Y6M4DT12H-2147483648M5S")); - assert_null(crm_time_parse_duration("P3Y6M4DT12H30MP-2147483648S")); -} - -static void -valid_arg(void **state) -{ - // @TODO Check result value - assert_non_null(crm_time_parse_duration("P3Y6M4DT12H30M5S")); - assert_non_null(crm_time_parse_duration("P3Y6M4DT12H30M-5S")); - assert_non_null(crm_time_parse_duration("P3Y6M4DT12H-30M5S")); - assert_non_null(crm_time_parse_duration("P3Y6M4DT-12H30M5S")); - assert_non_null(crm_time_parse_duration("P3Y6M-4DT12H30M5S")); - assert_non_null(crm_time_parse_duration("P3Y-6M4DT12H30M5S")); - assert_non_null(crm_time_parse_duration("P3Y6M4DT12H30M")); - assert_non_null(crm_time_parse_duration("P3Y6M4D")); - assert_non_null(crm_time_parse_duration("P1M")); // 1 month - assert_non_null(crm_time_parse_duration("PT1M")); // 1 minute - assert_non_null(crm_time_parse_duration("P7W")); - -#if 0 - // @TODO Current implementation can't handle these cases - - // Fractional value for last unit - assert_non_null(crm_time_parse_duration("P3Y6M4DT12H30.5M")); - assert_non_null(crm_time_parse_duration("P3Y6M4DT12H30,5M")); - - // P--
T:: format - assert_non_null(crm_time_parse_duration("P0003-02-01T11:10:09"); -#endif -} - -PCMK__UNIT_TEST(NULL, NULL, - cmocka_unit_test(empty_arg), - cmocka_unit_test(invalid_arg), - cmocka_unit_test(overflow), - cmocka_unit_test(valid_arg)); diff --git a/lib/common/tests/iso8601/pcmk__add_time_from_xml_test.c b/lib/common/tests/iso8601/pcmk__add_time_from_xml_test.c index fa7f6ab183e..ebea2842ab6 100644 --- a/lib/common/tests/iso8601/pcmk__add_time_from_xml_test.c +++ b/lib/common/tests/iso8601/pcmk__add_time_from_xml_test.c @@ -1,5 +1,5 @@ /* - * Copyright 2024 the Pacemaker project contributors + * Copyright 2024-2026 the Pacemaker project contributors * * The version control history for this file may have further details. * @@ -45,7 +45,7 @@ null_xml_ok(void **state) assert_int_equal(pcmk__add_time_from_xml(t, pcmk__time_years, NULL), pcmk_rc_ok); - assert_int_equal(crm_time_compare(t, reference), 0); + assert_int_equal(pcmk__time_compare(t, reference), 0); crm_time_free(t); crm_time_free(reference); @@ -70,7 +70,7 @@ missing_attr(void **state) assert_int_equal(pcmk__add_time_from_xml(t, pcmk__time_months, xml), pcmk_rc_ok); - assert_int_equal(crm_time_compare(t, reference), 0); + assert_int_equal(pcmk__time_compare(t, reference), 0); crm_time_free(t); crm_time_free(reference); @@ -86,7 +86,7 @@ invalid_attr(void **state) assert_int_equal(pcmk__add_time_from_xml(t, pcmk__time_years, xml), pcmk_rc_unpack_error); - assert_int_equal(crm_time_compare(t, reference), 0); + assert_int_equal(pcmk__time_compare(t, reference), 0); crm_time_free(t); crm_time_free(reference); @@ -102,12 +102,12 @@ out_of_range_attr(void **state) xml = pcmk__xml_parse(YEARS_TOO_BIG); assert_int_equal(pcmk__add_time_from_xml(t, pcmk__time_years, xml), ERANGE); - assert_int_equal(crm_time_compare(t, reference), 0); + assert_int_equal(pcmk__time_compare(t, reference), 0); pcmk__xml_free(xml); xml = pcmk__xml_parse(YEARS_TOO_SMALL); assert_int_equal(pcmk__add_time_from_xml(t, pcmk__time_years, xml), ERANGE); - assert_int_equal(crm_time_compare(t, reference), 0); + assert_int_equal(pcmk__time_compare(t, reference), 0); pcmk__xml_free(xml); crm_time_free(t); @@ -123,7 +123,7 @@ add_years(void **state) assert_int_equal(pcmk__add_time_from_xml(t, pcmk__time_years, xml), pcmk_rc_ok); - assert_int_equal(crm_time_compare(t, reference), 0); + assert_int_equal(pcmk__time_compare(t, reference), 0); crm_time_free(t); crm_time_free(reference); @@ -139,7 +139,7 @@ add_months(void **state) assert_int_equal(pcmk__add_time_from_xml(t, pcmk__time_months, xml), pcmk_rc_ok); - assert_int_equal(crm_time_compare(t, reference), 0); + assert_int_equal(pcmk__time_compare(t, reference), 0); crm_time_free(t); crm_time_free(reference); @@ -155,7 +155,7 @@ add_weeks(void **state) assert_int_equal(pcmk__add_time_from_xml(t, pcmk__time_weeks, xml), pcmk_rc_ok); - assert_int_equal(crm_time_compare(t, reference), 0); + assert_int_equal(pcmk__time_compare(t, reference), 0); crm_time_free(t); crm_time_free(reference); @@ -171,7 +171,7 @@ add_days(void **state) assert_int_equal(pcmk__add_time_from_xml(t, pcmk__time_days, xml), pcmk_rc_ok); - assert_int_equal(crm_time_compare(t, reference), 0); + assert_int_equal(pcmk__time_compare(t, reference), 0); crm_time_free(t); crm_time_free(reference); @@ -187,7 +187,7 @@ add_hours(void **state) assert_int_equal(pcmk__add_time_from_xml(t, pcmk__time_hours, xml), pcmk_rc_ok); - assert_int_equal(crm_time_compare(t, reference), 0); + assert_int_equal(pcmk__time_compare(t, reference), 0); crm_time_free(t); crm_time_free(reference); @@ -203,7 +203,7 @@ add_minutes(void **state) assert_int_equal(pcmk__add_time_from_xml(t, pcmk__time_minutes, xml), pcmk_rc_ok); - assert_int_equal(crm_time_compare(t, reference), 0); + assert_int_equal(pcmk__time_compare(t, reference), 0); crm_time_free(t); crm_time_free(reference); @@ -219,7 +219,7 @@ add_seconds(void **state) assert_int_equal(pcmk__add_time_from_xml(t, pcmk__time_seconds, xml), pcmk_rc_ok); - assert_int_equal(crm_time_compare(t, reference), 0); + assert_int_equal(pcmk__time_compare(t, reference), 0); crm_time_free(t); crm_time_free(reference); diff --git a/lib/common/tests/iso8601/pcmk__set_time_if_earlier_test.c b/lib/common/tests/iso8601/pcmk__set_time_if_earlier_test.c index c4bf0140825..86d82cb8bab 100644 --- a/lib/common/tests/iso8601/pcmk__set_time_if_earlier_test.c +++ b/lib/common/tests/iso8601/pcmk__set_time_if_earlier_test.c @@ -1,5 +1,5 @@ /* - * Copyright 2024 the Pacemaker project contributors + * Copyright 2024-2026 the Pacemaker project contributors * * The version control history for this file may have further details. * @@ -26,7 +26,7 @@ null_ok(void **state) // Shouldn't assert, crash, or change target pcmk__set_time_if_earlier(target, NULL); - assert_int_equal(crm_time_compare(target, target_copy), 0); + assert_int_equal(pcmk__time_compare(target, target_copy), 0); crm_time_free(target); crm_time_free(target_copy); @@ -36,10 +36,10 @@ static void target_undefined(void **state) { crm_time_t *source = crm_time_new("2024-01-01 00:29:59 +01:00"); - crm_time_t *target = crm_time_new_undefined(); + crm_time_t *target = pcmk__assert_alloc(1, sizeof(crm_time_t)); pcmk__set_time_if_earlier(target, source); - assert_int_equal(crm_time_compare(target, source), 0); + assert_int_equal(pcmk__time_compare(target, source), 0); crm_time_free(source); crm_time_free(target); @@ -52,7 +52,7 @@ source_earlier(void **state) crm_time_t *target = crm_time_new("2024-01-01 00:30:00 +01:00"); pcmk__set_time_if_earlier(target, source); - assert_int_equal(crm_time_compare(target, source), 0); + assert_int_equal(pcmk__time_compare(target, source), 0); crm_time_free(source); crm_time_free(target); @@ -66,7 +66,7 @@ source_later(void **state) crm_time_t *target_copy = pcmk_copy_time(target); pcmk__set_time_if_earlier(target, source); - assert_int_equal(crm_time_compare(target, target_copy), 0); + assert_int_equal(pcmk__time_compare(target, target_copy), 0); crm_time_free(source); crm_time_free(target); diff --git a/lib/common/tests/iso8601/pcmk__time_parse_duration_test.c b/lib/common/tests/iso8601/pcmk__time_parse_duration_test.c new file mode 100644 index 00000000000..76acc590741 --- /dev/null +++ b/lib/common/tests/iso8601/pcmk__time_parse_duration_test.c @@ -0,0 +1,110 @@ +/* + * Copyright 2024-2026 the Pacemaker project contributors + * + * The version control history for this file may have further details. + * + * This source code is licensed under the GNU General Public License version 2 + * or later (GPLv2+) WITHOUT ANY WARRANTY. + */ + +#include + +#include + +#include +#include "crmcommon_private.h" + +static void +empty_arg(void **state) +{ + assert_null(pcmk__time_parse_duration(NULL)); + assert_null(pcmk__time_parse_duration("")); +} + +static void +invalid_arg(void **state) +{ + // Valid except doesn't start with P + assert_null(pcmk__time_parse_duration("X3Y6M4DT12H30M5S")); + + // Illegal character after P + assert_null(pcmk__time_parse_duration("P")); + assert_null(pcmk__time_parse_duration("P 3Y6M4DT12H30M5S")); + assert_null(pcmk__time_parse_duration("PX3Y6M4DT12H30M5S")); + + // Missing or invalid units + assert_null(pcmk__time_parse_duration("P3Y6M4DT12H30M5")); + assert_null(pcmk__time_parse_duration("P3Y6M4DT12H30M5X")); + assert_null(pcmk__time_parse_duration("P3X6M4DT12H30M5S")); + assert_null(pcmk__time_parse_duration("PT")); + assert_null(pcmk__time_parse_duration("P/")); + +#if 0 + // @TODO The current implementation treats these as valid + + // Units out of order + assert_null(pcmk__time_parse_duration("P6M3Y4DT12H30M5S")); + assert_null(pcmk__time_parse_duration("P6M3DT12HY430M5S")); + + // Same unit specified multiple times + assert_null(pcmk__time_parse_duration("P6Y4M3D1MT12H30M5S")); + + // Weeks mixed with other units + assert_null(pcmk__time_parse_duration("P6Y4M3W3D1MT12H30M5S")); + assert_null(pcmk__time_parse_duration("P3WT12H30M5S")); +#endif +} + +static void +overflow(void **state) +{ + // Too large + assert_null(pcmk__time_parse_duration("P2147483648Y6M4DT12H30M5S")); + assert_null(pcmk__time_parse_duration("P3Y2147483648M4DT12H30M5S")); + assert_null(pcmk__time_parse_duration("P3Y6M2147483648DT12H30M5S")); + assert_null(pcmk__time_parse_duration("P3Y6M4DT2147483648H30M5S")); + assert_null(pcmk__time_parse_duration("P3Y6M4DT12H2147483648M5S")); + assert_null(pcmk__time_parse_duration("P3Y6M4DT12H30MP2147483648S")); + + // Too small + assert_null(pcmk__time_parse_duration("P-2147483648Y6M4DT12H30M5S")); + assert_null(pcmk__time_parse_duration("P3Y-2147483648M4DT12H30M5S")); + assert_null(pcmk__time_parse_duration("P3Y6M-2147483648DT12H30M5S")); + assert_null(pcmk__time_parse_duration("P3Y6M4DT-2147483648H30M5S")); + assert_null(pcmk__time_parse_duration("P3Y6M4DT12H-2147483648M5S")); + assert_null(pcmk__time_parse_duration("P3Y6M4DT12H30MP-2147483648S")); +} + +static void +valid_arg(void **state) +{ + // @TODO Check result value + assert_non_null(pcmk__time_parse_duration("P3Y6M4DT12H30M5S")); + assert_non_null(pcmk__time_parse_duration("P3Y6M4DT12H30M-5S")); + assert_non_null(pcmk__time_parse_duration("P3Y6M4DT12H-30M5S")); + assert_non_null(pcmk__time_parse_duration("P3Y6M4DT-12H30M5S")); + assert_non_null(pcmk__time_parse_duration("P3Y6M-4DT12H30M5S")); + assert_non_null(pcmk__time_parse_duration("P3Y-6M4DT12H30M5S")); + assert_non_null(pcmk__time_parse_duration("P3Y6M4DT12H30M")); + assert_non_null(pcmk__time_parse_duration("P3Y6M4D")); + assert_non_null(pcmk__time_parse_duration("P1M")); // 1 month + assert_non_null(pcmk__time_parse_duration("PT1M")); // 1 minute + assert_non_null(pcmk__time_parse_duration("P7W")); + +#if 0 + // @TODO Current implementation can't handle these cases + + // Fractional value for last unit + assert_non_null(pcmk__time_parse_duration("P3Y6M4DT12H30.5M")); + assert_non_null(pcmk__time_parse_duration("P3Y6M4DT12H30,5M")); + + // P--
T:: format + assert_non_null(pcmk__time_parse_duration("P0003-02-01T11:10:09"); +#endif +} + +PCMK__UNIT_TEST(NULL, NULL, + cmocka_unit_test(empty_arg), + cmocka_unit_test(invalid_arg), + cmocka_unit_test(overflow), + cmocka_unit_test(valid_arg)); diff --git a/lib/common/tests/nvpair/pcmk__unpack_nvpair_blocks_test.c b/lib/common/tests/nvpair/pcmk__unpack_nvpair_blocks_test.c index 6bea483f134..c2e9e7a9e9a 100644 --- a/lib/common/tests/nvpair/pcmk__unpack_nvpair_blocks_test.c +++ b/lib/common/tests/nvpair/pcmk__unpack_nvpair_blocks_test.c @@ -144,7 +144,7 @@ rule_fails(void **state) assert_string_equal(g_hash_table_lookup(values, "name1"), "3"); assert_string_equal(g_hash_table_lookup(values, "name2"), "3"); assert_string_equal(g_hash_table_lookup(values, "name3"), "3"); - assert_int_equal(crm_time_compare(next_change, expected_next_change), 0); + assert_int_equal(pcmk__time_compare(next_change, expected_next_change), 0); pcmk__xml_free(xml); crm_time_free(now); diff --git a/lib/common/tests/rules/pcmk__evaluate_condition_test.c b/lib/common/tests/rules/pcmk__evaluate_condition_test.c index be0931a0267..32d1ab23048 100644 --- a/lib/common/tests/rules/pcmk__evaluate_condition_test.c +++ b/lib/common/tests/rules/pcmk__evaluate_condition_test.c @@ -42,7 +42,7 @@ static void null_invalid(void **state) { xmlNode *xml = NULL; - crm_time_t *next_change = crm_time_new_undefined(); + crm_time_t *next_change = pcmk__assert_alloc(1, sizeof(crm_time_t)); assert_int_equal(pcmk__evaluate_condition(NULL, NULL, next_change), EINVAL); @@ -63,7 +63,7 @@ static void invalid_expression(void **state) { xmlNode *xml = pcmk__xml_parse(EXPR_INVALID); - crm_time_t *next_change = crm_time_new_undefined(); + crm_time_t *next_change = pcmk__assert_alloc(1, sizeof(crm_time_t)); assert_int_equal(pcmk__evaluate_condition(xml, &rule_input, next_change), pcmk_rc_unpack_error); @@ -130,7 +130,7 @@ date_expression(void **state) rule_input.now = now; assert_int_equal(pcmk__evaluate_condition(xml, &rule_input, next_change), pcmk_rc_before_range); - assert_int_equal(crm_time_compare(next_change, reference), 0); + assert_int_equal(pcmk__time_compare(next_change, reference), 0); rule_input.now = NULL; crm_time_free(reference); diff --git a/lib/common/tests/rules/pcmk__evaluate_date_expression_test.c b/lib/common/tests/rules/pcmk__evaluate_date_expression_test.c index cfb6bdbf7f5..bed8fc3e998 100644 --- a/lib/common/tests/rules/pcmk__evaluate_date_expression_test.c +++ b/lib/common/tests/rules/pcmk__evaluate_date_expression_test.c @@ -1,5 +1,5 @@ /* - * Copyright 2024-2025 the Pacemaker project contributors + * Copyright 2024-2026 the Pacemaker project contributors * * The version control history for this file may have further details. * @@ -52,7 +52,7 @@ assert_date_expression(const xmlNode *xml, const char *now_s, if (check_next_change) { crm_time_t *reference = crm_time_new(reference_s); - assert_int_equal(crm_time_compare(next_change, reference), 0); + assert_int_equal(pcmk__time_compare(next_change, reference), 0); crm_time_free(reference); crm_time_free(next_change); } diff --git a/lib/common/tests/rules/pcmk__unpack_duration_test.c b/lib/common/tests/rules/pcmk__unpack_duration_test.c index 2eba68e24e7..978dd8d1bab 100644 --- a/lib/common/tests/rules/pcmk__unpack_duration_test.c +++ b/lib/common/tests/rules/pcmk__unpack_duration_test.c @@ -1,5 +1,5 @@ /* - * Copyright 2024 the Pacemaker project contributors + * Copyright 2024-2026 the Pacemaker project contributors * * The version control history for this file may have further details. * @@ -99,7 +99,7 @@ all_valid(void **state) crm_time_t *reference = crm_time_new("2025-03-21 16:01:01"); assert_int_equal(pcmk__unpack_duration(duration, start, &end), pcmk_rc_ok); - assert_int_equal(crm_time_compare(end, reference), 0); + assert_int_equal(pcmk__time_compare(end, reference), 0); crm_time_free(start); crm_time_free(end); diff --git a/lib/common/tests/rules/pcmk_evaluate_rule_test.c b/lib/common/tests/rules/pcmk_evaluate_rule_test.c index 0a028076c58..f0ce9d23b49 100644 --- a/lib/common/tests/rules/pcmk_evaluate_rule_test.c +++ b/lib/common/tests/rules/pcmk_evaluate_rule_test.c @@ -1,5 +1,5 @@ /* - * Copyright 2024-2025 the Pacemaker project contributors + * Copyright 2024-2026 the Pacemaker project contributors * * The version control history for this file may have further details. * @@ -43,7 +43,7 @@ static void null_invalid(void **state) { xmlNode *xml = NULL; - crm_time_t *next_change = crm_time_new_undefined(); + crm_time_t *next_change = pcmk__assert_alloc(1, sizeof(crm_time_t)); assert_int_equal(pcmk_evaluate_rule(NULL, NULL, next_change), EINVAL); @@ -69,7 +69,7 @@ static void id_missing(void **state) { xmlNode *xml = pcmk__xml_parse(RULE_OP_MISSING_ID); - crm_time_t *next_change = crm_time_new_undefined(); + crm_time_t *next_change = pcmk__assert_alloc(1, sizeof(crm_time_t)); assert_int_equal(pcmk_evaluate_rule(xml, &rule_input, next_change), pcmk_rc_unpack_error); @@ -85,7 +85,7 @@ good_idref(void **state) { xmlNode *parent_xml = pcmk__xml_parse(RULE_IDREF_PARENT); xmlNode *rule_xml = pcmk__xe_create(parent_xml, PCMK_XE_RULE); - crm_time_t *next_change = crm_time_new_undefined(); + crm_time_t *next_change = pcmk__assert_alloc(1, sizeof(crm_time_t)); pcmk__xe_set(rule_xml, PCMK_XA_ID_REF, "r"); assert_int_equal(pcmk_evaluate_rule(rule_xml, &rule_input, next_change), @@ -100,7 +100,7 @@ bad_idref(void **state) { xmlNode *parent_xml = pcmk__xml_parse(RULE_IDREF_PARENT); xmlNode *rule_xml = pcmk__xe_create(parent_xml, PCMK_XE_RULE); - crm_time_t *next_change = crm_time_new_undefined(); + crm_time_t *next_change = pcmk__assert_alloc(1, sizeof(crm_time_t)); pcmk__xe_set(rule_xml, PCMK_XA_ID_REF, "x"); assert_int_equal(pcmk_evaluate_rule(rule_xml, &rule_input, next_change), diff --git a/lib/common/tests/xml_element/pcmk__xe_get_datetime_test.c b/lib/common/tests/xml_element/pcmk__xe_get_datetime_test.c index bad68bffbf1..34c4103abd9 100644 --- a/lib/common/tests/xml_element/pcmk__xe_get_datetime_test.c +++ b/lib/common/tests/xml_element/pcmk__xe_get_datetime_test.c @@ -1,5 +1,5 @@ /* - * Copyright 2024 the Pacemaker project contributors + * Copyright 2024-2026 the Pacemaker project contributors * * The version control history for this file may have further details. * @@ -51,7 +51,7 @@ static void nonnull_time_invalid(void **state) { xmlNode *xml = pcmk__xml_parse(REFERENCE_XML); - crm_time_t *t = crm_time_new_undefined(); + crm_time_t *t = pcmk__assert_alloc(1, sizeof(crm_time_t)); assert_int_equal(pcmk__xe_get_datetime(xml, ATTR_PRESENT, &t), EINVAL); @@ -79,7 +79,7 @@ attr_valid(void **state) crm_time_t *reference = crm_time_new(REFERENCE_ISO8601); assert_int_equal(pcmk__xe_get_datetime(xml, ATTR_PRESENT, &t), pcmk_rc_ok); - assert_int_equal(crm_time_compare(t, reference), 0); + assert_int_equal(pcmk__time_compare(t, reference), 0); crm_time_free(t); crm_time_free(reference); diff --git a/lib/common/tls.c b/lib/common/tls.c index 3ba6aa94661..1d834a59812 100644 --- a/lib/common/tls.c +++ b/lib/common/tls.c @@ -27,7 +27,7 @@ #include // QB_XS #include -#include // crm_time_free, crm_time_log_date +#include // crm_time_* #include // CRM_CHECK #include // pcmk_rc_* @@ -474,7 +474,7 @@ pcmk__tls_check_cert_expiration(gnutls_session_t session) crm_time_t *expiry_t = pcmk__copy_timet(expiry); pcmk__time_log(LOG_WARNING, "TLS certificate will expire on", - expiry_t, crm_time_log_date|crm_time_log_timeofday); + expiry_t, pcmk__time_fmt_date|pcmk__time_fmt_time); crm_time_free(expiry_t); } } diff --git a/lib/common/xml_element.c b/lib/common/xml_element.c index 8782d79dbfc..bc6a349b1e4 100644 --- a/lib/common/xml_element.c +++ b/lib/common/xml_element.c @@ -1583,7 +1583,7 @@ pcmk__xe_get_timeval(const xmlNode *xml, const char *sec_attr, // No bounds checking; see comment in pcmk__xe_get_time() // Parse seconds - rc = pcmk__xe_get_time(xml, sec_attr, &(result.tv_sec)); + rc = pcmk__xe_get_time(xml, sec_attr, &result.tv_sec); if (rc != pcmk_rc_ok) { return rc; } diff --git a/lib/fencing/st_actions.c b/lib/fencing/st_actions.c index a4273919951..7f4cb6e17fe 100644 --- a/lib/fencing/st_actions.c +++ b/lib/fencing/st_actions.c @@ -65,8 +65,8 @@ static void log_action(stonith_action_t *action, pid_t pid); static void set_result_from_svc_action(stonith_action_t *action, svc_action_t *svc_action) { - services__copy_result(svc_action, &(action->result)); - pcmk__set_result_output(&(action->result), + services__copy_result(svc_action, &action->result); + pcmk__set_result_output(&action->result, services__grab_stdout(svc_action), services__grab_stderr(svc_action)); } @@ -212,7 +212,7 @@ stonith__destroy_action(stonith_action_t *action) free(action->action); g_clear_pointer(&action->args, g_hash_table_destroy); g_clear_pointer(&action->svc_action, services_action_free); - pcmk__reset_result(&(action->result)); + pcmk__reset_result(&action->result); free(action); } } @@ -228,7 +228,7 @@ stonith__destroy_action(stonith_action_t *action) pcmk__action_result_t * stonith__action_result(stonith_action_t *action) { - return (action == NULL)? NULL : &(action->result); + return (action == NULL)? NULL : &action->result; } #define FAILURE_MAX_RETRIES 2 @@ -265,7 +265,7 @@ stonith__action_create(const char *agent, const char *action_name, action->timeout = action->remaining_timeout = timeout_sec; action->max_retries = FAILURE_MAX_RETRIES; - pcmk__set_result(&(action->result), PCMK_OCF_UNKNOWN, PCMK_EXEC_UNKNOWN, + pcmk__set_result(&action->result, PCMK_OCF_UNKNOWN, PCMK_EXEC_UNKNOWN, "Initialization bug in fencing library"); if (device_args) { @@ -527,17 +527,15 @@ stonith_action_async_done(svc_action_t *svc_action) svc_action->params = NULL; log_action(action, action->pid); - if (!pcmk__result_ok(&(action->result)) - && update_remaining_timeout(action)) { + if (!pcmk__result_ok(&action->result) + && update_remaining_timeout(action) + && (internal_stonith_action_execute(action) == pcmk_ok)) { - int rc = internal_stonith_action_execute(action); - if (rc == pcmk_ok) { - return; - } + return; } if (action->done_cb) { - action->done_cb(action->pid, &(action->result), action->userdata); + action->done_cb(action->pid, &action->result, action->userdata); } action->svc_action = NULL; // don't remove our caller @@ -556,7 +554,7 @@ stonith_action_async_forked(svc_action_t *svc_action) (action->fork_cb) (svc_action->pid, action->userdata); } - pcmk__set_result(&(action->result), PCMK_OCF_UNKNOWN, PCMK_EXEC_PENDING, + pcmk__set_result(&action->result, PCMK_OCF_UNKNOWN, PCMK_EXEC_PENDING, NULL); pcmk__trace("Child process %d performing action '%s' successfully forked", @@ -616,7 +614,7 @@ internal_stonith_action_execute(stonith_action_t * action) if ((action->action == NULL) || (action->args == NULL) || (action->agent == NULL)) { - pcmk__set_result(&(action->result), PCMK_OCF_UNKNOWN_ERROR, + pcmk__set_result(&action->result, PCMK_OCF_UNKNOWN_ERROR, PCMK_EXEC_ERROR_FATAL, "Bug in fencing library"); return -EINVAL; } @@ -641,7 +639,7 @@ internal_stonith_action_execute(stonith_action_t * action) /* keep retries from executing out of control and free previous results */ if (is_retry) { - pcmk__reset_result(&(action->result)); + pcmk__reset_result(&action->result); // @TODO This should be nonblocking via timer if mainloop is used sleep(1); } diff --git a/lib/fencing/st_output.c b/lib/fencing/st_output.c index 5e5ad1209fd..1395e3e2008 100644 --- a/lib/fencing/st_output.c +++ b/lib/fencing/st_output.c @@ -49,10 +49,10 @@ timespec_string(time_t sec, long nsec, bool show_usec) { }; return pcmk__timespec2str(&ts, - crm_time_log_date - |crm_time_log_timeofday - |crm_time_log_with_timezone - |(show_usec? crm_time_usecs : 0)); + pcmk__time_fmt_date + |pcmk__time_fmt_time + |pcmk__time_fmt_timezone + |(show_usec? pcmk__time_fmt_usecs : 0)); } /*! diff --git a/lib/lrmd/lrmd_client.c b/lib/lrmd/lrmd_client.c index ecaac78903a..65b23df8edd 100644 --- a/lib/lrmd/lrmd_client.c +++ b/lib/lrmd/lrmd_client.c @@ -1272,7 +1272,7 @@ lrmd_tls_connect(lrmd_t * lrmd, int *fd) native->sock = -1; rc = pcmk__connect_remote(native->server, native->port, 0, NULL, - &(native->sock), NULL, NULL); + &native->sock, NULL, NULL); if (rc != pcmk_rc_ok) { pcmk__warn("Pacemaker Remote connection to %s:%d failed: %s " QB_XS " rc=%d", @@ -1546,7 +1546,7 @@ lrmd_tls_connect_async(lrmd_t *lrmd, int timeout) native->sock = -1; rc = pcmk__connect_remote(native->server, native->port, timeout, &timer_id, - &(native->sock), lrmd, lrmd_tcp_connect_cb); + &native->sock, lrmd, lrmd_tcp_connect_cb); if (rc != pcmk_rc_ok) { pcmk__warn("Pacemaker Remote connection to %s:%d failed: %s " QB_XS " rc=%d", diff --git a/lib/pacemaker/pcmk_graph_consumer.c b/lib/pacemaker/pcmk_graph_consumer.c index 079ea9c64bc..69eb7652fe0 100644 --- a/lib/pacemaker/pcmk_graph_consumer.c +++ b/lib/pacemaker/pcmk_graph_consumer.c @@ -575,7 +575,7 @@ unpack_action(pcmk__graph_synapse_t *parent, xmlNode *xml_action) return NULL; } - pcmk__scan_min_int(value, &(action->id), -1); + pcmk__scan_min_int(value, &action->id, -1); action->type = pcmk__rsc_graph_action; action->xml = pcmk__xml_copy(NULL, xml_action); action->synapse = parent; @@ -583,7 +583,7 @@ unpack_action(pcmk__graph_synapse_t *parent, xmlNode *xml_action) action->params = xml2list(action->xml); value = crm_meta_value(action->params, PCMK_META_TIMEOUT); - pcmk__scan_min_int(value, &(action->timeout), 0); + pcmk__scan_min_int(value, &action->timeout, 0); /* Take PCMK_META_START_DELAY into account for the timeout of the action * timer @@ -597,7 +597,7 @@ unpack_action(pcmk__graph_synapse_t *parent, xmlNode *xml_action) } if (pcmk__uint_from_hash(action->params, CRM_META "_" PCMK_META_INTERVAL, - 0, &(action->interval_ms)) != pcmk_rc_ok) { + 0, &action->interval_ms) != pcmk_rc_ok) { action->interval_ms = 0; } @@ -629,10 +629,10 @@ unpack_synapse(pcmk__graph_t *new_graph, const xmlNode *xml_synapse) return NULL; } - pcmk__scan_min_int(pcmk__xe_id(xml_synapse), &(new_synapse->id), 0); + pcmk__scan_min_int(pcmk__xe_id(xml_synapse), &new_synapse->id, 0); value = pcmk__xe_get(xml_synapse, PCMK__XA_PRIORITY); - pcmk__scan_min_int(value, &(new_synapse->priority), 0); + pcmk__scan_min_int(value, &new_synapse->priority, 0); CRM_CHECK(new_synapse->id >= 0, free_graph_synapse((void *) new_synapse); return NULL); @@ -749,37 +749,37 @@ pcmk__unpack_graph(const xmlNode *xml_graph, const char *reference) CRM_CHECK(buf != NULL, pcmk__free_graph(new_graph); return NULL); - pcmk__scan_min_int(buf, &(new_graph->id), 1); + pcmk__scan_min_int(buf, &new_graph->id, 1); buf = pcmk__xe_get(xml_graph, PCMK_OPT_CLUSTER_DELAY); CRM_CHECK(buf != NULL, pcmk__free_graph(new_graph); return NULL); - pcmk_parse_interval_spec(buf, &(new_graph->network_delay)); + pcmk_parse_interval_spec(buf, &new_graph->network_delay); buf = pcmk__xe_get(xml_graph, PCMK_OPT_FENCING_TIMEOUT); if (buf == NULL) { new_graph->fencing_timeout = new_graph->network_delay; } else { - pcmk_parse_interval_spec(buf, &(new_graph->fencing_timeout)); + pcmk_parse_interval_spec(buf, &new_graph->fencing_timeout); } // Use 0 (dynamic limit) as default/invalid, -1 (no limit) as minimum buf = pcmk__xe_get(xml_graph, PCMK_OPT_BATCH_LIMIT); if ((buf == NULL) - || (pcmk__scan_min_int(buf, &(new_graph->batch_limit), + || (pcmk__scan_min_int(buf, &new_graph->batch_limit, -1) != pcmk_rc_ok)) { new_graph->batch_limit = 0; } buf = pcmk__xe_get(xml_graph, PCMK_OPT_MIGRATION_LIMIT); - pcmk__scan_min_int(buf, &(new_graph->migration_limit), -1); + pcmk__scan_min_int(buf, &new_graph->migration_limit, -1); new_graph->failed_stop_offset = pcmk__xe_get_copy(xml_graph, PCMK__XA_FAILED_STOP_OFFSET); new_graph->failed_start_offset = pcmk__xe_get_copy(xml_graph, PCMK__XA_FAILED_START_OFFSET); - pcmk__xe_get_time(xml_graph, "recheck-by", &(new_graph->recheck_by)); + pcmk__xe_get_time(xml_graph, "recheck-by", &new_graph->recheck_by); } // Unpack each child element diff --git a/lib/pacemaker/pcmk_output.c b/lib/pacemaker/pcmk_output.c index 69d02d9087e..7df5120c3bf 100644 --- a/lib/pacemaker/pcmk_output.c +++ b/lib/pacemaker/pcmk_output.c @@ -755,9 +755,9 @@ pacemakerd_health(pcmk__output_t *out, va_list args) if (last_updated != 0) { last_updated_s = pcmk__epoch2str(&last_updated, - crm_time_log_date - |crm_time_log_timeofday - |crm_time_log_with_timezone); + pcmk__time_fmt_date + |pcmk__time_fmt_time + |pcmk__time_fmt_timezone); } rc = out->info(out, "Status of %s: '%s' (last updated %s)", @@ -796,9 +796,9 @@ pacemakerd_health_html(pcmk__output_t *out, va_list args) if (last_updated != 0) { last_updated_s = pcmk__epoch2str(&last_updated, - crm_time_log_date - |crm_time_log_timeofday - |crm_time_log_with_timezone); + pcmk__time_fmt_date + |pcmk__time_fmt_time + |pcmk__time_fmt_timezone); } msg = pcmk__assert_asprintf("Status of %s: '%s' (last updated %s)", @@ -860,9 +860,9 @@ pacemakerd_health_xml(pcmk__output_t *out, va_list args) if (last_updated != 0) { last_updated_s = pcmk__epoch2str(&last_updated, - crm_time_log_date - |crm_time_log_timeofday - |crm_time_log_with_timezone); + pcmk__time_fmt_date + |pcmk__time_fmt_time + |pcmk__time_fmt_timezone); } pcmk__output_create_xml_node(out, PCMK_XE_PACEMAKERD, diff --git a/lib/pacemaker/pcmk_sched_colocation.c b/lib/pacemaker/pcmk_sched_colocation.c index f4a85eea2e9..1892f37b616 100644 --- a/lib/pacemaker/pcmk_sched_colocation.c +++ b/lib/pacemaker/pcmk_sched_colocation.c @@ -421,9 +421,9 @@ pcmk__new_colocation(const char *id, const char *node_attr, int score, new_con->node_attribute = pcmk__s(node_attr, CRM_ATTR_UNAME); new_con->flags = flags; - pcmk__add_this_with(&(dependent->priv->this_with_colocations), new_con, + pcmk__add_this_with(&dependent->priv->this_with_colocations, new_con, dependent); - pcmk__add_with_this(&(primary->priv->with_this_colocations), new_con, + pcmk__add_with_this(&primary->priv->with_this_colocations, new_con, primary); dependent->priv->scheduler->priv->colocation_constraints = @@ -1930,10 +1930,10 @@ pcmk__add_dependent_scores(void *data, void *user_data) "%s: Incorporating attenuated %s assignment scores due " "to colocation %s", primary->id, dependent->id, colocation->id); - dependent->priv->cmds->add_colocated_node_scores(dependent, primary, - dependent->id, - &(primary->priv->allowed_nodes), - colocation, factor, flags); + dependent->priv->cmds->add_colocated_node_scores( + dependent, primary, dependent->id, &primary->priv->allowed_nodes, + colocation, factor, flags + ); } /*! diff --git a/lib/pacemaker/pcmk_sched_location.c b/lib/pacemaker/pcmk_sched_location.c index 641f7716c92..44891c98240 100644 --- a/lib/pacemaker/pcmk_sched_location.c +++ b/lib/pacemaker/pcmk_sched_location.c @@ -362,7 +362,7 @@ unpack_rsc_location(xmlNode *xml_obj, pcmk_resource_t *rsc, location->role_filter = role; } else { - crm_time_t *next_change = crm_time_new_undefined(); + crm_time_t *next_change = pcmk__assert_alloc(1, sizeof(crm_time_t)); xmlNode *rule_xml = pcmk__xe_first_child(xml_obj, PCMK_XE_RULE, NULL, NULL); pcmk_rule_input_t rule_input = { @@ -379,7 +379,7 @@ unpack_rsc_location(xmlNode *xml_obj, pcmk_resource_t *rsc, /* If there is a point in the future when the evaluation of a rule will * change, make sure the scheduler is re-run by that time. */ - if (crm_time_is_defined(next_change)) { + if (pcmk__time_is_initialized(next_change)) { time_t t = (time_t) crm_time_get_seconds_since_epoch(next_change); pcmk__update_recheck_time(t, rsc->priv->scheduler, diff --git a/lib/pacemaker/pcmk_sched_promotable.c b/lib/pacemaker/pcmk_sched_promotable.c index d3fa33d7214..8c06d953ab3 100644 --- a/lib/pacemaker/pcmk_sched_promotable.c +++ b/lib/pacemaker/pcmk_sched_promotable.c @@ -380,10 +380,10 @@ apply_coloc_to_primary(void *data, void *user_data) colocation->id, colocation->dependent->id, colocation->primary->id, pcmk_readable_score(colocation->score)); - dependent->priv->cmds->add_colocated_node_scores(dependent, clone, - clone->id, - &(clone->priv->allowed_nodes), - colocation, factor, flags); + dependent->priv->cmds->add_colocated_node_scores( + dependent, clone, clone->id, &clone->priv->allowed_nodes, colocation, + factor, flags + ); } /*! diff --git a/lib/pacemaker/pcmk_sched_recurring.c b/lib/pacemaker/pcmk_sched_recurring.c index 956b0cdfe0c..327a040a154 100644 --- a/lib/pacemaker/pcmk_sched_recurring.c +++ b/lib/pacemaker/pcmk_sched_recurring.c @@ -669,8 +669,8 @@ pcmk__new_cancel_action(pcmk_resource_t *rsc, const char *task, cancel_op = custom_action(rsc, key, PCMK_ACTION_CANCEL, node, FALSE, rsc->priv->scheduler); - pcmk__str_update(&(cancel_op->task), PCMK_ACTION_CANCEL); - pcmk__str_update(&(cancel_op->cancel_task), task); + pcmk__str_update(&cancel_op->task, PCMK_ACTION_CANCEL); + pcmk__str_update(&cancel_op->cancel_task, task); interval_ms_s = pcmk__assert_asprintf("%u", interval_ms); pcmk__insert_meta(cancel_op, PCMK_XA_OPERATION, task); diff --git a/lib/pacemaker/pcmk_scheduler.c b/lib/pacemaker/pcmk_scheduler.c index c9cfb345faa..191a4fe2989 100644 --- a/lib/pacemaker/pcmk_scheduler.c +++ b/lib/pacemaker/pcmk_scheduler.c @@ -823,7 +823,7 @@ pcmk__init_scheduler(pcmk__output_t *out, xmlNodePtr input, const crm_time_t *da } } else { - int rc = cib__signon_query(out, NULL, &(new_scheduler->input)); + int rc = cib__signon_query(out, NULL, &new_scheduler->input); if (rc != pcmk_rc_ok) { pcmk_free_scheduler(new_scheduler); diff --git a/lib/pacemaker/pcmk_simulate.c b/lib/pacemaker/pcmk_simulate.c index 4db2d34ef3d..be5c7da5ded 100644 --- a/lib/pacemaker/pcmk_simulate.c +++ b/lib/pacemaker/pcmk_simulate.c @@ -498,7 +498,7 @@ static void set_effective_date(pcmk_scheduler_t *scheduler, bool print_original, const char *use_date) { - static const uint32_t flags = crm_time_log_date|crm_time_log_timeofday; + static const uint32_t flags = pcmk__time_fmt_date|pcmk__time_fmt_time; pcmk__output_t *out = scheduler->priv->out; time_t original_date = 0; @@ -521,7 +521,7 @@ set_effective_date(pcmk_scheduler_t *scheduler, bool print_original, scheduler->priv->now = pcmk__copy_timet(original_date); if (print_original) { - char *when = crm_time_as_string(scheduler->priv->now, flags); + char *when = pcmk__time_text(scheduler->priv->now, flags); out->info(out, "Using the original execution date of: %s", when); free(when); diff --git a/lib/pacemaker/pcmk_status.c b/lib/pacemaker/pcmk_status.c index aab4e9fe4d5..49f897b3498 100644 --- a/lib/pacemaker/pcmk_status.c +++ b/lib/pacemaker/pcmk_status.c @@ -275,7 +275,7 @@ pcmk__status(pcmk__output_t *out, cib_t *cib, if ((cib->variant == cib_native) && pcmk__is_set(show, pcmk_section_times)) { // Currently used only in the times section - pcmk__query_node_name(out, 0, &(scheduler->priv->local_node_name), 0); + pcmk__query_node_name(out, 0, &scheduler->priv->local_node_name, 0); } rc = pcmk__output_cluster_status(scheduler, stonith, cib, current_cib, diff --git a/lib/pengine/complex.c b/lib/pengine/complex.c index 9235facaa63..e2ce92c405c 100644 --- a/lib/pengine/complex.c +++ b/lib/pengine/complex.c @@ -609,7 +609,7 @@ unpack_priority(pcmk_resource_t *rsc) { const char *value = g_hash_table_lookup(rsc->priv->meta, PCMK_META_PRIORITY); - int rc = pcmk_parse_score(value, &(rsc->priv->priority), 0); + int rc = pcmk_parse_score(value, &rsc->priv->priority, 0); if (rc != pcmk_rc_ok) { pcmk__config_warn("Using default (0) for resource %s " @@ -639,7 +639,7 @@ unpack_stickiness(pcmk_resource_t *rsc) "' is deprecated and will be removed in a " "future release (just leave it unset)"); } else { - int rc = pcmk_parse_score(value, &(rsc->priv->stickiness), 0); + int rc = pcmk_parse_score(value, &rsc->priv->stickiness, 0); if (rc != pcmk_rc_ok) { pcmk__config_warn("Using default (0) for resource %s " @@ -671,7 +671,7 @@ unpack_migration_threshold(pcmk_resource_t *rsc) "future release (just leave it unset)"); rsc->priv->ban_after_failures = PCMK_SCORE_INFINITY; } else { - int rc = pcmk_parse_score(value, &(rsc->priv->ban_after_failures), + int rc = pcmk_parse_score(value, &rsc->priv->ban_after_failures, PCMK_SCORE_INFINITY); if ((rc != pcmk_rc_ok) || (rsc->priv->ban_after_failures < 0)) { @@ -910,7 +910,7 @@ pe__unpack_resource(xmlNode *xml_obj, pcmk_resource_t **rsc, value = g_hash_table_lookup(rsc_private->meta, PCMK_META_FAILURE_TIMEOUT); if (value != NULL) { - pcmk_parse_interval_spec(value, &(rsc_private->failure_expiration_ms)); + pcmk_parse_interval_spec(value, &rsc_private->failure_expiration_ms); } if (remote_node) { @@ -926,8 +926,7 @@ pe__unpack_resource(xmlNode *xml_obj, pcmk_resource_t **rsc, if (value) { /* reconnect delay works by setting failure_timeout and preventing the * connection from starting until the failure is cleared. */ - pcmk_parse_interval_spec(value, - &(rsc_private->remote_reconnect_ms)); + pcmk_parse_interval_spec(value, &rsc_private->remote_reconnect_ms); /* We want to override any default failure_timeout in use when remote * PCMK_REMOTE_RA_RECONNECT_INTERVAL is in use. @@ -937,7 +936,7 @@ pe__unpack_resource(xmlNode *xml_obj, pcmk_resource_t **rsc, } } - get_target_role(*rsc, &(rsc_private->next_role)); + get_target_role(*rsc, &rsc_private->next_role); pcmk__rsc_trace(*rsc, "%s desired next state: %s", (*rsc)->id, (rsc_private->next_role == pcmk_role_unknown)? "default" : pcmk_role_text(rsc_private->next_role)); diff --git a/lib/pengine/failcounts.c b/lib/pengine/failcounts.c index 0036f833898..780aae1b357 100644 --- a/lib/pengine/failcounts.c +++ b/lib/pengine/failcounts.c @@ -306,7 +306,7 @@ update_failcount_for_attr(void *key, void *value, void *user_data) struct failcount_data *fc_data = user_data; // If this is a matching fail count attribute, update fail count - if (regexec(&(fc_data->failcount_re), (const char *) key, 0, NULL, 0) == 0) { + if (regexec(&fc_data->failcount_re, (const char *) key, 0, NULL, 0) == 0) { int score = 0; int rc = pcmk_parse_score(value, &score, 0); @@ -326,7 +326,7 @@ update_failcount_for_attr(void *key, void *value, void *user_data) } // If this is a matching last failure attribute, update last failure - if (regexec(&(fc_data->lastfailure_re), (const char *) key, 0, NULL, + if (regexec(&fc_data->lastfailure_re, (const char *) key, 0, NULL, 0) == 0) { long long last_ll; int rc = pcmk__scan_ll(value, &last_ll, 0LL); @@ -399,8 +399,8 @@ pe_get_failcount(const pcmk_node_t *node, pcmk_resource_t *rsc, return 0); g_hash_table_foreach(node->priv->attrs, update_failcount_for_attr, &fc_data); - regfree(&(fc_data.failcount_re)); - regfree(&(fc_data.lastfailure_re)); + regfree(&fc_data.failcount_re); + regfree(&fc_data.lastfailure_re); // If failure blocks the resource, disregard any failure timeout if ((fc_data.failcount > 0) && (rsc->priv->failure_expiration_ms > 0) diff --git a/lib/pengine/pe_actions.c b/lib/pengine/pe_actions.c index 2e8d3237c62..bd9b52dc5b3 100644 --- a/lib/pengine/pe_actions.c +++ b/lib/pengine/pe_actions.c @@ -593,7 +593,7 @@ unpack_interval_origin(const char *value, const xmlNode *xml_obj, } // Get seconds since origin (negative if origin is in the future) - result = crm_time_get_seconds(now) - crm_time_get_seconds(origin); + result = pcmk__time_get_seconds(now) - pcmk__time_get_seconds(origin); crm_time_free(origin); // Calculate seconds from closest interval to now diff --git a/lib/pengine/pe_output.c b/lib/pengine/pe_output.c index b351205fc75..fe427e3e54d 100644 --- a/lib/pengine/pe_output.c +++ b/lib/pengine/pe_output.c @@ -1669,9 +1669,9 @@ failed_action_xml(pcmk__output_t *out, va_list args) { unsigned int interval_ms = 0; char *interval_ms_s = NULL; char *rc_change = pcmk__epoch2str(&epoch, - crm_time_log_date - |crm_time_log_timeofday - |crm_time_log_with_timezone); + pcmk__time_fmt_date + |pcmk__time_fmt_time + |pcmk__time_fmt_timezone); pcmk__xe_get_uint(xml_op, PCMK_META_INTERVAL, &interval_ms); interval_ms_s = pcmk__assert_asprintf("%u", interval_ms); @@ -3353,7 +3353,7 @@ ticket_default(pcmk__output_t *out, va_list args) { * crm_ticket or we were given details=true as an argument. */ if (detail_str == NULL) { - char *epoch_str = pcmk__epoch2str(&(ticket->last_granted), 0); + char *epoch_str = pcmk__epoch2str(&ticket->last_granted, 0); out->list_item(out, NULL, "%s\t%s%s last-granted=\"%s\"", ticket->id, ticket_status(ticket), diff --git a/lib/pengine/rules_compat.c b/lib/pengine/rules_compat.c index 43fce159391..434f78c1dde 100644 --- a/lib/pengine/rules_compat.c +++ b/lib/pengine/rules_compat.c @@ -96,7 +96,7 @@ pe_eval_nvpairs(xmlNode *top, const xmlNode *xml_obj, const char *set_name, } data.doc = xml_obj->doc; - map_rule_input(&(data.rule_input), rule_data); + map_rule_input(&data.rule_input, rule_data); pairs = g_list_sort_with_data(pairs, pcmk__cmp_nvpair_blocks, &data); g_list_foreach(pairs, pcmk__unpack_nvpair_block, &data); diff --git a/lib/pengine/unpack.c b/lib/pengine/unpack.c index 4ff84c0e634..41558371cda 100644 --- a/lib/pengine/unpack.c +++ b/lib/pengine/unpack.c @@ -278,7 +278,7 @@ unpack_config(xmlNode *config, pcmk_scheduler_t *scheduler) scheduler); value = pcmk__cluster_option(config_hash, PCMK_OPT_FENCING_TIMEOUT); - pcmk_parse_interval_spec(value, &(scheduler->priv->fence_timeout_ms)); + pcmk_parse_interval_spec(value, &scheduler->priv->fence_timeout_ms); pcmk__debug("Default fencing action timeout: %s", pcmk__readable_interval(scheduler->priv->fence_timeout_ms)); @@ -309,7 +309,7 @@ unpack_config(xmlNode *config, pcmk_scheduler_t *scheduler) value = pcmk__cluster_option(config_hash, PCMK_OPT_PRIORITY_FENCING_DELAY); if (value) { - unsigned int *delay_ms = &(scheduler->priv->priority_fencing_ms); + unsigned int *delay_ms = &scheduler->priv->priority_fencing_ms; pcmk_parse_interval_spec(value, delay_ms); pcmk__trace("Priority fencing delay is %s", @@ -442,7 +442,7 @@ unpack_config(xmlNode *config, pcmk_scheduler_t *scheduler) pcmk__sched_shutdown_lock); if (pcmk__is_set(scheduler->flags, pcmk__sched_shutdown_lock)) { value = pcmk__cluster_option(config_hash, PCMK_OPT_SHUTDOWN_LOCK_LIMIT); - pcmk_parse_interval_spec(value, &(scheduler->priv->shutdown_lock_ms)); + pcmk_parse_interval_spec(value, &scheduler->priv->shutdown_lock_ms); pcmk__trace("Resources will be locked to nodes that were cleanly " "shut down (locks expire after %s)", pcmk__readable_interval(scheduler->priv->shutdown_lock_ms)); @@ -452,7 +452,7 @@ unpack_config(xmlNode *config, pcmk_scheduler_t *scheduler) } value = pcmk__cluster_option(config_hash, PCMK_OPT_NODE_PENDING_TIMEOUT); - pcmk_parse_interval_spec(value, &(scheduler->priv->node_pending_ms)); + pcmk_parse_interval_spec(value, &scheduler->priv->node_pending_ms); if (scheduler->priv->node_pending_ms == 0U) { pcmk__trace("Do not fence pending nodes"); } else { @@ -2332,7 +2332,7 @@ unpack_find_resource(pcmk_scheduler_t *scheduler, const pcmk_node_t *node, const bool removed = pcmk__is_set(rsc->flags, pcmk__rsc_removed); - pcmk__str_update(&(rsc->priv->history_id), rsc_id); + pcmk__str_update(&rsc->priv->history_id, rsc_id); pcmk__rsc_debug(rsc, "Internally renamed %s on %s to %s%s", rsc_id, pcmk__node_name(node), rsc->id, (removed? " (removed)" : "")); @@ -4526,7 +4526,7 @@ static int unpack_action_result(struct action_history *history) { if ((pcmk__xe_get_int(history->xml, PCMK__XA_OP_STATUS, - &(history->execution_status)) != pcmk_rc_ok) + &history->execution_status) != pcmk_rc_ok) || (history->execution_status < PCMK_EXEC_PENDING) || (history->execution_status > PCMK_EXEC_MAX) || (history->execution_status == PCMK_EXEC_CANCELLED)) { @@ -4539,7 +4539,7 @@ unpack_action_result(struct action_history *history) return pcmk_rc_unpack_error; } if ((pcmk__xe_get_int(history->xml, PCMK__XA_RC_CODE, - &(history->exit_status)) != pcmk_rc_ok) + &history->exit_status) != pcmk_rc_ok) || (history->exit_status < 0) || (history->exit_status > CRM_EX_MAX)) { pcmk__config_err("Ignoring resource history entry %s for %s on %s " "with invalid " PCMK__XA_RC_CODE " '%s'", @@ -4799,7 +4799,7 @@ unpack_rsc_op(pcmk_resource_t *rsc, pcmk_node_t *node, xmlNode *xml_op, history.id, rsc->id, pcmk__node_name(node)); return; } - pcmk__xe_get_uint(xml_op, PCMK_META_INTERVAL, &(history.interval_ms)); + pcmk__xe_get_uint(xml_op, PCMK_META_INTERVAL, &history.interval_ms); if (!can_affect_state(&history)) { pcmk__rsc_trace(rsc, "Ignoring resource history entry %s for %s on %s " @@ -4815,7 +4815,7 @@ unpack_rsc_op(pcmk_resource_t *rsc, pcmk_node_t *node, xmlNode *xml_op, history.expected_exit_status = pe__target_rc_from_xml(xml_op); history.key = pcmk__xe_history_key(xml_op); - pcmk__xe_get_int(xml_op, PCMK__XA_CALL_ID, &(history.call_id)); + pcmk__xe_get_int(xml_op, PCMK__XA_CALL_ID, &history.call_id); pcmk__rsc_trace(rsc, "Unpacking %s (%s call %d on %s): %s (%s)", history.id, history.task, history.call_id, diff --git a/lib/pengine/utils.c b/lib/pengine/utils.c index 37cdf3807dc..bb3d5c03b0d 100644 --- a/lib/pengine/utils.c +++ b/lib/pengine/utils.c @@ -727,11 +727,11 @@ pe__unpack_dataset_nvpairs(const xmlNode *xml_obj, const char *set_name, return; } - next_change = crm_time_new_undefined(); + next_change = pcmk__assert_alloc(1, sizeof(crm_time_t)); pcmk__unpack_nvpair_blocks(xml_obj, set_name, always_first, rule_input, hash, next_change, scheduler->input->doc); - if (crm_time_is_defined(next_change)) { + if (pcmk__time_is_initialized(next_change)) { time_t recheck = (time_t) crm_time_get_seconds_since_epoch(next_change); pcmk__update_recheck_time(recheck, scheduler, "rule evaluation"); diff --git a/lib/services/services.c b/lib/services/services.c index 81bfd15f405..177830d6078 100644 --- a/lib/services/services.c +++ b/lib/services/services.c @@ -443,7 +443,7 @@ services_action_user(svc_action_t *op, const char *user) CRM_CHECK((op != NULL) && (user != NULL), return -EINVAL); - rc = pcmk__lookup_user(user, &(op->opaque->uid), &(op->opaque->gid)); + rc = pcmk__lookup_user(user, &op->opaque->uid, &op->opaque->gid); return pcmk_rc2legacy(rc); } diff --git a/lib/services/services_linux.c b/lib/services/services_linux.c index d09ea571d41..1a4c1fb10d8 100644 --- a/lib/services/services_linux.c +++ b/lib/services/services_linux.c @@ -57,13 +57,13 @@ struct sigchld_data_s { static bool sigchld_setup(struct sigchld_data_s *data) { - sigemptyset(&(data->mask)); - sigaddset(&(data->mask), SIGCHLD); + sigemptyset(&data->mask); + sigaddset(&data->mask, SIGCHLD); - sigemptyset(&(data->old_mask)); + sigemptyset(&data->old_mask); // Block SIGCHLD (saving previous set of blocked signals to restore later) - if (sigprocmask(SIG_BLOCK, &(data->mask), &(data->old_mask)) < 0) { + if (sigprocmask(SIG_BLOCK, &data->mask, &data->old_mask) < 0) { pcmk__info("Wait for child process completion failed: %s " QB_XS " source=sigprocmask", pcmk_rc_str(errno)); @@ -83,7 +83,7 @@ sigchld_open(struct sigchld_data_s *data) CRM_CHECK(data != NULL, return -1); - fd = signalfd(-1, &(data->mask), SFD_NONBLOCK); + fd = signalfd(-1, &data->mask, SFD_NONBLOCK); if (fd < 0) { pcmk__info("Wait for child process completion failed: %s " QB_XS " source=signalfd", @@ -139,8 +139,8 @@ static void sigchld_cleanup(struct sigchld_data_s *data) { // Restore the original set of blocked signals - if ((sigismember(&(data->old_mask), SIGCHLD) == 0) - && (sigprocmask(SIG_UNBLOCK, &(data->mask), NULL) < 0)) { + if ((sigismember(&data->old_mask, SIGCHLD) == 0) + && (sigprocmask(SIG_UNBLOCK, &data->mask, NULL) < 0)) { pcmk__warn("Could not clean up after child process completion: %s", pcmk_rc_str(errno)); } @@ -207,8 +207,8 @@ sigchld_setup(struct sigchld_data_s *data) // Set SIGCHLD handler data->sa.sa_handler = (sighandler_t) sigchld_handler; data->sa.sa_flags = 0; - sigemptyset(&(data->sa.sa_mask)); - if (sigaction(SIGCHLD, &(data->sa), &(data->old_sa)) < 0) { + sigemptyset(&data->sa.sa_mask); + if (sigaction(SIGCHLD, &data->sa, &data->old_sa) < 0) { pcmk__info("Wait for child process completion failed: %s " QB_XS " source=sigaction", pcmk_rc_str(errno)); @@ -252,7 +252,7 @@ static void sigchld_cleanup(struct sigchld_data_s *data) { // Restore the previous SIGCHLD handler - if (sigaction(SIGCHLD, &(data->old_sa), NULL) < 0) { + if (sigaction(SIGCHLD, &data->old_sa, NULL) < 0) { pcmk__warn("Could not clean up after child process completion: %s", pcmk_rc_str(errno)); } @@ -631,10 +631,10 @@ finish_op_output(svc_action_t *op, bool is_stderr) int fd; if (is_stderr) { - source = &(op->opaque->stderr_gsource); + source = &op->opaque->stderr_gsource; fd = op->opaque->stderr_fd; } else { - source = &(op->opaque->stdout_gsource); + source = &op->opaque->stdout_gsource; fd = op->opaque->stdout_fd; } diff --git a/lib/services/services_ocf.c b/lib/services/services_ocf.c index 85f7be9b279..fb4d4e90b09 100644 --- a/lib/services/services_ocf.c +++ b/lib/services/services_ocf.c @@ -1,5 +1,5 @@ /* - * Copyright 2012-2025 the Pacemaker project contributors + * Copyright 2012-2026 the Pacemaker project contributors * * The version control history for this file may have further details. * @@ -171,7 +171,7 @@ int services__ocf_prepare(svc_action_t *op) { if (!services__ocf_agent_exists(op->provider, op->agent, - &(op->opaque->exec))) { + &op->opaque->exec)) { return ENOENT; } diff --git a/lib/services/systemd.c b/lib/services/systemd.c index bf2d51db42e..01eeb31aad9 100644 --- a/lib/services/systemd.c +++ b/lib/services/systemd.c @@ -859,7 +859,7 @@ process_unit_method_reply(DBusMessage *reply, svc_action_t *op) if (!op->synchronous && start_stop) { // Should be set to unknown/pending already services__set_result(op, PCMK_OCF_UNKNOWN, PCMK_EXEC_PENDING, NULL); - pcmk__str_update(&(op->opaque->job_path), path); + pcmk__str_update(&op->opaque->job_path, path); } else { services__set_result(op, PCMK_OCF_OK, PCMK_EXEC_DONE, NULL); diff --git a/tools/cibsecret.c b/tools/cibsecret.c index 2a6dc783fdf..473c3563423 100644 --- a/tools/cibsecret.c +++ b/tools/cibsecret.c @@ -363,7 +363,7 @@ get_live_peers(pcmk__output_t *out) /* Get the local node name if possible. */ if (cib->variant != cib_file) { - rc = pcmk__query_node_name(out, 0, &(nd.local_node), 0); + rc = pcmk__query_node_name(out, 0, &nd.local_node, 0); if (rc != pcmk_rc_ok) { out->err(out, "Could not get local node name"); goto done; diff --git a/tools/crm_attribute.c b/tools/crm_attribute.c index 3c9b702c081..41730972e5a 100644 --- a/tools/crm_attribute.c +++ b/tools/crm_attribute.c @@ -707,12 +707,12 @@ build_arg_context(pcmk__common_args_t *args, GOptionGroup **group) { GOptionContext *context = NULL; GOptionEntry extra_prog_entries[] = { - { "quiet", 'q', 0, G_OPTION_ARG_NONE, &(args->quiet), + { "quiet", 'q', 0, G_OPTION_ARG_NONE, &args->quiet, "Print only the value on stdout", NULL }, // NOTE: resource-agents <4.2.0 (2018-10-24) uses -Q - { "quiet", 'Q', G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &(args->quiet), + { "quiet", 'Q', G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &args->quiet, NULL, NULL }, diff --git a/tools/crm_mon.c b/tools/crm_mon.c index e63c04df3e5..c45a4dfe2a4 100644 --- a/tools/crm_mon.c +++ b/tools/crm_mon.c @@ -1236,7 +1236,7 @@ build_arg_context(pcmk__common_args_t *args, GOptionGroup **group) { GOptionContext *context = NULL; GOptionEntry extra_prog_entries[] = { - { "quiet", 'Q', 0, G_OPTION_ARG_NONE, &(args->quiet), + { "quiet", 'Q', 0, G_OPTION_ARG_NONE, &args->quiet, "Be less descriptive in output.", NULL }, @@ -1656,7 +1656,7 @@ main(int argc, char **argv) && pcmk__is_set(show, pcmk_section_times)) { // Currently used only in the times section - pcmk__query_node_name(out, 0, &(scheduler->priv->local_node_name), 0); + pcmk__query_node_name(out, 0, &scheduler->priv->local_node_name, 0); } out->message(out, "crm-mon-disconnected", diff --git a/tools/crm_node.c b/tools/crm_node.c index 0d4cb92968a..497ee90eae8 100644 --- a/tools/crm_node.c +++ b/tools/crm_node.c @@ -130,7 +130,7 @@ gboolean name_cb(const char *option_name, const char *optarg, void *data, GError **error) { options.command = 'N'; - pcmk__scan_min_int(optarg, &(options.nodeid), 0); + pcmk__scan_min_int(optarg, &options.nodeid, 0); return TRUE; } @@ -764,7 +764,7 @@ build_arg_context(pcmk__common_args_t *args, GOptionGroup **group) { GOptionContext *context = NULL; GOptionEntry extra_prog_entries[] = { - { "quiet", 'Q', 0, G_OPTION_ARG_NONE, &(args->quiet), + { "quiet", 'Q', 0, G_OPTION_ARG_NONE, &args->quiet, "Be less descriptive in output.", NULL }, diff --git a/tools/crm_resource.c b/tools/crm_resource.c index c8cd7d474c4..b781fec3247 100644 --- a/tools/crm_resource.c +++ b/tools/crm_resource.c @@ -1980,7 +1980,7 @@ build_arg_context(pcmk__common_args_t *args, GOptionGroup **group) { GOptionContext *context = NULL; GOptionEntry extra_prog_entries[] = { - { "quiet", 'Q', G_OPTION_FLAG_NONE, G_OPTION_ARG_NONE, &(args->quiet), + { "quiet", 'Q', G_OPTION_FLAG_NONE, G_OPTION_ARG_NONE, &args->quiet, "Be less descriptive in output.", NULL }, { "resource", 'r', G_OPTION_FLAG_NONE, G_OPTION_ARG_STRING, &options.rsc_id, diff --git a/tools/crm_resource_ban.c b/tools/crm_resource_ban.c index e52268b4335..656cb17cf4e 100644 --- a/tools/crm_resource_ban.c +++ b/tools/crm_resource_ban.c @@ -1,5 +1,5 @@ /* - * Copyright 2004-2025 the Pacemaker project contributors + * Copyright 2004-2026 the Pacemaker project contributors * * The version control history for this file may have further details. * @@ -24,14 +24,14 @@ parse_cli_lifetime(pcmk__output_t *out, const char *move_lifetime) crm_time_t *now = NULL; crm_time_t *later = NULL; crm_time_t *duration = NULL; - const uint32_t duration_flags = crm_time_log_date|crm_time_log_timeofday; - const uint32_t time_flags = duration_flags|crm_time_log_with_timezone; + const uint32_t duration_flags = pcmk__time_fmt_date|pcmk__time_fmt_time; + const uint32_t time_flags = duration_flags|pcmk__time_fmt_timezone; if (move_lifetime == NULL) { return NULL; } - duration = crm_time_parse_duration(move_lifetime); + duration = pcmk__time_parse_duration(move_lifetime); if (duration == NULL) { out->err(out, "Invalid duration specified: %s\n" "Please refer to https://en.wikipedia.org/wiki/ISO_8601#Durations " @@ -53,7 +53,7 @@ parse_cli_lifetime(pcmk__output_t *out, const char *move_lifetime) pcmk__time_log(LOG_INFO, "now ", now, time_flags); pcmk__time_log(LOG_INFO, "later ", later, time_flags); pcmk__time_log(LOG_INFO, "duration", duration, duration_flags); - later_s = crm_time_as_string(later, time_flags); + later_s = pcmk__time_text(later, time_flags); out->info(out, "Migration will take effect until: %s", later_s); crm_time_free(duration); @@ -496,7 +496,7 @@ cli_resource_clear_all_expired(xmlNode *root, cib_t *cib_conn, const char *rsc, continue; // Treat as unexpired } - if (crm_time_compare(now, end) == 1) { + if (pcmk__time_compare(now, end) > 0) { xmlNode *fragment = NULL; xmlNode *location = NULL; diff --git a/tools/crm_simulate.c b/tools/crm_simulate.c index 5c43d535173..f57af68831b 100644 --- a/tools/crm_simulate.c +++ b/tools/crm_simulate.c @@ -475,7 +475,7 @@ build_arg_context(pcmk__common_args_t *args, GOptionGroup **group) { GOptionContext *context = NULL; GOptionEntry extra_prog_entries[] = { - { "quiet", 'Q', 0, G_OPTION_ARG_NONE, &(args->quiet), + { "quiet", 'Q', 0, G_OPTION_ARG_NONE, &args->quiet, "Display only essential output", NULL }, diff --git a/tools/crm_verify.c b/tools/crm_verify.c index b11e67f4392..7828b7ec178 100644 --- a/tools/crm_verify.c +++ b/tools/crm_verify.c @@ -91,7 +91,7 @@ build_arg_context(pcmk__common_args_t *args, GOptionGroup **group) { "\tcrm_verify --xml-file file.xml --verbose\n\n"; GOptionEntry extra_prog_entries[] = { - { "quiet", 'q', 0, G_OPTION_ARG_NONE, &(args->quiet), + { "quiet", 'q', 0, G_OPTION_ARG_NONE, &args->quiet, "Don't print verify information", NULL }, { NULL } diff --git a/tools/crmadmin.c b/tools/crmadmin.c index b1040a29230..ff1e5802644 100644 --- a/tools/crmadmin.c +++ b/tools/crmadmin.c @@ -145,7 +145,7 @@ build_arg_context(pcmk__common_args_t *args, GOptionGroup **group) { GOptionContext *context = NULL; GOptionEntry extra_prog_entries[] = { - { "quiet", 'q', 0, G_OPTION_ARG_NONE, &(args->quiet), + { "quiet", 'q', 0, G_OPTION_ARG_NONE, &args->quiet, "Display only the essential query information", NULL }, diff --git a/tools/iso8601.c b/tools/iso8601.c index 303d12ab520..fd2c27d91e7 100644 --- a/tools/iso8601.c +++ b/tools/iso8601.c @@ -55,15 +55,15 @@ modifier_cb(const char *option_name, const char *optarg, void *data, GError **error) { if (pcmk__str_any_of(option_name, "--seconds", "-s", NULL)) { - options.print_options |= crm_time_seconds; + options.print_options |= pcmk__time_fmt_seconds; } else if (pcmk__str_any_of(option_name, "--epoch", "-S", NULL)) { - options.print_options |= crm_time_epoch; + options.print_options |= pcmk__time_fmt_epoch; } else if (pcmk__str_any_of(option_name, "--local", "-L", NULL)) { - options.print_options |= crm_time_log_with_timezone; + options.print_options |= pcmk__time_fmt_timezone; } else if (pcmk__str_any_of(option_name, "--ordinal", "-O", NULL)) { - options.print_options |= crm_time_ordinal; + options.print_options |= pcmk__time_fmt_ordinal; } else if (pcmk__str_any_of(option_name, "--week", "-W", NULL)) { - options.print_options |= crm_time_weeks; + options.print_options |= pcmk__time_fmt_weeks; } return TRUE; @@ -130,8 +130,8 @@ date_default(pcmk__output_t *out, va_list args) char *date_s = NULL; - opts |= crm_time_log_date | crm_time_log_timeofday; - date_s = crm_time_as_string(date, opts); + opts |= pcmk__time_fmt_date|pcmk__time_fmt_time; + date_s = pcmk__time_text(date, opts); out->info(out, "%s: %s", prefix, date_s); @@ -149,8 +149,8 @@ date_xml(pcmk__output_t *out, va_list args) char *date_s = NULL; - opts |= crm_time_log_date | crm_time_log_timeofday; - date_s = crm_time_as_string(date, opts); + opts |= pcmk__time_fmt_date|pcmk__time_fmt_time; + date_s = pcmk__time_text(date, opts); pcmk__output_create_xml_text_node(out, PCMK_XE_DATE, date_s); free(date_s); @@ -164,7 +164,7 @@ duration_default(pcmk__output_t *out, va_list args) crm_time_t *time = va_arg(args, crm_time_t *); int opts = va_arg(args, int); - char *date_s = crm_time_as_string(time, opts | crm_time_log_duration); + char *date_s = pcmk__time_text(time, opts|pcmk__time_fmt_duration); out->info(out, "Duration: %s", date_s); @@ -179,7 +179,7 @@ duration_xml(pcmk__output_t *out, va_list args) crm_time_t *time = va_arg(args, crm_time_t *); int opts = va_arg(args, int); - char *date_s = crm_time_as_string(time, opts | crm_time_log_duration); + char *date_s = pcmk__time_text(time, opts|pcmk__time_fmt_duration); pcmk__output_create_xml_text_node(out, PCMK_XE_DURATION, date_s); free(date_s); @@ -195,8 +195,8 @@ duration_ends_default(pcmk__output_t *out, va_list args) char *date_s = NULL; - opts |= crm_time_log_date | crm_time_log_timeofday | crm_time_log_with_timezone; - date_s = crm_time_as_string(time, opts); + opts |= pcmk__time_fmt_date|pcmk__time_fmt_time|pcmk__time_fmt_timezone; + date_s = pcmk__time_text(time, opts); out->info(out, "Duration ends at: %s", date_s); @@ -213,8 +213,8 @@ duration_ends_xml(pcmk__output_t *out, va_list args) char *date_s = NULL; - opts |= crm_time_log_date | crm_time_log_timeofday | crm_time_log_with_timezone; - date_s = crm_time_as_string(time, opts); + opts |= pcmk__time_fmt_date|pcmk__time_fmt_time|pcmk__time_fmt_timezone; + date_s = pcmk__time_text(time, opts); pcmk__output_create_xml_text_node(out, PCMK_XE_DURATION_ENDS, date_s); free(date_s); @@ -232,14 +232,14 @@ period_default(pcmk__output_t *out, va_list args) char *start_s = NULL; char *end_s = NULL; - opts |= crm_time_log_date | crm_time_log_timeofday; + opts |= pcmk__time_fmt_date|pcmk__time_fmt_time; - start_s = crm_time_as_string(start, opts); + start_s = pcmk__time_text(start, opts); if (start_s == NULL) { return pcmk_rc_no_output; } - end_s = crm_time_as_string(end, opts); + end_s = pcmk__time_text(end, opts); if (end_s == NULL) { free(start_s); return pcmk_rc_no_output; @@ -263,14 +263,14 @@ period_xml(pcmk__output_t *out, va_list args) char *start_s = NULL; char *end_s = NULL; - opts |= crm_time_log_date | crm_time_log_timeofday; + opts |= pcmk__time_fmt_date|pcmk__time_fmt_time; - start_s = crm_time_as_string(start, opts); + start_s = pcmk__time_text(start, opts); if (start_s == NULL) { return pcmk_rc_no_output; } - end_s = crm_time_as_string(end, opts); + end_s = pcmk__time_text(end, opts); if (end_s == NULL) { free(start_s); return pcmk_rc_no_output; @@ -299,7 +299,7 @@ parse_period(const char *period_str, crm_time_t **start, crm_time_t **end) tzset(); if (period_str[0] == 'P') { - diff = crm_time_parse_duration(period_str); + diff = pcmk__time_parse_duration(period_str); if (diff == NULL) { goto invalid; } @@ -319,7 +319,7 @@ parse_period(const char *period_str, crm_time_t **start, crm_time_t **end) "has two durations", original); goto invalid; } - diff = crm_time_parse_duration(period_str); + diff = pcmk__time_parse_duration(period_str); if (diff == NULL) { goto invalid; } @@ -471,7 +471,7 @@ main(int argc, char **argv) } if (options.duration_s) { - duration = crm_time_parse_duration(options.duration_s); + duration = pcmk__time_parse_duration(options.duration_s); if (duration == NULL) { exit_code = CRM_EX_INVALID_PARAM; @@ -513,9 +513,10 @@ main(int argc, char **argv) out->message(out, "duration_ends", later, options.print_options); if (options.expected_s) { - char *dt_s = crm_time_as_string(later, - options.print_options | crm_time_log_date | - crm_time_log_timeofday); + char *dt_s = pcmk__time_text(later, + options.print_options + |pcmk__time_fmt_date + |pcmk__time_fmt_time); if (!pcmk__str_eq(options.expected_s, dt_s, pcmk__str_casei)) { exit_code = CRM_EX_ERROR; goto done; @@ -525,8 +526,10 @@ main(int argc, char **argv) crm_time_free(later); } else if (date_time && options.expected_s) { - char *dt_s = crm_time_as_string(date_time, - options.print_options | crm_time_log_date | crm_time_log_timeofday); + char *dt_s = pcmk__time_text(date_time, + options.print_options + |pcmk__time_fmt_date + |pcmk__time_fmt_time); if (!pcmk__str_eq(options.expected_s, dt_s, pcmk__str_casei)) { exit_code = CRM_EX_ERROR; diff --git a/tools/stonith_admin.c b/tools/stonith_admin.c index d4a60ad00eb..ef8face6f3d 100644 --- a/tools/stonith_admin.c +++ b/tools/stonith_admin.c @@ -338,7 +338,7 @@ build_arg_context(pcmk__common_args_t *args, GOptionGroup **group) { GOptionContext *context = NULL; GOptionEntry extra_prog_entries[] = { - { "quiet", 'q', 0, G_OPTION_ARG_NONE, &(args->quiet), + { "quiet", 'q', 0, G_OPTION_ARG_NONE, &args->quiet, "Be less descriptive in output.", NULL },