Skip to content

Deprecate crm_time_free() through crm_time_add_years()#4153

Open
nrwahl2 wants to merge 26 commits into
ClusterLabs:mainfrom
nrwahl2:nrwahl2-time_first
Open

Deprecate crm_time_free() through crm_time_add_years()#4153
nrwahl2 wants to merge 26 commits into
ClusterLabs:mainfrom
nrwahl2:nrwahl2-time_first

Conversation

@nrwahl2

@nrwahl2 nrwahl2 commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

This is the next batch from #4097.

nrwahl2 added 26 commits July 22, 2026 11:16
Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
To replace crm_time_get_seconds_since_epoch(). The name
"pcmk__time_to_unix()" is chosen in order to align with
g_date_time_to_unix(), which we plan to adopt eventually.

During development, I used an assertion to validate that the new
epoch_seconds calculation matches the old EPOCH_SECONDS constant.

Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
External callers have no need to inspect a crm_time_t object. Pacemaker
should not be used for general-purpose date/time manipulation.

Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
It's equivalent to free(). There are no dynamically allocated fields
within crm_time_t.

Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
Use free() instead.

Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
Previously it would dereference a NULL argument.

Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
To replace pcmk_copy_time().

Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
External callers have no need to copy a crm_time_t object. Pacemaker
should not be used for general-purpose date/time manipulation.

Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
To replace crm_time_add().

Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
External callers have no need to add to a crm_time_t object. Pacemaker
should not be used for general-purpose date/time manipulation.

Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
To replace crm_time_subtract().

Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
External callers have no need to subtract from a crm_time_t object.
Pacemaker should not be used for general-purpose date/time manipulation.

Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
To replace crm_time_add_seconds().

Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
External callers have no need to add seconds to a crm_time_t object.
Pacemaker should not be used for general-purpose date/time manipulation.

Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
Previously, the (value * SECONDS_IN_MINUTE) computation could overflow.

This is not the most efficient implementation; we could avoid the for
loops in the common case where the multiplication does not overflow.
However, that seems to me like premature optimization. Simplicity and
readability seem more important than here.

Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
External callers have no need to add minutes to a crm_time_t object.
Pacemaker should not be used for general-purpose date/time manipulation.

Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
Previously, the (value * SECONDS_IN_HOUR) computation could overflow.

This is not the most efficient implementation; we could avoid the for
loops in the common case where the multiplication does not overflow.
However, that seems to me like premature optimization. Simplicity and
readability seem more important than here.

Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
External callers have no need to add hours to a crm_time_t object.
Pacemaker should not be used for general-purpose date/time manipulation.

Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
To replace crm_time_add_days().

Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
External callers have no need to add days to a crm_time_t object.
Pacemaker should not be used for general-purpose date/time manipulation.

Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
Previously, the (value * 7) computation could overflow.

This is not the most efficient implementation; we could avoid the for
loops in the common case where the multiplication does not overflow.
However, that seems to me like premature optimization. Simplicity and
readability seem more important than here.

Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
External callers have no need to add weeks to a crm_time_t object.
Pacemaker should not be used for general-purpose date/time manipulation.

Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
External callers have no need to add months to a crm_time_t object.
Pacemaker should not be used for general-purpose date/time manipulation.

Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
To replace crm_time_add_years().

Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
External callers have no need to add years to a crm_time_t object.
Pacemaker should not be used for general-purpose date/time manipulation.

Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
@nrwahl2
nrwahl2 requested a review from clumens July 22, 2026 22:54
@nrwahl2 nrwahl2 added the needs attention PRs that someone needs to look at label Jul 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs attention PRs that someone needs to look at

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant