From 821798da9d7b80bf4d683c6a48ad05b14e541cc4 Mon Sep 17 00:00:00 2001 From: Jacob Keller Date: Mon, 7 May 2012 12:50:36 -0700 Subject: [PATCH] ptp4l: throw a fault for other port event failures this patch makes sure every function is checked for a negative return value and ensures that a fault is detected when these fail -v2- * Fixed only check the ones with return value -v3- * Modified the delay_req functions to return 0 on nonfault cases Signed-off-by: Jacob Keller --- port.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/port.c b/port.c index 4fe32d0..ebcc7bb 100644 --- a/port.c +++ b/port.c @@ -756,11 +756,11 @@ static int process_delay_req(struct port *p, struct ptp_message *m) int cnt, err = 0, pdulen; if (p->state != PS_MASTER && p->state != PS_GRAND_MASTER) - return -1; + return 0; if (p->delayMechanism == DM_P2P) { pr_warning("port %hu: delay request on P2P port", portnum(p)); - return -1; + return 0; } msg = msg_allocate(); @@ -879,7 +879,7 @@ static int process_pdelay_req(struct port *p, struct ptp_message *m) if (p->delayMechanism == DM_E2E) { pr_warning("port %hu: pdelay_req on E2E port", portnum(p)); - return -1; + return 0; } if (p->delayMechanism == DM_AUTO) { pr_info("port %hu: peer detected, switch to P2P", portnum(p)); @@ -1294,10 +1294,12 @@ enum fsm_event port_event(struct port *p, int fd_index) process_sync(p, msg); break; case DELAY_REQ: - process_delay_req(p, msg); + if (process_delay_req(p, msg)) + event = EV_FAULT_DETECTED; break; case PDELAY_REQ: - process_pdelay_req(p, msg); + if (process_pdelay_req(p, msg)) + event = EV_FAULT_DETECTED; break; case PDELAY_RESP: if (process_pdelay_resp(p, msg))