Changeset 14347


Ignore:
Timestamp:
Nov 30, 2014, 7:38:47 PM (8 years ago)
Author:
mikedld
Message:

#5771: Use true and false instead of 1 and 0 for bool variables (patch by ticamkq + additional fixes)

Location:
trunk/libtransmission
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/crypto.c

    r14282 r14347  
    176176      memset (crypto->mySecret, 0, offset);
    177177      memcpy (crypto->mySecret + offset, secret, len);
    178       crypto->mySecretIsSet = 1;
     178      crypto->mySecretIsSet = true;
    179179    }
    180180
     
    271271                         const uint8_t * hash)
    272272{
    273   crypto->torrentHashIsSet = hash ? 1 : 0;
     273  crypto->torrentHashIsSet = hash != NULL;
    274274
    275275  if (hash)
     
    287287}
    288288
    289 int
     289bool
    290290tr_cryptoHasTorrentHash (const tr_crypto * crypto)
    291291{
    292292  assert (crypto);
    293293
    294   return crypto->torrentHashIsSet ? 1 : 0;
     294  return crypto->torrentHashIsSet;
    295295}
    296296
  • trunk/libtransmission/crypto.h

    r14241 r14347  
    5858const uint8_t* tr_cryptoGetTorrentHash (const tr_crypto * crypto);
    5959
    60 int            tr_cryptoHasTorrentHash (const tr_crypto * crypto);
     60bool           tr_cryptoHasTorrentHash (const tr_crypto * crypto);
    6161
    6262const uint8_t* tr_cryptoComputeSecret (tr_crypto *     crypto,
  • trunk/libtransmission/fdlimit.c

    r14331 r14347  
    4242{
    4343  const char zero = '\0';
    44   bool success = 0;
     44  bool success = false;
    4545
    4646  if (!length)
     
    6666preallocate_file_full (const char * filename, uint64_t length)
    6767{
    68   bool success = 0;
     68  bool success = false;
    6969
    7070  tr_sys_file_t fd = tr_sys_file_open (filename, TR_SYS_FILE_WRITE | TR_SYS_FILE_CREATE, 0666, NULL);
  • trunk/libtransmission/handshake.c

    r14241 r14347  
    475475    evbuffer_add        (outbuf, msg, sizeof (msg));
    476476
    477     handshake->haveSentBitTorrentHandshake = 1;
     477    handshake->haveSentBitTorrentHandshake = true;
    478478  }
    479479
     
    688688        return tr_handshakeDone (handshake, false);
    689689      tr_peerIoWriteBytes (handshake->io, msg, sizeof (msg), false);
    690       handshake->haveSentBitTorrentHandshake = 1;
     690      handshake->haveSentBitTorrentHandshake = true;
    691691    }
    692692
     
    940940
    941941    evbuffer_add (outbuf, msg, sizeof (msg));
    942     handshake->haveSentBitTorrentHandshake = 1;
     942    handshake->haveSentBitTorrentHandshake = true;
    943943  }
    944944
     
    11401140          uint8_t msg[HANDSHAKE_SIZE];
    11411141          buildHandshakeMessage (handshake, msg);
    1142           handshake->haveSentBitTorrentHandshake = 1;
     1142          handshake->haveSentBitTorrentHandshake = true;
    11431143          setReadState (handshake, AWAITING_HANDSHAKE);
    11441144          tr_peerIoWriteBytes (handshake->io, msg, sizeof (msg), false);
     
    11571157      dbgmsg (handshake, "handshake failed, trying plaintext...");
    11581158      buildHandshakeMessage (handshake, msg);
    1159       handshake->haveSentBitTorrentHandshake = 1;
     1159      handshake->haveSentBitTorrentHandshake = true;
    11601160      setReadState (handshake, AWAITING_HANDSHAKE);
    11611161      tr_peerIoWriteBytes (handshake->io, msg, sizeof (msg), false);
     
    12151215      buildHandshakeMessage (handshake, msg);
    12161216
    1217       handshake->haveSentBitTorrentHandshake = 1;
     1217      handshake->haveSentBitTorrentHandshake = true;
    12181218      setReadState (handshake, AWAITING_HANDSHAKE);
    12191219      tr_peerIoWriteBytes (handshake->io, msg, sizeof (msg), false);
  • trunk/libtransmission/net.c

    r14316 r14347  
    575575    static unsigned char ipv6[16];
    576576    static time_t last_time = 0;
    577     static int have_ipv6 = 0;
     577    static bool have_ipv6 = false;
    578578    const time_t now = tr_time ();
    579579
  • trunk/libtransmission/peer-io.c

    r14316 r14347  
    180180canReadWrapper (tr_peerIo * io)
    181181{
    182     bool err = 0;
    183     bool done = 0;
     182    bool err = false;
     183    bool done = false;
    184184    tr_session * session;
    185185
     
    222222                    if (evbuffer_get_length (io->inbuf))
    223223                        continue;
    224                     done = 1;
     224                    done = true;
    225225                    break;
    226226
    227227                case READ_LATER:
    228                     done = 1;
     228                    done = true;
    229229                    break;
    230230
    231231                case READ_ERR:
    232                     err = 1;
     232                    err = true;
    233233                    break;
    234234            }
     
    972972}
    973973
    974 int
     974bool
    975975tr_peerIoHasTorrentHash (const tr_peerIo * io)
    976976{
  • trunk/libtransmission/peer-io.h

    r14241 r14347  
    218218const uint8_t*       tr_peerIoGetTorrentHash (tr_peerIo * io);
    219219
    220 int                  tr_peerIoHasTorrentHash (const tr_peerIo * io);
     220bool                 tr_peerIoHasTorrentHash (const tr_peerIo * io);
    221221
    222222void                 tr_peerIoSetTorrentHash (tr_peerIo *     io,
  • trunk/libtransmission/peer-mgr.c

    r14311 r14347  
    15571557      struct peer_atom * atom = peer->atom;
    15581558      atom->flags2 |= MYFLAG_BANNED;
    1559       peer->doPurge = 1;
     1559      peer->doPurge = true;
    15601560      tordbg (s, "banning peer %s", tr_atomAddrStr (atom));
    15611561    }
     
    18121812          {
    18131813            /* some protocol error from the peer */
    1814             peer->doPurge = 1;
     1814            peer->doPurge = true;
    18151815            tordbg (s, "setting %s doPurge flag because we got an ERANGE, EMSGSIZE, or ENOTCONN error",
    18161816                    tr_atomAddrStr (peer->atom));
  • trunk/libtransmission/peer-msgs.c

    r14334 r14347  
    679679        /* build the fast set */
    680680        msgs->fastsetSize = tr_generateAllowedSet (msgs->fastset, numwant, inf->pieceCount, inf->hash, addr);
    681         msgs->haveFastSet = 1;
     681        msgs->haveFastSet = true;
    682682
    683683        /* send it to the peer */
     
    933933
    934934    dbgmsg (msgs, "sending an ltep handshake");
    935     msgs->clientSentLtepHandshake = 1;
     935    msgs->clientSentLtepHandshake = true;
    936936
    937937    /* decide if we want to advertise metadata xfer support (BEP 9) */
    938938    if (tr_torrentIsPrivate (msgs->torrent))
    939         allow_metadata_xfer = 0;
     939        allow_metadata_xfer = false;
    940940    else
    941         allow_metadata_xfer = 1;
     941        allow_metadata_xfer = true;
    942942
    943943    /* decide if we want to advertise pex support */
    944944    if (!tr_torrentAllowsPex (msgs->torrent))
    945         allow_pex = 0;
     945        allow_pex = false;
    946946    else if (msgs->peerSentLtepHandshake)
    947         allow_pex = msgs->peerSupportsPex ? 1 : 0;
     947        allow_pex = msgs->peerSupportsPex;
    948948    else
    949         allow_pex = 1;
     949        allow_pex = true;
    950950
    951951    tr_variantInitDict (&val, 8);
     
    996996
    997997    tr_peerIoReadBytes (msgs->io, inbuf, tmp, len);
    998     msgs->peerSentLtepHandshake = 1;
     998    msgs->peerSentLtepHandshake = true;
    999999
    10001000    if (tr_variantFromBenc (&val, tmp, len) || !tr_variantIsDict (&val))
     
    10161016
    10171017    /* check supported messages for utorrent pex */
    1018     msgs->peerSupportsPex = 0;
    1019     msgs->peerSupportsMetadataXfer = 0;
     1018    msgs->peerSupportsPex = false;
     1019    msgs->peerSupportsMetadataXfer = false;
    10201020
    10211021    if (tr_variantDictFindDict (&val, TR_KEY_m, &sub)) {
     
    12451245    {
    12461246        dbgmsg (msgs, "got ut pex");
    1247         msgs->peerSupportsPex = 1;
     1247        msgs->peerSupportsPex = true;
    12481248        parseUtPex (msgs, msglen, inbuf);
    12491249    }
     
    12511251    {
    12521252        dbgmsg (msgs, "got ut metadata");
    1253         msgs->peerSupportsMetadataXfer = 1;
     1253        msgs->peerSupportsMetadataXfer = true;
    12541254        parseUtMetadata (msgs, msglen, inbuf);
    12551255    }
  • trunk/libtransmission/torrent.c

    r14344 r14347  
    19771977
    19781978  assert (tr_isTorrent (tor));
    1979   tor->isDeleting = 1;
     1979  tor->isDeleting = true;
    19801980
    19811981  data = tr_new0 (struct remove_data, 1);
  • trunk/libtransmission/upnp.c

    r14262 r14347  
    225225                         "Local Address is \"%s\""), handle->lanaddr);
    226226            handle->state = TR_UPNP_IDLE;
    227             handle->hasDiscovered = 1;
     227            handle->hasDiscovered = true;
    228228        }
    229229        else
  • trunk/libtransmission/verify.c

    r14327 r14347  
    4444  tr_sys_file_t fd = TR_BAD_SYS_FILE;
    4545  uint64_t filePos = 0;
    46   bool changed = 0;
    47   bool hadPiece = 0;
     46  bool changed = false;
     47  bool hadPiece = false;
    4848  time_t lastSleptAt = 0;
    4949  uint32_t piecePos = 0;
Note: See TracChangeset for help on using the changeset viewer.