Ignore:
Timestamp:
Mar 18, 2015, 7:34:26 AM (6 years ago)
Author:
mikedld
Message:

Define and use tr_socket_t and TR_BAD_SOCKET instead of int and -1.

Test socket validity by comparing to TR_BAD_SOCKET instead of various
(and sometimes wrong) other tests like x >= 0, x != -1, x > 0,
x > -1, x (valid), and x < 0, x == -1 (invalid).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/announcer-udp.c

    r14476 r14479  
    5454            const void * buf, size_t buflen)
    5555{
    56     int sockfd;
     56    tr_socket_t sockfd;
    5757
    5858    if (ai->ai_addr->sa_family == AF_INET)
     
    6161        sockfd = session->udp6_socket;
    6262    else
    63         sockfd = -1;
    64 
    65     if (sockfd < 0) {
     63        sockfd = TR_BAD_SOCKET;
     64
     65    if (sockfd == TR_BAD_SOCKET) {
    6666        errno = EAFNOSUPPORT;
    6767        return -1;
Note: See TracChangeset for help on using the changeset viewer.