The branch, master has been updated
       via  d3c101f tests: Pass the sockaddr structure to system functions.
       via  a33de32 echo_srv: Silence alignment warnings.
       via  d059262 swrap: Silence alignment warnings.
       via  2c4e3a7 swrap: Fix type punning warnings when loading functions.
       via  6adb3e5 swrap: Fix access to struct members in log messages.
      from  442ac15 swrap: Fix whitespace errors.

http://gitweb.samba.org/?p=socket_wrapper.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit d3c101f14b17cd2750a289dda5c2fec82f9b9861
Author: Andreas Schneider <[email protected]>
Date:   Tue Sep 2 12:17:15 2014 +0200

    tests: Pass the sockaddr structure to system functions.
    
    Signed-off-by: Andreas Schneider <[email protected]>
    Reviewed-by: Stefan Metzmacher <[email protected]>

commit a33de3254837fc3c78c5c445f9c2e19b2b4d4f94
Author: Andreas Schneider <[email protected]>
Date:   Tue Sep 2 12:13:25 2014 +0200

    echo_srv: Silence alignment warnings.
    
    Signed-off-by: Andreas Schneider <[email protected]>
    Reviewed-by: Stefan Metzmacher <[email protected]>

commit d0592624650748179928205adffefc1f4e0a140f
Author: Andreas Schneider <[email protected]>
Date:   Tue Sep 2 12:00:13 2014 +0200

    swrap: Silence alignment warnings.
    
    Signed-off-by: Andreas Schneider <[email protected]>
    Reviewed-by: Stefan Metzmacher <[email protected]>

commit 2c4e3a778753f40b275598498279852ea308f703
Author: Andreas Schneider <[email protected]>
Date:   Tue Sep 2 11:55:58 2014 +0200

    swrap: Fix type punning warnings when loading functions.
    
    Signed-off-by: Andreas Schneider <[email protected]>
    Reviewed-by: Stefan Metzmacher <[email protected]>

commit 6adb3e5e3c5dcd12dfb94e5ae1b836dc9fb12a1a
Author: Andreas Schneider <[email protected]>
Date:   Tue Sep 2 11:16:04 2014 +0200

    swrap: Fix access to struct members in log messages.
    
    Signed-off-by: Andreas Schneider <[email protected]>
    Reviewed-by: Stefan Metzmacher <[email protected]>

-----------------------------------------------------------------------

Summary of changes:
 src/socket_wrapper.c                 |   39 +++++++++++++++++----------------
 tests/echo_srv.c                     |   12 +++++++---
 tests/test_echo_tcp_bind.c           |    2 +-
 tests/test_echo_tcp_socket.c         |    2 +-
 tests/test_echo_tcp_socket_options.c |    4 +-
 5 files changed, 32 insertions(+), 27 deletions(-)


Changeset truncated at 500 lines:

diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c
index 1b3352b..13b24a0 100644
--- a/src/socket_wrapper.c
+++ b/src/socket_wrapper.c
@@ -520,8 +520,9 @@ static void *_swrap_load_lib_function(enum swrap_lib lib, 
const char *fn_name)
 
 #define swrap_load_lib_function(lib, fn_name) \
        if (swrap.fns.libc_##fn_name == NULL) { \
+               void *swrap_cast_ptr = _swrap_load_lib_function(lib, #fn_name); 
\
                *(void **) (&swrap.fns.libc_##fn_name) = \
-                       _swrap_load_lib_function(lib, #fn_name); \
+                       swrap_cast_ptr; \
        }
 
 
@@ -1411,7 +1412,7 @@ static int sockaddr_convert_to_un(struct socket_info *si,
                if (in_len < sizeof(struct sockaddr_in)) {
                        break;
                }
-               sin = (const struct sockaddr_in *)in_addr;
+               sin = (const struct sockaddr_in *)(const void *)in_addr;
                if(sin->sin_addr.s_addr != htonl(INADDR_ANY)) {
                        break;
                }
@@ -1706,16 +1707,16 @@ static uint8_t *swrap_pcap_packet_init(struct timeval 
*tval,
 
        switch (src->sa_family) {
        case AF_INET:
-               src_in = (const struct sockaddr_in *)src;
-               dest_in = (const struct sockaddr_in *)dest;
+               src_in = (const struct sockaddr_in *)(const void *)src;
+               dest_in = (const struct sockaddr_in *)(const void *)dest;
                src_port = src_in->sin_port;
                dest_port = dest_in->sin_port;
                ip_hdr_len = sizeof(ip->v4);
                break;
 #ifdef HAVE_IPV6
        case AF_INET6:
-               src_in6 = (const struct sockaddr_in6 *)src;
-               dest_in6 = (const struct sockaddr_in6 *)dest;
+               src_in6 = (const struct sockaddr_in6 *)(const void *)src;
+               dest_in6 = (const struct sockaddr_in6 *)(const void *)dest;
                src_port = src_in6->sin6_port;
                dest_port = dest_in6->sin6_port;
                ip_hdr_len = sizeof(ip->v6);
@@ -1777,14 +1778,14 @@ static uint8_t *swrap_pcap_packet_init(struct timeval 
*tval,
 
        buf = base;
 
-       frame = (struct swrap_packet_frame *)buf;
+       frame = (struct swrap_packet_frame *)(void *)buf;
        frame->seconds          = tval->tv_sec;
        frame->micro_seconds    = tval->tv_usec;
        frame->recorded_length  = wire_len - icmp_truncate_len;
        frame->full_length      = wire_len - icmp_truncate_len;
        buf += SWRAP_PACKET_FRAME_SIZE;
 
-       ip = (union swrap_packet_ip *)buf;
+       ip = (union swrap_packet_ip *)(void *)buf;
        switch (src->sa_family) {
        case AF_INET:
                ip->v4.ver_hdrlen       = 0x45; /* version 4 and 5 * 32 bit 
words */
@@ -1815,7 +1816,7 @@ static uint8_t *swrap_pcap_packet_init(struct timeval 
*tval,
        }
 
        if (unreachable) {
-               pay = (union swrap_packet_payload *)buf;
+               pay = (union swrap_packet_payload *)(void *)buf;
                switch (src->sa_family) {
                case AF_INET:
                        pay->icmp4.type         = 0x03; /* destination 
unreachable */
@@ -1825,7 +1826,7 @@ static uint8_t *swrap_pcap_packet_init(struct timeval 
*tval,
                        buf += SWRAP_PACKET_PAYLOAD_ICMP4_SIZE;
 
                        /* set the ip header in the ICMP payload */
-                       ip = (union swrap_packet_ip *)buf;
+                       ip = (union swrap_packet_ip *)(void *)buf;
                        ip->v4.ver_hdrlen       = 0x45; /* version 4 and 5 * 32 
bit words */
                        ip->v4.tos              = 0x00;
                        ip->v4.packet_length    = htons(wire_len - 
icmp_hdr_len);
@@ -1851,7 +1852,7 @@ static uint8_t *swrap_pcap_packet_init(struct timeval 
*tval,
                        buf += SWRAP_PACKET_PAYLOAD_ICMP6_SIZE;
 
                        /* set the ip header in the ICMP payload */
-                       ip = (union swrap_packet_ip *)buf;
+                       ip = (union swrap_packet_ip *)(void *)buf;
                        ip->v6.ver_prio         = 0x60; /* version 4 and 5 * 32 
bit words */
                        ip->v6.flow_label_high  = 0x00;
                        ip->v6.flow_label_low   = 0x0000;
@@ -1868,7 +1869,7 @@ static uint8_t *swrap_pcap_packet_init(struct timeval 
*tval,
                }
        }
 
-       pay = (union swrap_packet_payload *)buf;
+       pay = (union swrap_packet_payload *)(void *)buf;
 
        switch (socket_type) {
        case SOCK_STREAM:
@@ -2807,7 +2808,7 @@ static int swrap_connect(int s, const struct sockaddr 
*serv_addr,
 
        SWRAP_LOG(SWRAP_LOG_TRACE,
                  "connect() path=%s, fd=%d",
-                 un_addr.un.sun_path, s);
+                 un_addr.sa.un.sun_path, s);
 
 
        /* to give better errors */
@@ -2887,7 +2888,7 @@ static int swrap_bind(int s, const struct sockaddr 
*myaddr, socklen_t addrlen)
                        break;
                }
 
-               sin = (const struct sockaddr_in *)myaddr;
+               sin = (const struct sockaddr_in *)(const void *)myaddr;
 
                if (sin->sin_family != AF_INET) {
                        bind_error = EAFNOSUPPORT;
@@ -2910,7 +2911,7 @@ static int swrap_bind(int s, const struct sockaddr 
*myaddr, socklen_t addrlen)
                        break;
                }
 
-               sin6 = (const struct sockaddr_in6 *)myaddr;
+               sin6 = (const struct sockaddr_in6 *)(const void *)myaddr;
 
                if (sin6->sin6_family != AF_INET6) {
                        bind_error = EAFNOSUPPORT;
@@ -2954,7 +2955,7 @@ static int swrap_bind(int s, const struct sockaddr 
*myaddr, socklen_t addrlen)
 
        SWRAP_LOG(SWRAP_LOG_TRACE,
                  "bind() path=%s, fd=%d",
-                 un_addr.sa_un.sun_path, s);
+                 un_addr.sa.un.sun_path, s);
 
        if (ret == 0) {
                si->bound = 1;
@@ -3019,7 +3020,7 @@ static int swrap_bindresvport_sa(int sd, struct sockaddr 
*sa)
                        break;
                }
                case AF_INET6: {
-                       struct sockaddr_in6 *sin6p = (struct sockaddr_in6 *)sa;
+                       struct sockaddr_in6 *sin6p = (struct sockaddr_in6 
*)(void *)sa;
 
                        salen = sizeof(struct sockaddr_in6);
                        sin6p->sin6_port = htons(port);
@@ -4239,7 +4240,7 @@ static ssize_t swrap_sendto(int s, const void *buf, 
size_t len, int flags,
        if (bcast) {
                struct stat st;
                unsigned int iface;
-               unsigned int prt = ntohs(((const struct sockaddr_in 
*)to)->sin_port);
+               unsigned int prt = ntohs(((const struct sockaddr_in *)(const 
void *)to)->sin_port);
                char type;
 
                type = SOCKET_TYPE_CHAR_UDP;
@@ -4603,7 +4604,7 @@ static ssize_t swrap_sendmsg(int s, const struct msghdr 
*omsg, int flags)
        if (bcast) {
                struct stat st;
                unsigned int iface;
-               unsigned int prt = ntohs(((const struct sockaddr_in 
*)to)->sin_port);
+               unsigned int prt = ntohs(((const struct sockaddr_in *)(const 
void *)to)->sin_port);
                char type;
                size_t i, len = 0;
                uint8_t *buf;
diff --git a/tests/echo_srv.c b/tests/echo_srv.c
index 0eb4676..5b784de 100644
--- a/tests/echo_srv.c
+++ b/tests/echo_srv.c
@@ -612,7 +612,8 @@ static ssize_t echo_udp_recv_from_to(int sock,
                        if (cmsgptr->cmsg_level == IPPROTO_IP &&
                            cmsgptr->cmsg_type == IP_RECVDSTADDR) {
                                char ip[INET_ADDRSTRLEN] = { 0 };
-                               struct sockaddr_in *sinp = (struct sockaddr_in 
*)to;
+                               struct sockaddr_in *sinp =
+                                       (struct sockaddr_in *)(void *)to;
                                struct in_addr *addr;
                                void *cmsg_cast_ptr = CMSG_DATA(cmsgptr);
 
@@ -639,7 +640,8 @@ static ssize_t echo_udp_recv_from_to(int sock,
                                        cmsgptr->cmsg_type == IPV6_PKTINFO) {
                                char ip[INET6_ADDRSTRLEN] = { 0 };
                                struct in6_pktinfo *pkt6;
-                               struct sockaddr_in6 *sin6p = (struct 
sockaddr_in6 *)to;
+                               struct sockaddr_in6 *sin6p =
+                                       (struct sockaddr_in6 *)(void *)to;
                                void *cmsg_cast_ptr = CMSG_DATA(cmsgptr);
 
                                pkt6 = (struct in6_pktinfo *)cmsg_cast_ptr;
@@ -717,7 +719,8 @@ static ssize_t echo_udp_send_to_from(int sock,
 #elif defined(IP_SENDSRCADDR)
                struct in_addr *p = (struct in_addr *)cmsg_cast_ptr;
 #endif
-               const struct sockaddr_in *from4 = (const struct sockaddr_in 
*)from;
+               const struct sockaddr_in *from4 =
+                       (const struct sockaddr_in *)(const void *)from;
 
                if (fromlen != sizeof(struct sockaddr_in)) {
                        break;
@@ -742,7 +745,8 @@ static ssize_t echo_udp_send_to_from(int sock,
        case AF_INET6: {
         void *cast_ptr = CMSG_DATA(cmsgptr);
                struct in6_pktinfo *p = (struct in6_pktinfo *)cast_ptr;
-               const struct sockaddr_in6 *from6 = (const struct sockaddr_in6 
*)from;
+               const struct sockaddr_in6 *from6 =
+                       (const struct sockaddr_in6 *)(const void *)from;
 
                if (fromlen != sizeof(struct sockaddr_in6)) {
                        break;
diff --git a/tests/test_echo_tcp_bind.c b/tests/test_echo_tcp_bind.c
index 705fd8d..b95724d 100644
--- a/tests/test_echo_tcp_bind.c
+++ b/tests/test_echo_tcp_bind.c
@@ -411,7 +411,7 @@ static void test_bind_on_ipv6_sock(void **state)
        assert_return_code(s, errno);
 
        addr_un.sa.un.sun_family = AF_UNIX;
-       rc = bind(s, &addr_un.sa.un, addr_un.sa_socklen);
+       rc = bind(s, &addr_un.sa.s, addr_un.sa_socklen);
        assert_int_equal(rc, -1);
        /* FreeBSD uses EINVAL here... */
        assert_true(errno == EAFNOSUPPORT || errno == EINVAL);
diff --git a/tests/test_echo_tcp_socket.c b/tests/test_echo_tcp_socket.c
index ebbe87b..a4b2f89 100644
--- a/tests/test_echo_tcp_socket.c
+++ b/tests/test_echo_tcp_socket.c
@@ -47,7 +47,7 @@ static void test_socket_getsockname6(void **state)
        s = socket(AF_INET6, SOCK_STREAM, IPPROTO_TCP);
        assert_int_not_equal(s, -1);
 
-       rc = getsockname(s, &addr.sa.in6, &addr.sa_socklen);
+       rc = getsockname(s, &addr.sa.s, &addr.sa_socklen);
        assert_return_code(rc, errno);
        assert_int_equal(addr.sa.in6.sin6_family, AF_INET6);
 }
diff --git a/tests/test_echo_tcp_socket_options.c 
b/tests/test_echo_tcp_socket_options.c
index ba14e73..dbad41d 100644
--- a/tests/test_echo_tcp_socket_options.c
+++ b/tests/test_echo_tcp_socket_options.c
@@ -122,7 +122,7 @@ static void test_sockopt_so(void **state)
                       &addr.sa.in.sin_addr);
        assert_int_equal(rc, 1);
 
-       rc = connect(s, &addr.sa.in, addr.sa_socklen);
+       rc = connect(s, &addr.sa.s, addr.sa_socklen);
        assert_int_equal(rc, 0);
 
 #ifdef SO_DOMAIN
@@ -192,7 +192,7 @@ static void test_sockopt_so6(void **state)
                       &addr.sa.in6.sin6_addr);
        assert_int_equal(rc, 1);
 
-       rc = connect(s, &addr.sa.in6, addr.sa_socklen);
+       rc = connect(s, &addr.sa.s, addr.sa_socklen);
        assert_int_equal(rc, 0);
 
 #ifdef SO_DOMAIN


-- 
Socket Wrapper Repository

Reply via email to