Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
2f32485
Refactor: libcrmcommon: Make pcmk__time_get_ywd() library-private
nrwahl2 May 1, 2026
d24f815
Refactor: libcrmcommon: New pcmk__time_to_unix()
nrwahl2 May 1, 2026
4b3b394
API: libcrmcommon: Deprecate crm_time_get_seconds_since_epoch()
nrwahl2 May 1, 2026
14bc12b
Refactor: various: Drop crm_time_free() internally
nrwahl2 May 1, 2026
74dc11f
API: libcrmcommon: Deprecate crm_time_free()
nrwahl2 May 1, 2026
439a4da
Low: libcrmcommon: Handle NULL argument in pcmk_copy_time()
nrwahl2 Jul 22, 2026
15fb03a
Refactor: libcrmcommon: New pcmk__time_copy()
nrwahl2 May 1, 2026
4306a19
API: libcrmcommon: Deprecate pcmk_copy_time()
nrwahl2 May 1, 2026
127355d
Refactor: libcrmcommon: New pcmk__time_add()
nrwahl2 May 1, 2026
21cf76c
API: libcrmcommon: Deprecate crm_time_add()
nrwahl2 May 1, 2026
2513d00
Refactor: libcrmcommon: New pcmk__time_subtract()
nrwahl2 May 1, 2026
ccb9560
API: libcrmcommon: Deprecate crm_time_subtract()
nrwahl2 May 1, 2026
821032e
Refactor: libcrmcommon: New pcmk__time_add_seconds()
nrwahl2 May 1, 2026
a2d4b9e
API: libcrmcommon: Deprecate crm_time_add_seconds()
nrwahl2 May 1, 2026
1fc44db
Low: libcrmcommon: Avoid overflow in crm_time_add_minutes()
nrwahl2 Jul 22, 2026
51b4dcb
API: libcrmcommon: Deprecate crm_time_add_minutes()
nrwahl2 May 1, 2026
87c0c8b
Low: libcrmcommon: Avoid overflow in crm_time_add_hours()
nrwahl2 Jul 22, 2026
32beaeb
API: libcrmcommon: Deprecate crm_time_add_hours()
nrwahl2 May 1, 2026
d65e8db
Refactor: libcrmcommon: New pcmk__time_add_days()
nrwahl2 May 1, 2026
7c0d6a3
API: libcrmcommon: Deprecate crm_time_add_days()
nrwahl2 May 1, 2026
42eeb92
Low: libcrmcommon: Avoid overflow in crm_time_add_weeks()
nrwahl2 Jul 22, 2026
edba1a2
API: libcrmcommon: Deprecate crm_time_add_weeks()
nrwahl2 May 1, 2026
700a901
API: libcrmcommon: Deprecate crm_time_add_months()
nrwahl2 May 1, 2026
cb01a78
Refactor: libcrmcommon: New pcmk__time_add_years()
nrwahl2 May 1, 2026
6fbc818
API: libcrmcommon: Deprecate crm_time_add_years()
nrwahl2 May 1, 2026
eaea3d4
Refactor: libcrmcommon: Drop unused includes from iso8601.h
nrwahl2 May 1, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion daemons/controld/controld_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ config_query_callback(xmlNode * msg, int call_id, int rc, xmlNode * output, void

g_hash_table_destroy(config_hash);
bail:
crm_time_free(now);
free(now);
}

/*!
Expand Down
2 changes: 1 addition & 1 deletion daemons/controld/controld_remote_proxy.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ remote_config_check(xmlNode *msg, int call_id, int rc, xmlNode *output,
lrmd__validate_remote_settings(lrmd, config_hash);

g_hash_table_destroy(config_hash);
crm_time_free(now);
free(now);
}

/*!
Expand Down
23 changes: 0 additions & 23 deletions include/crm/common/iso8601.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@
#ifndef PCMK__CRM_COMMON_ISO8601__H
#define PCMK__CRM_COMMON_ISO8601__H

#include <ctype.h>
#include <stdbool.h> // bool
#include <stdint.h> // uint32_t
#include <time.h>

#ifdef __cplusplus
extern "C" {
#endif
Expand Down Expand Up @@ -52,24 +47,6 @@ typedef struct crm_time_s crm_time_t;
* A timezone of 'Z' denotes UTC time
*/
crm_time_t *crm_time_new(const char *string);
void crm_time_free(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);

/* Returns a new time object */
crm_time_t *pcmk_copy_time(const crm_time_t *source);
crm_time_t *crm_time_add(const crm_time_t *dt, const crm_time_t *value);
crm_time_t *crm_time_subtract(const crm_time_t *dt, const crm_time_t *value);

/* All crm_time_add_... functions support negative values */
void crm_time_add_seconds(crm_time_t * dt, int value);
void crm_time_add_minutes(crm_time_t * dt, int value);
void crm_time_add_hours(crm_time_t * dt, int value);
void crm_time_add_days(crm_time_t * dt, int value);
void crm_time_add_weeks(crm_time_t * dt, int value);
void crm_time_add_months(crm_time_t * dt, int value);
void crm_time_add_years(crm_time_t * dt, int value);

