Changeset 14172


Ignore:
Timestamp:
Aug 24, 2013, 6:08:38 PM (8 years ago)
Author:
jordan
Message:

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

Location:
trunk/libtransmission
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/peer-io.c

    r13868 r14172  
    625625    io->socket = socket;
    626626    io->utp_socket = utp_socket;
    627     io->isIncoming = isIncoming != 0;
     627    io->isIncoming = isIncoming;
    628628    io->timeCreated = tr_time ();
    629629    io->inbuf = evbuffer_new ();
     
    10521052    struct tr_datatype * d;
    10531053    d = datatype_new ();
    1054     d->isPieceData = isPieceData != 0;
     1054    d->isPieceData = isPieceData;
    10551055    d->length = byteCount;
    10561056    peer_io_push_datatype (io, d);
  • trunk/libtransmission/rpc-server.c

    r14171 r14172  
    844844                           bool             isEnabled)
    845845{
    846   server->isWhitelistEnabled = isEnabled != 0;
     846  assert (tr_isBool (isEnabled));
     847
     848  server->isWhitelistEnabled = isEnabled;
    847849}
    848850
  • trunk/libtransmission/session.c

    r14171 r14172  
    20292029{
    20302030  assert (tr_isSession (session));
    2031 
    2032   session->isPexEnabled = enabled != 0;
     2031  assert (tr_isBool (enabled));
     2032
     2033  session->isPexEnabled = enabled;
    20332034}
    20342035
     
    20722073  assert (tr_isBool (enabled));
    20732074
    2074   if ((enabled != 0) != (session->isDHTEnabled != 0))
     2075  if (enabled != session->isDHTEnabled)
    20752076    tr_runInEventThread (session, toggleDHTImpl, session);
    20762077}
     
    21132114  assert (tr_isBool (enabled));
    21142115
    2115   if ((enabled != 0) != (session->isUTPEnabled != 0))
     2116  if (enabled != session->isUTPEnabled)
    21162117    tr_runInEventThread (session, toggle_utp, session);
    21172118}
     
    21422143  assert (tr_isBool (enabled));
    21432144
    2144   if ((enabled != 0) != (session->isLPDEnabled != 0))
     2145  if (enabled != session->isLPDEnabled)
    21452146    tr_runInEventThread (session, toggleLPDImpl, session);
    21462147}
     
    23732374
    23742375  assert (tr_isSession (session));
    2375 
    2376   session->isBlocklistEnabled = isEnabled != 0;
     2376  assert (tr_isBool (isEnabled));
     2377
     2378  session->isBlocklistEnabled = isEnabled;
    23772379
    23782380  for (l=session->blocklists; l!=NULL; l=l->next)
  • trunk/libtransmission/torrent-ctor.c

    r13991 r14172  
    254254tr_ctorSetDeleteSource (tr_ctor * ctor, bool deleteSource)
    255255{
    256     ctor->doDelete = deleteSource != 0;
    257     ctor->isSet_delete = 1;
     256    assert (tr_isBool (deleteSource));
     257
     258    ctor->doDelete = deleteSource;
     259    ctor->isSet_delete = true;
    258260}
    259261
     
    278280tr_ctorSetSave (tr_ctor * ctor, bool saveInOurTorrentsDir)
    279281{
    280     ctor->saveInOurTorrentsDir = saveInOurTorrentsDir != 0;
     282    assert (tr_isBool (saveInOurTorrentsDir));
     283
     284    ctor->saveInOurTorrentsDir = saveInOurTorrentsDir;
    281285}
    282286
     
    292296                  bool        isPaused)
    293297{
    294     struct optional_args * args = &ctor->optionalArgs[mode];
    295 
    296     args->isSet_paused = 1;
    297     args->isPaused = isPaused ? 1 : 0;
     298    struct optional_args * args;
     299
     300    assert (ctor != NULL);
     301    assert ((mode == TR_FALLBACK) || (mode == TR_FORCE));
     302    assert (tr_isBool (isPaused));
     303
     304    args = &ctor->optionalArgs[mode];
     305    args->isSet_paused = true;
     306    args->isPaused = isPaused;
    298307}
    299308
     
    303312                     uint16_t    peerLimit)
    304313{
    305     struct optional_args * args = &ctor->optionalArgs[mode];
    306 
    307     args->isSet_connected = 1;
     314    struct optional_args * args;
     315
     316    assert (ctor != NULL);
     317    assert ((mode == TR_FALLBACK) || (mode == TR_FORCE));
     318
     319    args = &ctor->optionalArgs[mode];
     320    args->isSet_connected = true;
    308321    args->peerLimit = peerLimit;
    309322}
     
    314327                       const char * directory)
    315328{
    316     struct optional_args * args = &ctor->optionalArgs[mode];
    317 
     329    struct optional_args * args;
     330
     331    assert (ctor != NULL);
     332    assert ((mode == TR_FALLBACK) || (mode == TR_FORCE));
     333
     334    args = &ctor->optionalArgs[mode];
    318335    tr_free (args->downloadDir);
    319336    args->downloadDir = NULL;
    320     args->isSet_downloadDir = 0;
     337    args->isSet_downloadDir = false;
    321338
    322339    if (directory && *directory)
    323340    {
    324         args->isSet_downloadDir = 1;
     341        args->isSet_downloadDir = true;
    325342        args->downloadDir = tr_strdup (directory);
    326343    }
     
    353370tr_ctorGetPaused (const tr_ctor * ctor, tr_ctorMode mode, bool * setmeIsPaused)
    354371{
    355     int                          err = 0;
     372    int err = 0;
    356373    const struct optional_args * args = &ctor->optionalArgs[mode];
    357374
     
    359376        err = 1;
    360377    else if (setmeIsPaused)
    361         *setmeIsPaused = args->isPaused ? 1 : 0;
     378        *setmeIsPaused = args->isPaused;
    362379
    363380    return err;
     
    369386                       const char **   setmeDownloadDir)
    370387{
    371     int                          err = 0;
     388    int err = 0;
    372389    const struct optional_args * args = &ctor->optionalArgs[mode];
    373390
Note: See TracChangeset for help on using the changeset viewer.