aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2008-06-04 12:47:06 +0000
committerRoy Marples <roy@marples.name>2008-06-04 12:47:06 +0000
commite6aed12328231e3945bffc4ed07475d559ae45f4 (patch)
treeae588458b8fba6206a5d3bed5f3c7627ec6a12c7
parent83ade5b701eaff9b777649ffad8cb2562cd643ce (diff)
No need to check type twice like this.
-rw-r--r--src/librc/librc-depend.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/librc/librc-depend.c b/src/librc/librc-depend.c
index 5ceeb741..a4ac6535 100644
--- a/src/librc/librc-depend.c
+++ b/src/librc/librc-depend.c
@@ -178,10 +178,15 @@ rc_deptree_load(void)
librc_hidden_def(rc_deptree_load)
static bool
-valid_service(const char *runlevel, const char *service)
+valid_service(const char *runlevel, const char *service, const char *type)
{
- RC_SERVICE state = rc_service_state(service);
+ RC_SERVICE state;
+
+ if (strcmp(type, "ineed") == 0 ||
+ strcmp(type, "needsme") == 0)
+ return true;
+ state = rc_service_state(service);
return ((strcmp(runlevel, bootlevel) != 0 &&
rc_service_in_runlevel(service, bootlevel)) ||
rc_service_in_runlevel(service, runlevel) ||
@@ -387,18 +392,12 @@ visit_service(const RC_DEPTREE *deptree,
if (TAILQ_FIRST(provided)) {
TAILQ_FOREACH(p, provided, entries) {
di = get_depinfo(deptree, p->value);
- if (di &&
- (strcmp(type->value, "ineed") == 0 ||
- strcmp(type->value, "needsme") == 0 ||
- valid_service(runlevel, di->service)))
+ if (di && valid_service(runlevel, di->service, type->value))
visit_service(deptree, types, sorted, visited, di,
runlevel, options | RC_DEP_TRACE);
}
}
- else if (di &&
- (strcmp(type->value, "ineed") == 0 ||
- strcmp(type->value, "needsme") == 0 ||
- valid_service(runlevel, service->value)))
+ else if (di && valid_service(runlevel, service->value, type->value))
visit_service(deptree, types, sorted, visited, di,
runlevel, options | RC_DEP_TRACE);