summaryrefslogtreecommitdiffstats
path: root/lib/common/mainloop.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-03 13:39:28 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-03 13:39:28 +0000
commit924f5ea83e48277e014ebf0d19a27187cb93e2f7 (patch)
tree75920a275bba045f6d108204562c218a9a26ea15 /lib/common/mainloop.c
parentAdding upstream version 2.1.7. (diff)
downloadpacemaker-upstream.tar.xz
pacemaker-upstream.zip
Adding upstream version 2.1.8~rc1.upstream/2.1.8_rc1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'lib/common/mainloop.c')
-rw-r--r--lib/common/mainloop.c33
1 files changed, 15 insertions, 18 deletions
diff --git a/lib/common/mainloop.c b/lib/common/mainloop.c
index f971713..7626134 100644
--- a/lib/common/mainloop.c
+++ b/lib/common/mainloop.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2004-2023 the Pacemaker project contributors
+ * Copyright 2004-2024 the Pacemaker project contributors
*
* The version control history for this file may have further details.
*
@@ -191,7 +191,6 @@ mainloop_add_trigger(int priority, int (*dispatch) (gpointer user_data),
CRM_ASSERT(sizeof(crm_trigger_t) > sizeof(GSource));
source = g_source_new(&crm_trigger_funcs, sizeof(crm_trigger_t));
- CRM_ASSERT(source != NULL);
return mainloop_setup_trigger(source, priority, dispatch, userdata);
}
@@ -1256,7 +1255,7 @@ mainloop_child_add_with_flags(pid_t pid, int timeout, const char *desc, void *pr
void (*callback) (mainloop_child_t * p, pid_t pid, int core, int signo, int exitcode))
{
static bool need_init = TRUE;
- mainloop_child_t *child = calloc(1, sizeof(mainloop_child_t));
+ mainloop_child_t *child = pcmk__assert_alloc(1, sizeof(mainloop_child_t));
child->pid = pid;
child->timerid = 0;
@@ -1264,7 +1263,7 @@ mainloop_child_add_with_flags(pid_t pid, int timeout, const char *desc, void *pr
child->privatedata = privatedata;
child->callback = callback;
child->flags = flags;
- pcmk__str_update(&child->desc, desc);
+ child->desc = pcmk__str_copy(desc);
if (timeout) {
child->timerid = g_timeout_add(timeout, child_timeout_callback, child);
@@ -1368,21 +1367,19 @@ mainloop_timer_set_period(mainloop_timer_t *t, guint period_ms)
mainloop_timer_t *
mainloop_timer_add(const char *name, guint period_ms, bool repeat, GSourceFunc cb, void *userdata)
{
- mainloop_timer_t *t = calloc(1, sizeof(mainloop_timer_t));
+ mainloop_timer_t *t = pcmk__assert_alloc(1, sizeof(mainloop_timer_t));
- if(t) {
- if(name) {
- t->name = crm_strdup_printf("%s-%u-%d", name, period_ms, repeat);
- } else {
- t->name = crm_strdup_printf("%p-%u-%d", t, period_ms, repeat);
- }
- t->id = 0;
- t->period_ms = period_ms;
- t->repeat = repeat;
- t->cb = cb;
- t->userdata = userdata;
- crm_trace("Created timer %s with %p %p", t->name, userdata, t->userdata);
- }
+ if (name != NULL) {
+ t->name = crm_strdup_printf("%s-%u-%d", name, period_ms, repeat);
+ } else {
+ t->name = crm_strdup_printf("%p-%u-%d", t, period_ms, repeat);
+ }
+ t->id = 0;
+ t->period_ms = period_ms;
+ t->repeat = repeat;
+ t->cb = cb;
+ t->userdata = userdata;
+ crm_trace("Created timer %s with %p %p", t->name, userdata, t->userdata);
return t;
}