Re: [Linuxptp-devel] [RFC v2 4/5] Add ignore_source_id config option.
PTP IEEE 1588 stack for Linux
Brought to you by:
rcochran
From: Richard C. <ric...@gm...> - 2018-08-18 04:11:58
|
On Thu, Aug 16, 2018 at 10:42:14AM -0700, Vedang Patel wrote: > +static int check_source_identity(struct port *p, struct ptp_message *m) > +{ > + struct PortIdentity master; > + > + if (!p->ignore_source_id) { > + master = clock_parent_identity(p->clock); > + if (!pid_eq(&master, &m->header.sourcePortIdentity)) { > + return -1; > + } > + } > + return 0; > +} I prefer an "early out" pattern, like: if (p->ignore_source_id) { return 0; } master = clock_parent_identity(p->clock); if (!pid_eq(&master, &m->header.sourcePortIdentity)) { return -1; } return 0; or even: if (p->ignore_source_id) { return 0; } master = clock_parent_identity(p->clock); return pid_eq(&master, &m->header.sourcePortIdentity) ? 0 : -1; Thanks, Richard |