1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-25 09:13:06 +00:00

treat bool args as booleans rather than ints; no need to compare them a la 'if (boolVal != 0)'

This commit is contained in:
Jordan Lee 2013-08-24 18:08:38 +00:00
parent 28fe36f1f8
commit f762c2ce6a
4 changed files with 43 additions and 22 deletions

View file

@ -624,7 +624,7 @@ tr_peerIoNew (tr_session * session,
io->port = port; io->port = port;
io->socket = socket; io->socket = socket;
io->utp_socket = utp_socket; io->utp_socket = utp_socket;
io->isIncoming = isIncoming != 0; io->isIncoming = isIncoming;
io->timeCreated = tr_time (); io->timeCreated = tr_time ();
io->inbuf = evbuffer_new (); io->inbuf = evbuffer_new ();
io->outbuf = evbuffer_new (); io->outbuf = evbuffer_new ();
@ -1051,7 +1051,7 @@ addDatatype (tr_peerIo * io, size_t byteCount, bool isPieceData)
{ {
struct tr_datatype * d; struct tr_datatype * d;
d = datatype_new (); d = datatype_new ();
d->isPieceData = isPieceData != 0; d->isPieceData = isPieceData;
d->length = byteCount; d->length = byteCount;
peer_io_push_datatype (io, d); peer_io_push_datatype (io, d);
} }

View file

@ -843,7 +843,9 @@ void
tr_rpcSetWhitelistEnabled (tr_rpc_server * server, tr_rpcSetWhitelistEnabled (tr_rpc_server * server,
bool isEnabled) bool isEnabled)
{ {
server->isWhitelistEnabled = isEnabled != 0; assert (tr_isBool (isEnabled));
server->isWhitelistEnabled = isEnabled;
} }
bool bool

View file

@ -2028,8 +2028,9 @@ void
tr_sessionSetPexEnabled (tr_session * session, bool enabled) tr_sessionSetPexEnabled (tr_session * session, bool enabled)
{ {
assert (tr_isSession (session)); assert (tr_isSession (session));
assert (tr_isBool (enabled));
session->isPexEnabled = enabled != 0; session->isPexEnabled = enabled;
} }
bool bool
@ -2071,7 +2072,7 @@ tr_sessionSetDHTEnabled (tr_session * session, bool enabled)
assert (tr_isSession (session)); assert (tr_isSession (session));
assert (tr_isBool (enabled)); assert (tr_isBool (enabled));
if ((enabled != 0) != (session->isDHTEnabled != 0)) if (enabled != session->isDHTEnabled)
tr_runInEventThread (session, toggleDHTImpl, session); tr_runInEventThread (session, toggleDHTImpl, session);
} }
@ -2112,7 +2113,7 @@ tr_sessionSetUTPEnabled (tr_session * session, bool enabled)
assert (tr_isSession (session)); assert (tr_isSession (session));
assert (tr_isBool (enabled)); assert (tr_isBool (enabled));
if ((enabled != 0) != (session->isUTPEnabled != 0)) if (enabled != session->isUTPEnabled)
tr_runInEventThread (session, toggle_utp, session); tr_runInEventThread (session, toggle_utp, session);
} }
@ -2141,7 +2142,7 @@ tr_sessionSetLPDEnabled (tr_session * session, bool enabled)
assert (tr_isSession (session)); assert (tr_isSession (session));
assert (tr_isBool (enabled)); assert (tr_isBool (enabled));
if ((enabled != 0) != (session->isLPDEnabled != 0)) if (enabled != session->isLPDEnabled)
tr_runInEventThread (session, toggleLPDImpl, session); tr_runInEventThread (session, toggleLPDImpl, session);
} }
@ -2372,8 +2373,9 @@ tr_blocklistSetEnabled (tr_session * session, bool isEnabled)
tr_list * l; tr_list * l;
assert (tr_isSession (session)); assert (tr_isSession (session));
assert (tr_isBool (isEnabled));
session->isBlocklistEnabled = isEnabled != 0; session->isBlocklistEnabled = isEnabled;
for (l=session->blocklists; l!=NULL; l=l->next) for (l=session->blocklists; l!=NULL; l=l->next)
tr_blocklistFileSetEnabled (l->data, isEnabled); tr_blocklistFileSetEnabled (l->data, isEnabled);

View file

