summaryrefslogtreecommitdiff
path: root/usr.sbin/ifstated/ifstated.c
diff options
context:
space:
mode:
authorMarco Pfatschbacher <mpf@cvs.openbsd.org>2006-02-01 23:23:38 +0000
committerMarco Pfatschbacher <mpf@cvs.openbsd.org>2006-02-01 23:23:38 +0000
commitbfc4a81d2a41d4c8091f44ca72e461cf36a18c7d (patch)
treeab4197b511113d86a9b986905ec5802bd41b3831 /usr.sbin/ifstated/ifstated.c
parenta5811f0fa3a5c00aaee18e2e2831de4241d08833 (diff)
Simplify expression code. Patch from markus@.
ok mcbride@
Diffstat (limited to 'usr.sbin/ifstated/ifstated.c')
-rw-r--r--usr.sbin/ifstated/ifstated.c31
1 files changed, 8 insertions, 23 deletions
diff --git a/usr.sbin/ifstated/ifstated.c b/usr.sbin/ifstated/ifstated.c
index b8057cf4a31..f85ac86f298 100644
--- a/usr.sbin/ifstated/ifstated.c
+++ b/usr.sbin/ifstated/ifstated.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ifstated.c,v 1.26 2006/02/01 23:13:09 mpf Exp $ */
+/* $OpenBSD: ifstated.c,v 1.27 2006/02/01 23:23:37 mpf Exp $ */
/*
* Copyright (c) 2004 Marco Pfatschbacher <mpf@openbsd.org>
@@ -310,10 +310,7 @@ adjust_external_expressions(struct ifsd_state *state)
TAILQ_FOREACH(expression, &external->expressions, entries) {
TAILQ_INSERT_TAIL(&expressions,
expression, eval);
- if (external->prevstatus == 0)
- expression->truth = 1;
- else
- expression->truth = 0;
+ expression->truth = !external->prevstatus;
}
adjust_expressions(&expressions, conf->maxdepth);
}
@@ -422,10 +419,7 @@ scan_ifstate_single(int ifindex, int s, struct ifsd_state *state)
struct ifsd_expression *expression;
int truth;
- if (ifstate->ifstate == s)
- truth = 1;
- else
- truth = 0;
+ truth = (ifstate->ifstate == s);
TAILQ_FOREACH(expression,
&ifstate->expressions, entries) {
@@ -481,24 +475,15 @@ adjust_expressions(struct ifsd_expression_list *expressions, int depth)
switch (expression->type) {
case IFSD_OPER_AND:
- if (expression->left->truth &&
- expression->right->truth)
- expression->truth = 1;
- else
- expression->truth = 0;
+ expression->truth = expression->left->truth &&
+ expression->right->truth;
break;
case IFSD_OPER_OR:
- if (expression->left->truth ||
- expression->right->truth)
- expression->truth = 1;
- else
- expression->truth = 0;
+ expression->truth = expression->left->truth ||
+ expression->right->truth;
break;
case IFSD_OPER_NOT:
- if (expression->right->truth)
- expression->truth = 0;
- else
- expression->truth = 1;
+ expression->truth = !expression->right->truth;
break;
default:
break;