From 6b471d45edfdfa835a9115ce4be96d92f100e2ac Mon Sep 17 00:00:00 2001 From: Richard Cochran Date: Sun, 5 Feb 2017 18:25:18 +0100 Subject: [PATCH] port: Change port_dispatch() into a void function. This global function used to return an error code, but now it always returns zero. This patch converts the function signature to return void and simplifies the main clock loop by removing the useless test. Signed-off-by: Richard Cochran --- clock.c | 6 +++--- port.c | 9 ++++----- port.h | 4 +--- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/clock.c b/clock.c index a6a1a1a..f027305 100644 --- a/clock.c +++ b/clock.c @@ -1463,7 +1463,7 @@ struct PortIdentity clock_parent_identity(struct clock *c) int clock_poll(struct clock *c) { - int cnt, err, i, sde = 0; + int cnt, i, sde = 0; enum fsm_event event; struct pollfd *cur; struct port *p; @@ -1490,14 +1490,14 @@ int clock_poll(struct clock *c) cur++; LIST_FOREACH(p, &c->ports, list) { /* Let the ports handle their events. */ - for (i = err = 0; i < N_POLLFD && !err; i++) { + for (i = 0; i < N_POLLFD; i++) { if (cur[i].revents & (POLLIN|POLLPRI)) { event = port_event(p, i); if (EV_STATE_DECISION_EVENT == event) sde = 1; if (EV_ANNOUNCE_RECEIPT_TIMEOUT_EXPIRES == event) sde = 1; - err = port_dispatch(p, event, 0); + port_dispatch(p, event, 0); /* Clear any fault after a little while. */ if (PS_FAULTY == port_state(p)) { clock_fault_timeout(p, 1); diff --git a/port.c b/port.c index 5f1646b..0f99b1b 100644 --- a/port.c +++ b/port.c @@ -2143,7 +2143,7 @@ static void port_p2p_transition(struct port *p, enum port_state next) }; } -int port_dispatch(struct port *p, enum fsm_event event, int mdiff) +void port_dispatch(struct port *p, enum fsm_event event, int mdiff) { enum port_state next; @@ -2180,7 +2180,7 @@ int port_dispatch(struct port *p, enum fsm_event event, int mdiff) } if (next == p->state) - return 0; + return; port_show_transition(p, next, event); @@ -2196,12 +2196,11 @@ int port_dispatch(struct port *p, enum fsm_event event, int mdiff) if (p->jbod && next == PS_UNCALIBRATED) { if (clock_switch_phc(p->clock, p->phc_index)) { p->last_fault_type = FT_SWITCH_PHC; - return port_dispatch(p, EV_FAULT_DETECTED, 0); + port_dispatch(p, EV_FAULT_DETECTED, 0); + return; } clock_sync_interval(p->clock, p->log_sync_interval); } - - return 0; } enum fsm_event port_event(struct port *p, int fd_index) diff --git a/port.h b/port.h index d2e0865..b00bc64 100644 --- a/port.h +++ b/port.h @@ -69,10 +69,8 @@ struct foreign_clock *port_compute_best(struct port *port); * @param port A pointer previously obtained via port_open(). * @param event One of the @a fsm_event codes. * @param mdiff Whether a new master has been selected. - * @return Zero if the port's file descriptor array is still valid, - * and non-zero if it has become invalid. */ -int port_dispatch(struct port *p, enum fsm_event event, int mdiff); +void port_dispatch(struct port *p, enum fsm_event event, int mdiff); /** * Generates state machine events based on activity on a port's file