netdb/getaddrinfo: fix the compile warning
netdb/lib_getaddrinfo.c: In function ‘alloc_ai’: netdb/lib_getaddrinfo.c:80:9: warning: ‘strncpy’ specified bound 108 equals destination size [-Wstringop-truncation] 80 | strncpy(ai->sa.sun.sun_path, addr, sizeof(ai->sa.sun.sun_path)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ netdb/lib_getaddrinfo.c: In function ‘alloc_ai’: netdb/lib_getaddrinfo.c:103:9: warning: ‘strncpy’ specified bound 16 equals destination size [-Wstringop-truncation] 103 | strncpy(ai->sa.srp.rp_cpu, addr, sizeof(ai->sa.srp.rp_cpu)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: chao.an <anchao@xiaomi.com>
This commit is contained in:
parent
6472a698b6
commit
0f7ccf0c08
@ -77,7 +77,7 @@ FAR static struct ai_s *alloc_ai(int family, int socktype, int protocol,
|
||||
case AF_LOCAL:
|
||||
ai->ai.ai_addrlen = sizeof(struct sockaddr_un);
|
||||
ai->sa.sun.sun_family = AF_LOCAL;
|
||||
strncpy(ai->sa.sun.sun_path, addr, sizeof(ai->sa.sun.sun_path));
|
||||
strlcpy(ai->sa.sun.sun_path, addr, sizeof(ai->sa.sun.sun_path));
|
||||
break;
|
||||
#endif
|
||||
#ifdef CONFIG_NET_IPv4
|
||||
@ -100,7 +100,7 @@ FAR static struct ai_s *alloc_ai(int family, int socktype, int protocol,
|
||||
case AF_RPMSG:
|
||||
ai->ai.ai_addrlen = sizeof(struct sockaddr_rpmsg);
|
||||
ai->sa.srp.rp_family = AF_RPMSG;
|
||||
strncpy(ai->sa.srp.rp_cpu, addr, sizeof(ai->sa.srp.rp_cpu));
|
||||
strlcpy(ai->sa.srp.rp_cpu, addr, sizeof(ai->sa.srp.rp_cpu));
|
||||
snprintf(ai->sa.srp.rp_name, sizeof(ai->sa.srp.rp_name), "%d", port);
|
||||
break;
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user