os: fix Mac test error
This commit is contained in:
parent
00a9491a97
commit
91b35a0b62
|
@ -167,7 +167,7 @@ uint32_t ip2uint(const char *const ip_addr);
|
|||
void taosIgnSIGPIPE();
|
||||
void taosSetMaskSIGPIPE();
|
||||
uint32_t taosInetAddr(const char *ipAddr);
|
||||
const char *taosInetNtoa(struct in_addr ipInt);
|
||||
const char *taosInetNtoa(struct in_addr ipInt, char *dstStr, int32_t len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ void syncUtilU642Addr(uint64_t u64, char* host, size_t len, uint16_t* port) {
|
|||
|
||||
struct in_addr addr;
|
||||
addr.s_addr = hostU32;
|
||||
snprintf(host, len, "%s", taosInetNtoa(addr));
|
||||
taosInetNtoa(addr, host, len);
|
||||
*port = (uint16_t)((u64 & 0x00000000FFFF0000) >> 16);
|
||||
}
|
||||
|
||||
|
|
|
@ -312,10 +312,8 @@ uint32_t taosInetAddr(const char *ipAddr) {
|
|||
return inet_addr(ipAddr);
|
||||
#endif
|
||||
}
|
||||
const char *taosInetNtoa(struct in_addr ipInt) {
|
||||
// not thread safe, only for debug usage while print log
|
||||
char tmpDstStr[16];
|
||||
return inet_ntop(AF_INET, &ipInt, tmpDstStr, INET6_ADDRSTRLEN);
|
||||
const char *taosInetNtoa(struct in_addr ipInt, char *dstStr, int32_t len) {
|
||||
return inet_ntop(AF_INET, &ipInt, dstStr, len);
|
||||
}
|
||||
|
||||
#ifndef SIGPIPE
|
||||
|
@ -666,7 +664,7 @@ int taosGetLocalIp(const char *eth, char *ip) {
|
|||
return -1;
|
||||
}
|
||||
memcpy(&sin, &ifr.ifr_addr, sizeof(sin));
|
||||
snprintf(ip, 64, "%s", taosInetNtoa(sin.sin_addr));
|
||||
taosInetNtoa(sin.sin_addr, ip, 64);
|
||||
taosCloseSocketNoCheck1(fd);
|
||||
#endif
|
||||
return 0;
|
||||
|
|
Loading…
Reference in New Issue