#ifdef __cplusplus
}
Expand Down
36 changes: 36 additions & 0 deletions include/crm/common/iso8601_compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,42 @@ 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);

//! \deprecated Do not use
long long crm_time_get_seconds_since_epoch(const crm_time_t *dt);

//! \deprecated Use \c free() instead
void crm_time_free(crm_time_t *dt);

//! \deprecated Do not use
crm_time_t *pcmk_copy_time(const crm_time_t *source);

//! \deprecated Do not use
crm_time_t *crm_time_add(const crm_time_t *dt, const crm_time_t *value);

//! \deprecated Do not use
crm_time_t *crm_time_subtract(const crm_time_t *dt, const crm_time_t *value);

//! \deprecated Do not use
void crm_time_add_seconds(crm_time_t *dt, int value);

//! \deprecated Do not use
void crm_time_add_minutes(crm_time_t *dt, int value);

//! \deprecated Do not use
void crm_time_add_hours(crm_time_t *dt, int value);

//! \deprecated Do not use
void crm_time_add_days(crm_time_t *dt, int value);

//! \deprecated Do not use
void crm_time_add_weeks(crm_time_t *dt, int value);

//! \deprecated Do not use
void crm_time_add_months(crm_time_t *dt, int value);

//! \deprecated Do not use
void crm_time_add_years(crm_time_t *dt, int value);

#ifdef __cplusplus
}
#endif
Expand Down
8 changes: 6 additions & 2 deletions include/crm/common/iso8601_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,12 @@ enum pcmk__time_fmt_flags {
};

bool pcmk__time_valid_year(int year);

crm_time_t *pcmk__time_copy(const crm_time_t *source);

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);
long long pcmk__time_to_unix(const crm_time_t *dt);
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);
Expand All @@ -141,6 +143,8 @@ 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);
crm_time_t *pcmk__time_add(const crm_time_t *dt, const crm_time_t *value);
crm_time_t *pcmk__time_subtract(const crm_time_t *dt, const crm_time_t *value);

int pcmk__time_compare(const crm_time_t *a, const crm_time_t *b);

Expand Down
2 changes: 1 addition & 1 deletion lib/cib/cib_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ read_config(GHashTable *options, xmlNode *current_cib)
pcmk__unpack_nvpair_blocks(config, PCMK_XE_CLUSTER_PROPERTY_SET,
PCMK_VALUE_CIB_BOOTSTRAP_OPTIONS, &rule_input,
options, NULL, config->doc);
crm_time_free(now);
free(now);
}

static bool
Expand Down
2 changes: 1 addition & 1 deletion lib/common/alerts.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ unpack_alert_options(xmlNode *xml, pcmk__alert_t *entry,

pcmk__unpack_nvpair_blocks(xml, PCMK_XE_META_ATTRIBUTES, NULL, &rule_input,
config_hash, NULL, xml->doc);
crm_time_free(now);
free(now);

value = g_hash_table_lookup(config_hash, PCMK_META_ENABLED);
if ((value != NULL) && !pcmk__is_true(value)) {
Expand Down
13 changes: 13 additions & 0 deletions lib/common/crmcommon_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,12 @@ enum pcmk__time_component {
pcmk__time_seconds,
};

G_GNUC_INTERNAL
void pcmk__time_add_days(crm_time_t *dt, int value);

G_GNUC_INTERNAL
void pcmk__time_add_seconds(crm_time_t *dt, int value);

G_GNUC_INTERNAL
void pcmk__time_get_timeofday(const crm_time_t *dt, uint32_t *hour,
uint32_t *minute, uint32_t *second);
Expand All @@ -216,6 +222,10 @@ 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
void pcmk__time_get_ywd(const crm_time_t *dt, uint32_t *y, uint32_t *w,
uint32_t *d);

G_GNUC_INTERNAL
const char *pcmk__time_component_attr(enum pcmk__time_component component);

Expand All @@ -226,6 +236,9 @@ int pcmk__add_time_from_xml(crm_time_t *t, enum pcmk__time_component component,
G_GNUC_INTERNAL
void pcmk__set_time_if_earlier(crm_time_t *target, const crm_time_t *source);

G_GNUC_INTERNAL
void pcmk__time_add_years(crm_time_t *dt, int value);


/*
* IPC
Expand Down
2 changes: 1 addition & 1 deletion lib/common/fuzzers/iso8601_fuzzer.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
now = pcmk__copy_timet(tv.tv_sec);
result = pcmk__time_format_hr(ns, now,
(int) (tv.tv_nsec / QB_TIME_NS_IN_USEC));
crm_time_free(now);
free(now);
free(result);

free(ns);
Expand Down
Loading