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 <richardcochran@gmail.com>
master
Richard Cochran 2017-02-05 18:25:18 +01:00
parent 117ed5c2d0
commit 6b471d45ed
3 changed files with 8 additions and 11 deletions

View File

@ -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);

9
port.c
View File

@ -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)

4
port.h
View File

@ -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