From 20d08fae4d5b4145971395fd3203ea207a3db111 Mon Sep 17 00:00:00 2001 From: David Cemin Date: Tue, 29 Mar 2016 10:35:29 -0400 Subject: [Codereview] Fixing memcpy size In two different places the wrong size of memory was being used on a memcpy / memset. Now it uses the size of the pointer instead of a fixed number. --- daemons/gptp/common/ieee1588port.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/daemons/gptp/common/ieee1588port.cpp b/daemons/gptp/common/ieee1588port.cpp index de79e145..c66e849f 100644 --- a/daemons/gptp/common/ieee1588port.cpp +++ b/daemons/gptp/common/ieee1588port.cpp @@ -145,7 +145,7 @@ IEEE1588Port::IEEE1588Port pdelay_count = 0; sync_count = 0; - bzero(link_delay, 4); + memset(link_delay, 0, sizeof(link_delay)); } void IEEE1588Port::timestamper_init(void) @@ -171,7 +171,7 @@ bool IEEE1588Port::init_port(int delay[4]) this->net_iface = net_iface; this->net_iface->getLinkLayerAddress(&local_addr); clock->setClockIdentity(&local_addr); - memcpy(this->link_delay, delay, 4); + memcpy(this->link_delay, delay, sizeof(this->link_delay)); this->timestamper_init(); -- cgit v1.2.1