@ -253,8 +253,10 @@ tr_ctorInitTorrentWanted (const tr_ctor * ctor, tr_torrent * tor)
void void
tr_ctorSetDeleteSource (tr_ctor * ctor, bool deleteSource) tr_ctorSetDeleteSource (tr_ctor * ctor, bool deleteSource)
{ {
ctor->doDelete = deleteSource != 0; assert (tr_isBool (deleteSource));
ctor->isSet_delete = 1;
ctor->doDelete = deleteSource;
ctor->isSet_delete = true;
} }
int int
@ -277,7 +279,9 @@ tr_ctorGetDeleteSource (const tr_ctor * ctor, bool * setme)
void void
tr_ctorSetSave (tr_ctor * ctor, bool saveInOurTorrentsDir) tr_ctorSetSave (tr_ctor * ctor, bool saveInOurTorrentsDir)
{ {
ctor->saveInOurTorrentsDir = saveInOurTorrentsDir != 0; assert (tr_isBool (saveInOurTorrentsDir));
ctor->saveInOurTorrentsDir = saveInOurTorrentsDir;
} }
int int
@ -291,10 +295,15 @@ tr_ctorSetPaused (tr_ctor * ctor,
tr_ctorMode mode, tr_ctorMode mode,
bool isPaused) bool isPaused)
{ {
struct optional_args * args = &ctor->optionalArgs[mode]; struct optional_args * args;
args->isSet_paused = 1; assert (ctor != NULL);
args->isPaused = isPaused ? 1 : 0; assert ((mode == TR_FALLBACK) || (mode == TR_FORCE));
assert (tr_isBool (isPaused));
args = &ctor->optionalArgs[mode];
args->isSet_paused = true;
args->isPaused = isPaused;
} }
void void
@ -302,9 +311,13 @@ tr_ctorSetPeerLimit (tr_ctor * ctor,
tr_ctorMode mode, tr_ctorMode mode,
uint16_t peerLimit) uint16_t peerLimit)
{ {
struct optional_args * args = &ctor->optionalArgs[mode]; struct optional_args * args;
args->isSet_connected = 1; assert (ctor != NULL);
assert ((mode == TR_FALLBACK) || (mode == TR_FORCE));
args = &ctor->optionalArgs[mode];
args->isSet_connected = true;
args->peerLimit = peerLimit; args->peerLimit = peerLimit;
} }
@ -313,15 +326,19 @@ tr_ctorSetDownloadDir (tr_ctor * ctor,
tr_ctorMode mode, tr_ctorMode mode,
const char * directory) const char * directory)
{ {
struct optional_args * args = &ctor->optionalArgs[mode]; struct optional_args * args;
assert (ctor != NULL);
assert ((mode == TR_FALLBACK) || (mode == TR_FORCE));
args = &ctor->optionalArgs[mode];
tr_free (args->downloadDir); tr_free (args->downloadDir);
args->downloadDir = NULL; args->downloadDir = NULL;
args->isSet_downloadDir = 0; args->isSet_downloadDir = false;
if (directory && *directory) if (directory && *directory)
{ {
args->isSet_downloadDir = 1; args->isSet_downloadDir = true;
args->downloadDir = tr_strdup (directory); args->downloadDir = tr_strdup (directory);
} }
} }
@ -352,13 +369,13 @@ tr_ctorGetPeerLimit (const tr_ctor * ctor,
int int
tr_ctorGetPaused (const tr_ctor * ctor, tr_ctorMode mode, bool * setmeIsPaused) tr_ctorGetPaused (const tr_ctor * ctor, tr_ctorMode mode, bool * setmeIsPaused)
{ {
int err = 0; int err = 0;
const struct optional_args * args = &ctor->optionalArgs[mode]; const struct optional_args * args = &ctor->optionalArgs[mode];
if (!args->isSet_paused) if (!args->isSet_paused)
err = 1; err = 1;
else if (setmeIsPaused) else if (setmeIsPaused)
*setmeIsPaused = args->isPaused ? 1 : 0; *setmeIsPaused = args->isPaused;
return err; return err;
} }
@ -368,7 +385,7 @@ tr_ctorGetDownloadDir (const tr_ctor * ctor,
tr_ctorMode mode, tr_ctorMode mode,
const char ** setmeDownloadDir) const char ** setmeDownloadDir)
{ {
int err = 0; int err = 0;
const struct optional_args * args = &ctor->optionalArgs[mode]; const struct optional_args * args = &ctor->optionalArgs[mode];
if (!args->isSet_downloadDir) if (!args->isSet_downloadDir)