Mercurial > dovecot > core-2.2
comparison src/lib/net.c @ 16666:58be84a381e5
net_ip2addr() changed to return "" instead of NULL on failure.
Pretty much everything in the code assumed that it would never fail, which
it normally doesn't except if the ip_addr was created for UNIX sockets.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Tue, 06 Aug 2013 14:53:23 +0300 |
parents | dc60e46f0cb5 |
children | 07cc79e0041d |
comparison
equal
deleted
inserted
replaced
16665:7057d4ad8891 | 16666:58be84a381e5 |
---|---|
868 #ifdef HAVE_IPV6 | 868 #ifdef HAVE_IPV6 |
869 char addr[MAX_IP_LEN+1]; | 869 char addr[MAX_IP_LEN+1]; |
870 | 870 |
871 addr[MAX_IP_LEN] = '\0'; | 871 addr[MAX_IP_LEN] = '\0'; |
872 if (inet_ntop(ip->family, &ip->u.ip6, addr, MAX_IP_LEN) == NULL) | 872 if (inet_ntop(ip->family, &ip->u.ip6, addr, MAX_IP_LEN) == NULL) |
873 return NULL; | 873 return ""; |
874 | 874 |
875 return t_strdup(addr); | 875 return t_strdup(addr); |
876 #else | 876 #else |
877 unsigned long ip4; | 877 unsigned long ip4; |
878 | 878 |
879 if (ip->family != AF_INET) | 879 if (ip->family != AF_INET) |
880 return NULL; | 880 return ""; |
881 | 881 |
882 ip4 = ntohl(ip->u.ip4.s_addr); | 882 ip4 = ntohl(ip->u.ip4.s_addr); |
883 return t_strdup_printf("%lu.%lu.%lu.%lu", | 883 return t_strdup_printf("%lu.%lu.%lu.%lu", |
884 (ip4 & 0xff000000UL) >> 24, | 884 (ip4 & 0xff000000UL) >> 24, |
885 (ip4 & 0x00ff0000) >> 16, | 885 (ip4 & 0x00ff0000) >> 16, |