mirror of
https://github.com/espressif/openthread.git
synced 2026-08-20 09:29:51 +00:00
[posix] avoid compiler warning on use of strncpy (#6653)
This commit is contained in:
@@ -258,7 +258,9 @@ bool InfraNetif::IsRunning(void) const
|
||||
VerifyOrDie(sock != -1, OT_EXIT_ERROR_ERRNO);
|
||||
|
||||
memset(&ifReq, 0, sizeof(ifReq));
|
||||
strncpy(ifReq.ifr_name, mInfraIfName, sizeof(ifReq.ifr_name));
|
||||
static_assert(sizeof(ifReq.ifr_name) >= sizeof(mInfraIfName), "mInfraIfName is not of appropriate size.");
|
||||
strcpy(ifReq.ifr_name, mInfraIfName);
|
||||
|
||||
VerifyOrDie(ioctl(sock, SIOCGIFFLAGS, &ifReq) != -1, OT_EXIT_ERROR_ERRNO);
|
||||
|
||||
close(sock);
|
||||
@@ -274,7 +276,7 @@ void InfraNetif::Init(otInstance *aInstance, const char *aIfName)
|
||||
VerifyOrExit(aIfName != nullptr);
|
||||
|
||||
VerifyOrDie(strnlen(aIfName, sizeof(mInfraIfName)) <= sizeof(mInfraIfName) - 1, OT_EXIT_INVALID_ARGUMENTS);
|
||||
strncpy(mInfraIfName, aIfName, sizeof(mInfraIfName));
|
||||
strcpy(mInfraIfName, aIfName);
|
||||
|
||||
// Initializes the infra interface.
|
||||
ifIndex = if_nametoindex(aIfName);
|
||||
|
||||
Reference in New Issue
Block a user