Ignore:
Timestamp:
Jun 15, 2009, 5:16:36 AM (12 years ago)
Author:
jhujhiti
Message:

(trunk libT) fix "dereferencing pointer does brea strict-aliasing rules" warning

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/fdlimit.c

    r8691 r8702  
    612612         * align with the family field of any protocol-specific structure." */
    613613        if( sock.ss_family == AF_INET )
    614         {
    615             struct sockaddr_in * sock4 = (struct sockaddr_in *)&sock;
     614        {
     615            struct sockaddr_in *si;
     616            union { struct sockaddr_storage dummy; struct sockaddr_in si; } s;
     617            s.dummy = sock;
     618            si = &s.si;
    616619            addr->type = TR_AF_INET;
    617             addr->addr.addr4.s_addr = sock4->sin_addr.s_addr;
    618             *port = sock4->sin_port;
     620            addr->addr.addr4.s_addr = si->sin_addr.s_addr;
     621            *port = si->sin_port;
    619622        }
    620623        else
    621624        {
    622             struct sockaddr_in6 * sock6 = (struct sockaddr_in6 *)&sock;
     625            struct sockaddr_in6 *si;
     626            union { struct sockaddr_storage dummy; struct sockaddr_in6 si; } s;
     627            s.dummy = sock;
     628            si = &s.si;
    623629            addr->type = TR_AF_INET6;
    624             addr->addr.addr6 = sock6->sin6_addr;
    625             *port = sock6->sin6_port;
     630            addr->addr.addr6 = si->sin6_addr;
     631            *port = si->sin6_port;
    626632        }
    627633        ++gFd->socketCount;
Note: See TracChangeset for help on using the changeset viewer.