]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/core/timer.c
Bug #944: Deletion of unnecessary checks before a few calls of systemd functions
[thirdparty/systemd.git] / src / core / timer.c
index d427956e0cf8068b701c013f794db329f6a7457d..7027f83dfd600abbc8deae4c48e9782c5914296b 100644 (file)
@@ -27,7 +27,6 @@
 #include "dbus-timer.h"
 #include "special.h"
 #include "bus-util.h"
-#include "bus-error.h"
 
 static const UnitActiveState state_translation_table[_TIMER_STATE_MAX] = {
         [TIMER_DEAD] = UNIT_INACTIVE,
@@ -57,10 +56,7 @@ void timer_free_values(Timer *t) {
 
         while ((v = t->values)) {
                 LIST_REMOVE(value, t->values, v);
-
-                if (v->calendar_spec)
-                        calendar_spec_free(v->calendar_spec);
-
+                calendar_spec_free(v->calendar_spec);
                 free(v);
         }
 }
@@ -429,17 +425,21 @@ static void timer_enter_waiting(Timer *t, bool initial) {
                                 goto fail;
 
                         r = sd_event_source_set_enabled(t->monotonic_event_source, SD_EVENT_ONESHOT);
-                } else
+                        if (r < 0)
+                                goto fail;
+                } else {
+
                         r = sd_event_add_time(
                                         UNIT(t)->manager->event,
                                         &t->monotonic_event_source,
                                         t->wake_system ? CLOCK_BOOTTIME_ALARM : CLOCK_MONOTONIC,
                                         t->next_elapse_monotonic_or_boottime, t->accuracy_usec,
                                         timer_dispatch, t);
-                if (r < 0)
-                        goto fail;
+                        if (r < 0)
+                                goto fail;
 
-                (void) sd_event_source_set_description(t->monotonic_event_source, "timer-monotonic");
+                        (void) sd_event_source_set_description(t->monotonic_event_source, "timer-monotonic");
+                }
 
         } else if (t->monotonic_event_source) {
 
@@ -458,17 +458,20 @@ static void timer_enter_waiting(Timer *t, bool initial) {
                                 goto fail;
 
                         r = sd_event_source_set_enabled(t->realtime_event_source, SD_EVENT_ONESHOT);
-                } else
+                        if (r < 0)
+                                goto fail;
+                } else {
                         r = sd_event_add_time(
                                         UNIT(t)->manager->event,
                                         &t->realtime_event_source,
                                         t->wake_system ? CLOCK_REALTIME_ALARM : CLOCK_REALTIME,
                                         t->next_elapse_realtime, t->accuracy_usec,
                                         timer_dispatch, t);
-                if (r < 0)
-                        goto fail;
+                        if (r < 0)
+                                goto fail;
 
-                (void) sd_event_source_set_description(t->realtime_event_source, "timer-realtime");
+                        (void) sd_event_source_set_description(t->realtime_event_source, "timer-realtime");
+                }
 
         } else if (t->realtime_event_source) {