port: Add condition to check fc.

If foreign clock is NULL, both the clocks are obviously not equal. So,
return 0 in that case.

The above condition (fc == NULL) is not currently encountered. It will
be encoutered in the next few patches which implement static roles for
master and slave.

Signed-off-by: Vedang Patel <vedang.patel@intel.com>
master
Vedang Patel 2018-10-03 09:41:47 -07:00 committed by Richard Cochran
parent 78a720f2b3
commit 4910055bd7
1 changed files with 5 additions and 0 deletions

5
port.c
View File

@ -144,6 +144,11 @@ static int msg_current(struct ptp_message *m, struct timespec now)
static int msg_source_equal(struct ptp_message *m1, struct foreign_clock *fc)
{
struct PortIdentity *id1, *id2;
if (!fc) {
return 0;
}
id1 = &m1->header.sourcePortIdentity;
id2 = &fc->dataset.sender;
return 0 == memcmp(id1, id2, sizeof(*id1));