chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
unit: get rid of various unnecessary casts
[elogind.git]
/
src
/
timer.c
diff --git
a/src/timer.c
b/src/timer.c
index e95b4d66e10e3b1262cf4da292b817ef882ee163..ead8ab92a4b0881de1120cfe78b93775f6e44e00 100644
(file)
--- a/
src/timer.c
+++ b/
src/timer.c
@@
-31,7
+31,7
@@
static const UnitActiveState state_translation_table[_TIMER_STATE_MAX] = {
[TIMER_WAITING] = UNIT_ACTIVE,
[TIMER_RUNNING] = UNIT_ACTIVE,
[TIMER_ELAPSED] = UNIT_ACTIVE,
[TIMER_WAITING] = UNIT_ACTIVE,
[TIMER_RUNNING] = UNIT_ACTIVE,
[TIMER_ELAPSED] = UNIT_ACTIVE,
- [TIMER_MAINT
AI
NANCE] = UNIT_INACTIVE
+ [TIMER_MAINT
E
NANCE] = UNIT_INACTIVE
};
static void timer_init(Unit *u) {
};
static void timer_init(Unit *u) {
@@
-41,7
+41,6
@@
static void timer_init(Unit *u) {
assert(u->meta.load_state == UNIT_STUB);
t->next_elapse = (usec_t) -1;
assert(u->meta.load_state == UNIT_STUB);
t->next_elapse = (usec_t) -1;
- t->timer_watch.type = WATCH_INVALID;
}
static void timer_done(Unit *u) {
}
static void timer_done(Unit *u) {
@@
-61,7
+60,7
@@
static void timer_done(Unit *u) {
static int timer_verify(Timer *t) {
assert(t);
static int timer_verify(Timer *t) {
assert(t);
- if (
UNIT(t)
->meta.load_state != UNIT_LOADED)
+ if (
t
->meta.load_state != UNIT_LOADED)
return 0;
if (!t->values) {
return 0;
if (!t->values) {
@@
-168,7
+167,7
@@
static void timer_enter_dead(Timer *t, bool success) {
if (!success)
t->failure = true;
if (!success)
t->failure = true;
- timer_set_state(t, t->failure ? TIMER_MAINT
AI
NANCE : TIMER_DEAD);
+ timer_set_state(t, t->failure ? TIMER_MAINT
E
NANCE : TIMER_DEAD);
}
static void timer_enter_waiting(Timer *t, bool initial) {
}
static void timer_enter_waiting(Timer *t, bool initial) {
@@
-259,7
+258,7
@@
static void timer_enter_running(Timer *t) {
int r;
assert(t);
int r;
assert(t);
- if ((r = manager_add_job(
UNIT(t)
->meta.manager, JOB_START, t->unit, JOB_REPLACE, true, NULL)) < 0)
+ if ((r = manager_add_job(
t
->meta.manager, JOB_START, t->unit, JOB_REPLACE, true, NULL)) < 0)
goto fail;
timer_set_state(t, TIMER_RUNNING);
goto fail;
timer_set_state(t, TIMER_RUNNING);
@@
-274,8
+273,12
@@
static int timer_start(Unit *u) {
Timer *t = TIMER(u);
assert(t);
Timer *t = TIMER(u);
assert(t);
- assert(t->state == TIMER_DEAD);
+ assert(t->state == TIMER_DEAD || t->state == TIMER_MAINTENANCE);
+
+ if (t->unit->meta.load_state != UNIT_LOADED)
+ return -ENOENT;
+ t->failure = false;
timer_enter_waiting(t, true);
return 0;
}
timer_enter_waiting(t, true);
return 0;
}
@@
-373,9
+376,12
@@
void timer_unit_notify(Unit *u, UnitActiveState new_state) {
if (!p)
continue;
if (!p)
continue;
+ if (p->meta.load_state != UNIT_LOADED)
+ continue;
+
t = TIMER(p);
t = TIMER(p);
- if (t->
meta.load_state != UNIT_LOADED
)
+ if (t->
unit != u
)
continue;
/* Reenable all timers that depend on unit state */
continue;
/* Reenable all timers that depend on unit state */
@@
-403,7
+409,7
@@
void timer_unit_notify(Unit *u, UnitActiveState new_state) {
break;
case TIMER_DEAD:
break;
case TIMER_DEAD:
- case TIMER_MAINT
AI
NANCE:
+ case TIMER_MAINT
E
NANCE:
;
default:
;
default:
@@
-422,7
+428,7
@@
static const char* const timer_state_table[_TIMER_STATE_MAX] = {
[TIMER_WAITING] = "waiting",
[TIMER_RUNNING] = "running",
[TIMER_ELAPSED] = "elapsed",
[TIMER_WAITING] = "waiting",
[TIMER_RUNNING] = "running",
[TIMER_ELAPSED] = "elapsed",
- [TIMER_MAINT
AINANCE] = "maintai
nance"
+ [TIMER_MAINT
ENANCE] = "mainte
nance"
};
DEFINE_STRING_TABLE_LOOKUP(timer_state, TimerState);
};
DEFINE_STRING_TABLE_LOOKUP(timer_state, TimerState);