[posix] fix memcpy compiler warning false positive (#6840)

In the issue, compiler complained we were copying 16 bytes to a
location of 12 bytes. This was because in the check, the compiler
thought we are going to copy data to a nlmsghdr which is 12 bytes. The
reality is that we're copying data to a place behind nlmsghdr in req
struct.
This commit is contained in:
whd
2021-07-22 09:00:06 -07:00
committed by GitHub
parent 01561e72b9
commit 681cfba45e
+2 -2
View File
@@ -578,7 +578,7 @@ static otError AddExternalRoute(const otIp6Prefix &aPrefix)
otIp6AddressToString(&aPrefix.mPrefix, addrBuf, OT_IP6_ADDRESS_STRING_SIZE);
inet_pton(AF_INET6, addrBuf, data);
AddRtAttr(&req.header, sizeof(req), RTA_DST, data, sizeof(data));
AddRtAttr(reinterpret_cast<nlmsghdr *>(&req), sizeof(req), RTA_DST, data, sizeof(data));
AddRtAttrUint32(&req.header, sizeof(req), RTA_PRIORITY, kExternalRoutePriority);
AddRtAttrUint32(&req.header, sizeof(req), RTA_OIF, netifIdx);
@@ -627,7 +627,7 @@ static otError DeleteExternalRoute(const otIp6Prefix &aPrefix)
otIp6AddressToString(&aPrefix.mPrefix, addrBuf, OT_IP6_ADDRESS_STRING_SIZE);
inet_pton(AF_INET6, addrBuf, data);
AddRtAttr(&req.header, sizeof(req), RTA_DST, data, sizeof(data));
AddRtAttr(reinterpret_cast<nlmsghdr *>(&req), sizeof(req), RTA_DST, data, sizeof(data));
AddRtAttrUint32(&req.header, sizeof(req), RTA_OIF, netifIdx);
if (send(sNetlinkFd, &req, sizeof(req), 0) < 0)