#5771: Use true and false instead of 1 and 0 for bool variables (patch by ticamkq + additional fixes)
This commit is contained in:
parent
10e59dbc90
commit
e30728367f
|
@ -175,7 +175,7 @@ tr_cryptoComputeSecret (tr_crypto * crypto,
|
|||
offset = KEY_LEN - len;
|
||||
memset (crypto->mySecret, 0, offset);
|
||||
memcpy (crypto->mySecret + offset, secret, len);
|
||||
crypto->mySecretIsSet = 1;
|
||||
crypto->mySecretIsSet = true;
|
||||
}
|
||||
|
||||
BN_free (bn);
|
||||
|
@ -270,7 +270,7 @@ void
|
|||
tr_cryptoSetTorrentHash (tr_crypto * crypto,
|
||||
const uint8_t * hash)
|
||||
{
|
||||
crypto->torrentHashIsSet = hash ? 1 : 0;
|
||||
crypto->torrentHashIsSet = hash != NULL;
|
||||
|
||||
if (hash)
|
||||
memcpy (crypto->torrentHash, hash, SHA_DIGEST_LENGTH);
|
||||
|
@ -286,12 +286,12 @@ tr_cryptoGetTorrentHash (const tr_crypto * crypto)
|
|||
return crypto->torrentHashIsSet ? crypto->torrentHash : NULL;
|
||||
}
|
||||
|
||||
int
|
||||
bool
|
||||
tr_cryptoHasTorrentHash (const tr_crypto * crypto)
|
||||
{
|
||||
assert (crypto);
|
||||
|
||||
return crypto->torrentHashIsSet ? 1 : 0;
|
||||
return crypto->torrentHashIsSet;
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
@ -57,7 +57,7 @@ void tr_cryptoSetTorrentHash (tr_crypto * crypto, const uint8_t * torrentHash);
|
|||
|
||||
const uint8_t* tr_cryptoGetTorrentHash (const tr_crypto * crypto);
|
||||
|
||||
int tr_cryptoHasTorrentHash (const tr_crypto * crypto);
|
||||
bool tr_cryptoHasTorrentHash (const tr_crypto * crypto);
|
||||
|
||||
const uint8_t* tr_cryptoComputeSecret (tr_crypto * crypto,
|
||||
const uint8_t * peerPublicKey);
|
||||
|
|
|
@ -41,7 +41,7 @@ static bool
|
|||
preallocate_file_sparse (tr_sys_file_t fd, uint64_t length)
|
||||
{
|
||||
const char zero = '\0';
|
||||
bool success = 0;
|
||||
bool success = false;
|
||||
|
||||
if (!length)
|
||||
success = true;
|
||||
|
@ -65,7 +65,7 @@ preallocate_file_sparse (tr_sys_file_t fd, uint64_t length)
|
|||
static bool
|
||||
preallocate_file_full (const char * filename, uint64_t length)
|
||||
{
|
||||
bool success = 0;
|
||||
bool success = false;
|
||||
|
||||
tr_sys_file_t fd = tr_sys_file_open (filename, TR_SYS_FILE_WRITE | TR_SYS_FILE_CREATE, 0666, NULL);
|
||||
if (fd != TR_BAD_SYS_FILE)
|
||||
|
|
|
@ -474,7 +474,7 @@ readYb (tr_handshake * handshake, struct evbuffer * inbuf)
|
|||
evbuffer_add_uint16 (outbuf, sizeof (msg));
|
||||
evbuffer_add (outbuf, msg, sizeof (msg));
|
||||
|
||||
handshake->haveSentBitTorrentHandshake = 1;
|
||||
handshake->haveSentBitTorrentHandshake = true;
|
||||
}
|
||||
|
||||
/* send it */
|
||||
|
@ -687,7 +687,7 @@ readHandshake (tr_handshake * handshake,
|
|||
if (!buildHandshakeMessage (handshake, msg))
|
||||
return tr_handshakeDone (handshake, false);
|
||||
tr_peerIoWriteBytes (handshake->io, msg, sizeof (msg), false);
|
||||
handshake->haveSentBitTorrentHandshake = 1;
|
||||
handshake->haveSentBitTorrentHandshake = true;
|
||||
}
|
||||
|
||||
setReadState (handshake, AWAITING_PEER_ID);
|
||||
|
@ -939,7 +939,7 @@ readIA (tr_handshake * handshake,
|
|||
return tr_handshakeDone (handshake, false);
|
||||
|
||||
evbuffer_add (outbuf, msg, sizeof (msg));
|
||||
handshake->haveSentBitTorrentHandshake = 1;
|
||||
handshake->haveSentBitTorrentHandshake = true;
|
||||
}
|
||||
|
||||
/* send it out */
|
||||
|
@ -1139,7 +1139,7 @@ gotError (tr_peerIo * io,
|
|||
{
|
||||
uint8_t msg[HANDSHAKE_SIZE];
|
||||
buildHandshakeMessage (handshake, msg);
|
||||
handshake->haveSentBitTorrentHandshake = 1;
|
||||
handshake->haveSentBitTorrentHandshake = true;
|
||||
setReadState (handshake, AWAITING_HANDSHAKE);
|
||||
tr_peerIoWriteBytes (handshake->io, msg, sizeof (msg), false);
|
||||
}
|
||||
|
@ -1156,7 +1156,7 @@ gotError (tr_peerIo * io,
|
|||
|
||||
dbgmsg (handshake, "handshake failed, trying plaintext...");
|
||||
buildHandshakeMessage (handshake, msg);
|
||||
handshake->haveSentBitTorrentHandshake = 1;
|
||||
handshake->haveSentBitTorrentHandshake = true;
|
||||
setReadState (handshake, AWAITING_HANDSHAKE);
|
||||
tr_peerIoWriteBytes (handshake->io, msg, sizeof (msg), false);
|
||||
}
|
||||
|
@ -1214,7 +1214,7 @@ tr_handshakeNew (tr_peerIo * io,
|
|||
uint8_t msg[HANDSHAKE_SIZE];
|
||||
buildHandshakeMessage (handshake, msg);
|
||||
|
||||
handshake->haveSentBitTorrentHandshake = 1;
|
||||
handshake->haveSentBitTorrentHandshake = true;
|
||||
setReadState (handshake, AWAITING_HANDSHAKE);
|
||||
tr_peerIoWriteBytes (handshake->io, msg, sizeof (msg), false);
|
||||
}
|
||||
|
|
|
@ -574,7 +574,7 @@ tr_globalIPv6 (void)
|
|||
{
|
||||
static unsigned char ipv6[16];
|
||||
static time_t last_time = 0;
|
||||
static int have_ipv6 = 0;
|
||||
static bool have_ipv6 = false;
|
||||
const time_t now = tr_time ();
|
||||
|
||||
/* Re-check every half hour */
|
||||
|
|
|
@ -179,8 +179,8 @@ didWriteWrapper (tr_peerIo * io, unsigned int bytes_transferred)
|
|||
static void
|
||||
canReadWrapper (tr_peerIo * io)
|
||||
{
|
||||
bool err = 0;
|
||||
bool done = 0;
|
||||
bool err = false;
|
||||
bool done = false;
|
||||
tr_session * session;
|
||||
|
||||
dbgmsg (io, "canRead");
|
||||
|
@ -221,15 +221,15 @@ canReadWrapper (tr_peerIo * io)
|
|||
case READ_NOW:
|
||||
if (evbuffer_get_length (io->inbuf))
|
||||
continue;
|
||||
done = 1;
|
||||
done = true;
|
||||
break;
|
||||
|
||||
case READ_LATER:
|
||||
done = 1;
|
||||
done = true;
|
||||
break;
|
||||
|
||||
case READ_ERR:
|
||||
err = 1;
|
||||
err = true;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -971,7 +971,7 @@ tr_peerIoGetTorrentHash (tr_peerIo * io)
|
|||
return tr_cryptoGetTorrentHash (&io->crypto);
|
||||
}
|
||||
|
||||
int
|
||||
bool
|
||||
tr_peerIoHasTorrentHash (const tr_peerIo * io)
|
||||
{
|
||||
assert (tr_isPeerIo (io));
|
||||
|
|
|
@ -217,7 +217,7 @@ const struct tr_address * tr_peerIoGetAddress (const tr_peerIo * io,
|
|||
|
||||
const uint8_t* tr_peerIoGetTorrentHash (tr_peerIo * io);
|
||||
|
||||
int tr_peerIoHasTorrentHash (const tr_peerIo * io);
|
||||
bool tr_peerIoHasTorrentHash (const tr_peerIo * io);
|
||||
|
||||
void tr_peerIoSetTorrentHash (tr_peerIo * io,
|
||||
const uint8_t * hash);
|
||||
|
|
|
@ -1556,7 +1556,7 @@ addStrike (tr_swarm * s, tr_peer * peer)
|
|||
{
|
||||
struct peer_atom * atom = peer->atom;
|
||||
atom->flags2 |= MYFLAG_BANNED;
|
||||
peer->doPurge = 1;
|
||||
peer->doPurge = true;
|
||||
tordbg (s, "banning peer %s", tr_atomAddrStr (atom));
|
||||
}
|
||||
}
|
||||
|
@ -1811,7 +1811,7 @@ peerCallbackFunc (tr_peer * peer, const tr_peer_event * e, void * vs)
|
|||
if ((e->err == ERANGE) || (e->err == EMSGSIZE) || (e->err == ENOTCONN))
|
||||
{
|
||||
/* some protocol error from the peer */
|
||||
peer->doPurge = 1;
|
||||
peer->doPurge = true;
|
||||
tordbg (s, "setting %s doPurge flag because we got an ERANGE, EMSGSIZE, or ENOTCONN error",
|
||||
tr_atomAddrStr (peer->atom));
|
||||
}
|
||||
|
|
|
@ -678,7 +678,7 @@ updateFastSet (tr_peerMsgs * msgs UNUSED)
|
|||
|
||||
/* build the fast set */
|
||||
msgs->fastsetSize = tr_generateAllowedSet (msgs->fastset, numwant, inf->pieceCount, inf->hash, addr);
|
||||
msgs->haveFastSet = 1;
|
||||
msgs->haveFastSet = true;
|
||||
|
||||
/* send it to the peer */
|
||||
for (i=0; i<msgs->fastsetSize; ++i)
|
||||
|
@ -932,21 +932,21 @@ sendLtepHandshake (tr_peerMsgs * msgs)
|
|||
version_quark = tr_quark_new (TR_NAME " " USERAGENT_PREFIX, -1);
|
||||
|
||||
dbgmsg (msgs, "sending an ltep handshake");
|
||||
msgs->clientSentLtepHandshake = 1;
|
||||
msgs->clientSentLtepHandshake = true;
|
||||
|
||||
/* decide if we want to advertise metadata xfer support (BEP 9) */
|
||||
if (tr_torrentIsPrivate (msgs->torrent))
|
||||
allow_metadata_xfer = 0;
|
||||
allow_metadata_xfer = false;
|
||||
else
|
||||
allow_metadata_xfer = 1;
|
||||
allow_metadata_xfer = true;
|
||||
|
||||
/* decide if we want to advertise pex support */
|
||||
if (!tr_torrentAllowsPex (msgs->torrent))
|
||||
allow_pex = 0;
|
||||
allow_pex = false;
|
||||
else if (msgs->peerSentLtepHandshake)
|
||||
allow_pex = msgs->peerSupportsPex ? 1 : 0;
|
||||
allow_pex = msgs->peerSupportsPex;
|
||||
else
|
||||
allow_pex = 1;
|
||||
allow_pex = true;
|
||||
|
||||
tr_variantInitDict (&val, 8);
|
||||
tr_variantDictAddInt (&val, TR_KEY_e, getSession (msgs)->encryptionMode != TR_CLEAR_PREFERRED);
|
||||
|
@ -995,7 +995,7 @@ parseLtepHandshake (tr_peerMsgs * msgs, int len, struct evbuffer * inbuf)
|
|||
memset (&pex, 0, sizeof (tr_pex));
|
||||
|
||||
tr_peerIoReadBytes (msgs->io, inbuf, tmp, len);
|
||||
msgs->peerSentLtepHandshake = 1;
|
||||
msgs->peerSentLtepHandshake = true;
|
||||
|
||||
if (tr_variantFromBenc (&val, tmp, len) || !tr_variantIsDict (&val))
|
||||
{
|
||||
|
@ -1015,8 +1015,8 @@ parseLtepHandshake (tr_peerMsgs * msgs, int len, struct evbuffer * inbuf)
|
|||
}
|
||||
|
||||
/* check supported messages for utorrent pex */
|
||||
msgs->peerSupportsPex = 0;
|
||||
msgs->peerSupportsMetadataXfer = 0;
|
||||
msgs->peerSupportsPex = false;
|
||||
msgs->peerSupportsMetadataXfer = false;
|
||||
|
||||
if (tr_variantDictFindDict (&val, TR_KEY_m, &sub)) {
|
||||
if (tr_variantDictFindInt (sub, TR_KEY_ut_pex, &i)) {
|
||||
|
@ -1244,13 +1244,13 @@ parseLtep (tr_peerMsgs * msgs, int msglen, struct evbuffer * inbuf)
|
|||
else if (ltep_msgid == UT_PEX_ID)
|
||||
{
|
||||
dbgmsg (msgs, "got ut pex");
|
||||
msgs->peerSupportsPex = 1;
|
||||
msgs->peerSupportsPex = true;
|
||||
parseUtPex (msgs, msglen, inbuf);
|
||||
}
|
||||
else if (ltep_msgid == UT_METADATA_ID)
|
||||
{
|
||||
dbgmsg (msgs, "got ut metadata");
|
||||
msgs->peerSupportsMetadataXfer = 1;
|
||||
msgs->peerSupportsMetadataXfer = true;
|
||||
parseUtMetadata (msgs, msglen, inbuf);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -1976,7 +1976,7 @@ tr_torrentRemove (tr_torrent * tor,
|
|||
struct remove_data * data;
|
||||
|
||||
assert (tr_isTorrent (tor));
|
||||
tor->isDeleting = 1;
|
||||
tor->isDeleting = true;
|
||||
|
||||
data = tr_new0 (struct remove_data, 1);
|
||||
data->tor = tor;
|
||||
|
|
|
@ -224,7 +224,7 @@ tr_upnpPulse (tr_upnp * handle,
|
|||
tr_logAddNamedInfo (getKey (), _(
|
||||
"Local Address is \"%s\""), handle->lanaddr);
|
||||
handle->state = TR_UPNP_IDLE;
|
||||
handle->hasDiscovered = 1;
|
||||
handle->hasDiscovered = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -43,8 +43,8 @@ verifyTorrent (tr_torrent * tor, bool * stopFlag)
|
|||
SHA_CTX sha;
|
||||
tr_sys_file_t fd = TR_BAD_SYS_FILE;
|
||||
uint64_t filePos = 0;
|
||||
bool changed = 0;
|
||||
bool hadPiece = 0;
|
||||
bool changed = false;
|
||||
bool hadPiece = false;
|
||||
time_t lastSleptAt = 0;
|
||||
uint32_t piecePos = 0;
|
||||
tr_file_index_t fileIndex = 0;
|
||||
|
|
Loading…
Reference in New Issue