Changeset 4015 for zzuf


Ignore:
Timestamp:
Nov 23, 2009, 12:16:03 PM (10 years ago)
Author:
Sam Hocevar
Message:

Fix a compilation warning in the network code.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • zzuf/trunk/src/network.c

    r3933 r4015  
    197197static unsigned int get_socket_ip(int sock)
    198198{
    199     int ret;
     199    struct sockaddr s;
    200200    struct sockaddr_in sin;
    201201    socklen_t len = sizeof(sin);
     202    int ret;
    202203
    203204    // Probably not a socket descriptor
     
    205206        return 0;
    206207
    207     memset(&sin, 0, sizeof(sin));
    208     ret = getsockname(sock, &sin, &len);
    209     if (ret) {
    210         // TODO error handling
    211         return 0;
    212     }
    213 
     208    /* Use a sockaddr instead of sockaddr_in because we don't know whether
     209     * their alignments are compatible. So, no cast. */
     210    memset(&s, 0, sizeof(sin));
     211    ret = getsockname(sock, &s, &len);
     212    if (ret)
     213        return 0; // TODO: error handling
     214
     215    memcpy(&sin, &s, sizeof(sin));
    214216    return sin.sin_addr.s_addr;
    215217}
Note: See TracChangeset for help on using the changeset viewer.