]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: timer_enter_waiting(): refactor `base` local variable
authorAlan Jenkins <alan.christopher.jenkins@gmail.com>
Wed, 28 Feb 2018 15:07:30 +0000 (15:07 +0000)
committerAlan Jenkins <alan.christopher.jenkins@gmail.com>
Wed, 28 Feb 2018 15:07:30 +0000 (15:07 +0000)
We have two variables `b` and `base`.  `b` is declared within limited
scope; `base` is declared at the top of the function.  However `base`
is actually only used within a scope which is exclusive of `b`.  Clarify
by moving `base` inside the limited scope as well.

(Also `base` doesn't need initializing any more than `b` does.  The
declaration of `base` is now immediately followed by a case analysis of
`v->base`, which serves almost exclusively to determine the value of
`base`).

src/core/timer.c

index 133cbb974de8dfebeff9988b6a7848d26b47efdc..1770c593f81f1dcf36884cd2c04f1813bbd00f2d 100644 (file)
@@ -354,7 +354,6 @@ static void timer_enter_waiting(Timer *t, bool initial) {
         bool found_monotonic = false, found_realtime = false;
         bool leave_around = false;
         triple_timestamp ts;
-        usec_t base = 0;
         TimerValue *v;
         Unit *trigger;
         int r;
@@ -372,7 +371,6 @@ static void timer_enter_waiting(Timer *t, bool initial) {
         t->next_elapse_monotonic_or_boottime = t->next_elapse_realtime = 0;
 
         LIST_FOREACH(value, v, t->values) {
-
                 if (v->disabled)
                         continue;
 
@@ -397,7 +395,8 @@ static void timer_enter_waiting(Timer *t, bool initial) {
 
                         found_realtime = true;
 
-                } else  {
+                } else {
+                        usec_t base;
 
                         switch (v->base) {