From a8478fc8d3ee5ca8ad6264b18ca2896298c33a65 Mon Sep 17 00:00:00 2001 From: Marc Hoersken Date: Tue, 26 Jun 2012 07:27:02 +0200 Subject: sockaddr.h: Fixed dereferencing pointer breakin strict-aliasing Fixed warning: dereferencing pointer does break strict-aliasing rules by using a union inside the struct Curl_sockaddr_storage declaration. --- lib/sockaddr.h | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'lib/sockaddr.h') diff --git a/lib/sockaddr.h b/lib/sockaddr.h index c69411b52..440eb0a97 100644 --- a/lib/sockaddr.h +++ b/lib/sockaddr.h @@ -24,14 +24,19 @@ #include "setup.h" -#ifdef HAVE_STRUCT_SOCKADDR_STORAGE struct Curl_sockaddr_storage { - struct sockaddr_storage buffer; -}; + union { + struct sockaddr sa; + struct sockaddr_in sa_in; +#ifdef ENABLE_IPV6 + struct sockaddr_in6 sa_in6; +#endif +#ifdef HAVE_STRUCT_SOCKADDR_STORAGE + struct sockaddr_storage sa_stor; #else -struct Curl_sockaddr_storage { - char buffer[256]; /* this should be big enough to fit a lot */ -}; + char cbuf[256]; /* this should be big enough to fit a lot */ #endif + } buffer; +}; #endif /* __SOCKADDR_H */ -- cgit v1.2.3