diff options
author | Christian Pointner <equinox@anytun.org> | 2012-09-25 11:45:31 +0000 |
---|---|---|
committer | Christian Pointner <equinox@anytun.org> | 2012-09-25 11:45:31 +0000 |
commit | 4dda2b162fdab27197f371bb85842da581aee834 (patch) | |
tree | f0b10a52e541160c1739444923066c83e1c491ff /src/udp.c | |
parent | configure script cleanup (diff) |
-Wall cleanup
Diffstat (limited to 'src/udp.c')
-rw-r--r-- | src/udp.c | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -33,6 +33,9 @@ * along with uAnytun. If not, see <http://www.gnu.org/licenses/>. */ +#define _GNU_SOURCE +#include <stdio.h> + #include "datatypes.h" #include "udp.h" @@ -240,7 +243,6 @@ void udp_close(udp_t* sock) char* udp_endpoint_to_string(udp_endpoint_t e) { - size_t addrstr_len = 0; char addrstr[INET6_ADDRSTRLEN + 1], portstr[6], *ret; char addrport_sep = ':'; @@ -249,12 +251,13 @@ char* udp_endpoint_to_string(udp_endpoint_t e) case AF_INET: addrport_sep = ':'; break; case AF_INET6: addrport_sep = '.'; break; case AF_UNSPEC: return NULL; - default: asprintf(&ret, "unknown address type"); return ret; + default: return strdup("unknown address type"); } int errcode = getnameinfo((struct sockaddr *)&(e.addr_), e.len_, addrstr, sizeof(addrstr), portstr, sizeof(portstr), NI_NUMERICHOST | NI_NUMERICSERV); if (errcode != 0) return NULL; - asprintf(&ret, "%s%c%s", addrstr, addrport_sep ,portstr); + int len = asprintf(&ret, "%s%c%s", addrstr, addrport_sep ,portstr); + if(len == -1) return NULL; return ret; } |