summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 80a28a9)
raw | patch | inline | side by side (parent: 80a28a9)
author | Richard Cochran <richardcochran@gmail.com> | |
Tue, 3 Jan 2017 19:55:42 +0000 (20:55 +0100) | ||
committer | Richard Cochran <richardcochran@gmail.com> | |
Sun, 8 Jan 2017 20:34:53 +0000 (21:34 +0100) |
The code that decides whether a fault qualifies for ASAP treatment is
a tangle of logical operators. This patch replaces the open coded
logic with a helper function whose name makes the intent clear. This
is a cosmetic change only.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
a tangle of logical operators. This patch replaces the open coded
logic with a helper function whose name makes the intent clear. This
is a cosmetic change only.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
port.c | patch | blob | history |
index 6c9aa72f13b0eb9e8c569ad0960fa45499c1bfcc..02dbabbe34156fc6d1f85c20fe332232b35d4570 100644 (file)
--- a/port.c
+++ b/port.c
out->receiver = p->portIdentity;
}
+static int clear_fault_asap(struct fault_interval *faint)
+{
+ switch (faint->type) {
+ case FTMO_LINEAR_SECONDS:
+ return faint->val == 0 ? 1 : 0;
+ case FTMO_LOG2_SECONDS:
+ return faint->val == FRI_ASAP ? 1 : 0;
+ case FTMO_CNT:
+ return 0;
+ }
+ return 0;
+}
+
static int msg_current(struct ptp_message *m, struct timespec now)
{
int64_t t1, t2, tmo;
next = p->state_machine(p->state, event, mdiff);
fault_interval(p, last_fault_type(p), &i);
- if ((i.val == FRI_ASAP && i.type == FTMO_LOG2_SECONDS) ||
- (i.val == 0 && i.type == FTMO_LINEAR_SECONDS))
+ if (clear_fault_asap(&i)) {
fri_asap = 1;
+ }
if (PS_INITIALIZING == next || (PS_FAULTY == next && fri_asap)) {
/*
* This is a special case. Since we initialize the