Changeset 14532


Ignore:
Timestamp:
May 31, 2015, 10:13:31 PM (5 years ago)
Author:
mikedld
Message:

Add more booleans to the picture

Location:
trunk
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/daemon/daemon.c

    r14503 r14532  
    202202        {
    203203            bool trash = false;
    204             int test = tr_ctorGetDeleteSource (ctor, &trash);
     204            const bool test = tr_ctorGetDeleteSource (ctor, &trash);
    205205
    206206            tr_logAddInfo ("Parsing .torrent file successful \"%s\"", file);
    207207
    208             if (!test && trash)
     208            if (test && trash)
    209209            {
    210210                tr_error * error = NULL;
  • trunk/gtk/open-dialog.c

    r14320 r14532  
    290290                                           -1);
    291291
    292   if (tr_ctorGetDownloadDir (ctor, TR_FORCE, &str))
     292  if (!tr_ctorGetDownloadDir (ctor, TR_FORCE, &str))
    293293    g_assert_not_reached ();
    294294  g_assert (str);
     
    376376  row++;
    377377  w = data->run_check;
    378   if (tr_ctorGetPaused (ctor, TR_FORCE, &flag))
     378  if (!tr_ctorGetPaused (ctor, TR_FORCE, &flag))
    379379    g_assert_not_reached ();
    380380  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w), !flag);
     
    384384  row++;
    385385  w = data->trash_check;
    386   if (tr_ctorGetDeleteSource (ctor, &flag))
     386  if (!tr_ctorGetDeleteSource (ctor, &flag))
    387387    g_assert_not_reached ();
    388388  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w), flag);
  • trunk/gtk/tr-core.c

    r14526 r14532  
    11721172core_apply_defaults (tr_ctor * ctor)
    11731173{
    1174   if (tr_ctorGetPaused (ctor, TR_FORCE, NULL))
     1174  if (!tr_ctorGetPaused (ctor, TR_FORCE, NULL))
    11751175    tr_ctorSetPaused (ctor, TR_FORCE, !gtr_pref_flag_get (TR_KEY_start_added_torrents));
    11761176
    1177   if (tr_ctorGetDeleteSource (ctor, NULL))
     1177  if (!tr_ctorGetDeleteSource (ctor, NULL))
    11781178    tr_ctorSetDeleteSource (ctor, gtr_pref_flag_get (TR_KEY_trash_original_torrent_files));
    11791179
    1180   if (tr_ctorGetPeerLimit (ctor, TR_FORCE, NULL))
     1180  if (!tr_ctorGetPeerLimit (ctor, TR_FORCE, NULL))
    11811181    tr_ctorSetPeerLimit (ctor, TR_FORCE, gtr_pref_int_get (TR_KEY_peer_limit_per_torrent));
    11821182
    1183   if (tr_ctorGetDownloadDir (ctor, TR_FORCE, NULL))
     1183  if (!tr_ctorGetDownloadDir (ctor, TR_FORCE, NULL))
    11841184    tr_ctorSetDownloadDir (ctor, TR_FORCE, gtr_pref_string_get (TR_KEY_download_dir));
    11851185}
  • trunk/libtransmission/bandwidth.c

    r14354 r14532  
    347347  return byteCount;
    348348}
     349
    349350unsigned int
    350351tr_bandwidthClamp (const tr_bandwidth  * b,
  • trunk/libtransmission/bitfield.c

    r14526 r14532  
    147147***/
    148148
     149#ifndef NDEBUG
     150
    149151static bool
    150 tr_bitfieldIsValid (const tr_bitfield * b UNUSED)
     152tr_bitfieldIsValid (const tr_bitfield * b)
    151153{
    152154  assert (b != NULL);
     
    156158  return true;
    157159}
     160
     161#endif
    158162
    159163size_t
  • trunk/libtransmission/cache.c

    r14476 r14532  
    454454    }
    455455
    456     return err;
     456  return err;
    457457}
    458458
  • trunk/libtransmission/natpmp.c

    r14479 r14532  
    9999}
    100100
    101 static int
     101static bool
    102102canSendCommand (const struct tr_natpmp * nat)
    103103{
  • trunk/libtransmission/platform.c

    r14491 r14532  
    193193}
    194194
    195 int
     195bool
    196196tr_lockHave (const tr_lock * l)
    197197{
  • trunk/libtransmission/platform.h

    r14327 r14532  
    7676
    7777/** @brief return nonzero if the specified lock is locked */
    78 int tr_lockHave (const tr_lock *);
     78bool tr_lockHave (const tr_lock *);
    7979
    8080/* @} */
  • trunk/libtransmission/resume.c

    r14491 r14532  
    7878    }
    7979
    80     return numAdded;
     80  return numAdded;
    8181}
    8282
     
    873873      bool isPaused;
    874874
    875       if (!tr_ctorGetPaused (ctor, mode, &isPaused))
     875      if (tr_ctorGetPaused (ctor, mode, &isPaused))
    876876        {
    877877          tor->isRunning = !isPaused;
     
    881881
    882882  if (fields & TR_FR_MAX_PEERS)
    883     if (!tr_ctorGetPeerLimit (ctor, mode, &tor->maxConnectedPeers))
     883    if (tr_ctorGetPeerLimit (ctor, mode, &tor->maxConnectedPeers))
    884884      ret |= TR_FR_MAX_PEERS;
    885885
     
    888888      const char * path;
    889889
    890       if (!tr_ctorGetDownloadDir (ctor, mode, &path) && path && *path)
     890      if (tr_ctorGetDownloadDir (ctor, mode, &path) && path && *path)
    891891        {
    892892          ret |= TR_FR_DOWNLOAD_DIR;
  • trunk/libtransmission/torrent-ctor.c

    r14491 r14532  
    259259}
    260260
    261 int
     261bool
    262262tr_ctorGetDeleteSource (const tr_ctor * ctor, bool * setme)
    263263{
    264     int err = 0;
     264    bool ret = true;
    265265
    266266    if (!ctor->isSet_delete)
    267         err = 1;
     267        ret = false;
    268268    else if (setme)
    269         *setme = ctor->doDelete ? 1 : 0;
    270 
    271     return err;
     269        *setme = ctor->doDelete;
     270
     271    return ret;
    272272}
    273273
     
    284284}
    285285
    286 int
     286bool
    287287tr_ctorGetSave (const tr_ctor * ctor)
    288288{
     
    350350}
    351351
    352 int
     352bool
    353353tr_ctorGetPeerLimit (const tr_ctor * ctor,
    354354                     tr_ctorMode     mode,
    355355                     uint16_t *      setmeCount)
    356356{
    357     int err = 0;
     357    bool ret = true;
    358358    const struct optional_args * args = &ctor->optionalArgs[mode];
    359359
    360360    if (!args->isSet_connected)
    361         err = 1;
     361        ret = false;
    362362    else if (setmeCount)
    363363        *setmeCount = args->peerLimit;
    364364
    365     return err;
    366 }
    367 
    368 int
     365    return ret;
     366}
     367
     368bool
    369369tr_ctorGetPaused (const tr_ctor * ctor, tr_ctorMode mode, bool * setmeIsPaused)
    370370{
    371     int err = 0;
     371    bool ret = true;
    372372    const struct optional_args * args = &ctor->optionalArgs[mode];
    373373
    374374    if (!args->isSet_paused)
    375         err = 1;
     375        ret = false;
    376376    else if (setmeIsPaused)
    377377        *setmeIsPaused = args->isPaused;
    378378
    379     return err;
    380 }
    381 
    382 int
     379    return ret;
     380}
     381
     382bool
    383383tr_ctorGetDownloadDir (const tr_ctor * ctor,
    384384                       tr_ctorMode     mode,
    385385                       const char **   setmeDownloadDir)
    386386{
    387     int err = 0;
     387    bool ret = true;
    388388    const struct optional_args * args = &ctor->optionalArgs[mode];
    389389
    390390    if (!args->isSet_downloadDir)
    391         err = 1;
     391        ret = false;
    392392    else if (setmeDownloadDir)
    393393        *setmeDownloadDir = args->downloadDir;
    394394
    395     return err;
    396 }
    397 
    398 int
     395    return ret;
     396}
     397
     398bool
    399399tr_ctorGetIncompleteDir (const tr_ctor  * ctor,
    400400                         const char    ** setmeIncompleteDir)
    401401{
    402     int err = 0;
     402    bool ret = true;
    403403
    404404    if (ctor->incompleteDir == NULL)
    405         err = 1;
     405        ret = false;
    406406    else
    407407        *setmeIncompleteDir = ctor->incompleteDir;
    408408
    409     return err;
    410 }
    411 
    412 int
     409    return ret;
     410}
     411
     412bool
    413413tr_ctorGetMetainfo (const tr_ctor *  ctor,
    414414                    const tr_variant ** setme)
    415415{
    416     int err = 0;
     416    bool ret = true;
    417417
    418418    if (!ctor->isSet_metainfo)
    419         err = 1;
     419        ret = false;
    420420    else if (setme)
    421421        *setme = &ctor->metainfo;
    422422
    423     return err;
     423    return ret;
    424424}
    425425
  • trunk/libtransmission/torrent-magnet.c

    r14525 r14532  
    193193    }
    194194
    195     assert (ret == NULL || *len > 0);
    196 
    197     return ret;
     195  assert (ret == NULL || *len > 0);
     196
     197  return ret;
    198198}
    199199
  • trunk/libtransmission/torrent.c

    r14530 r14532  
    633633}
    634634
    635 static int
     635static bool
    636636pieceHasFile (tr_piece_index_t piece,
    637637              const tr_file *  file)
     
    873873           NULL);
    874874
    875   if (!tr_ctorGetDownloadDir (ctor, TR_FORCE, &dir) ||
    876     !tr_ctorGetDownloadDir (ctor, TR_FALLBACK, &dir))
    877       tor->downloadDir = tr_strdup (dir);
    878 
    879   if (tr_ctorGetIncompleteDir (ctor, &dir))
     875  if (tr_ctorGetDownloadDir (ctor, TR_FORCE, &dir) ||
     876      tr_ctorGetDownloadDir (ctor, TR_FALLBACK, &dir))
     877    tor->downloadDir = tr_strdup (dir);
     878
     879  if (!tr_ctorGetIncompleteDir (ctor, &dir))
    880880    dir = tr_sessionGetIncompleteDir (session);
    881881  if (tr_sessionIsIncompleteDirEnabled (session))
     
    953953    {
    954954      const tr_variant * val;
    955       if (!tr_ctorGetMetainfo (ctor, &val))
     955      if (tr_ctorGetMetainfo (ctor, &val))
    956956        {
    957957          const char * path = tor->info.torrent;
     
    997997  memset (setmeInfo, 0, sizeof (tr_info));
    998998
    999   if (tr_ctorGetMetainfo (ctor, &metainfo))
     999  if (!tr_ctorGetMetainfo (ctor, &metainfo))
    10001000    return TR_PARSE_ERR;
    10011001
  • trunk/libtransmission/torrent.h

    r14428 r14532  
    3232                            bool      saveMetadataInOurTorrentsDir);
    3333
    34 int         tr_ctorGetSave (const tr_ctor * ctor);
     34bool        tr_ctorGetSave (const tr_ctor * ctor);
    3535
    3636void        tr_ctorInitTorrentPriorities (const tr_ctor * ctor, tr_torrent * tor);
  • trunk/libtransmission/tr-dht.c

    r14491 r14532  
    7878};
    7979
    80 static int
     80static bool
    8181bootstrap_done (tr_session *session, int af)
    8282{
     
    461461}
    462462
    463 int
     463bool
    464464tr_dhtAddNode (tr_session       * ss,
    465465               const tr_address * address,
     
    470470
    471471    if (!tr_dhtEnabled (ss))
    472         return 0;
     472        return false;
    473473
    474474    /* Since we don't want to abuse our bootstrap nodes,
     
    477477    if (bootstrap) {
    478478        if (tr_dhtStatus (ss, af, NULL) >= TR_DHT_FIREWALLED)
    479             return 0;
     479            return false;
    480480    }
    481481
     
    487487        sin.sin_port = htons (port);
    488488        dht_ping_node ((struct sockaddr*)&sin, sizeof (sin));
    489         return 1;
     489        return true;
    490490    } else if (address->type == TR_AF_INET6) {
    491491        struct sockaddr_in6 sin6;
     
    495495        sin6.sin6_port = htons (port);
    496496        dht_ping_node ((struct sockaddr*)&sin6, sizeof (sin6));
    497         return 1;
    498     }
    499 
    500     return 0;
     497        return true;
     498    }
     499
     500    return false;
    501501}
    502502
  • trunk/libtransmission/tr-dht.h

    r13625 r14532  
    4343int tr_dhtStatus (tr_session *, int af, int * setme_nodeCount);
    4444const char *tr_dhtPrintableStatus (int status);
    45 int tr_dhtAddNode (tr_session *, const tr_address *, tr_port, bool bootstrap);
     45bool tr_dhtAddNode (tr_session *, const tr_address *, tr_port, bool bootstrap);
    4646void tr_dhtUpkeep (tr_session *);
    4747void tr_dhtCallback (unsigned char *buf, int buflen,
  • trunk/libtransmission/tr-lpd.c

    r14526 r14532  
    212212*   - copy back value from end to next "\r\n"
    213213*/
    214 static int lpd_extractParam (const char* const str, const char* const name, int n, char* const val)
     214static bool lpd_extractParam (const char* const str, const char* const name, int n, char* const val)
    215215{
    216216    /* configure maximum length of search string here */
     
    223223
    224224    if (strlen (name) > maxLength - strlen (CRLF ": "))
    225         return 0;
     225        return false;
    226226
    227227    /* compose the string token to search for */
     
    230230    pos = strstr (str, sstr);
    231231    if (pos == NULL)
    232         return 0; /* search was not successful */
     232        return false; /* search was not successful */
    233233
    234234    {
     
    249249
    250250    /* we successfully returned the value string */
    251     return 1;
     251    return true;
    252252}
    253253
     
    513513        /* save the effort to check Host, which seems to be optional anyway */
    514514
    515         if (lpd_extractParam (params, "Port", maxValueLen, value) == 0)
     515        if (!lpd_extractParam (params, "Port", maxValueLen, value))
    516516            return 0;
    517517
     
    523523        res = -1; /* signal caller side-effect to peer->port via return != 0 */
    524524
    525         if (lpd_extractParam (params, "Infohash", maxHashLen, hashString) == 0)
     525        if (!lpd_extractParam (params, "Infohash", maxHashLen, hashString))
    526526            return res;
    527527
  • trunk/libtransmission/transmission.h

    r14384 r14532  
    10121012
    10131013/** @brief Get this peer constructor's peer limit */
    1014 int         tr_ctorGetPeerLimit (const tr_ctor * ctor,
     1014bool        tr_ctorGetPeerLimit (const tr_ctor * ctor,
    10151015                                 tr_ctorMode     mode,
    10161016                                 uint16_t *      setmeCount);
    10171017
    10181018/** @brief Get the "isPaused" flag from this peer constructor */
    1019 int         tr_ctorGetPaused (const tr_ctor * ctor,
     1019bool        tr_ctorGetPaused (const tr_ctor * ctor,
    10201020                              tr_ctorMode     mode,
    10211021                              bool          * setmeIsPaused);
    10221022
    10231023/** @brief Get the download path from this peer constructor */
    1024 int         tr_ctorGetDownloadDir (const tr_ctor  * ctor,
     1024bool        tr_ctorGetDownloadDir (const tr_ctor  * ctor,
    10251025                                   tr_ctorMode      mode,
    10261026                                   const char    ** setmeDownloadDir);
    10271027
    10281028/** @brief Get the incomplete directory from this peer constructor */
    1029 int         tr_ctorGetIncompleteDir (const tr_ctor  * ctor,
     1029bool        tr_ctorGetIncompleteDir (const tr_ctor  * ctor,
    10301030                                     const char    ** setmeIncompleteDir);
    10311031
    10321032/** @brief Get the metainfo from this peer constructor */
    1033 int         tr_ctorGetMetainfo (const tr_ctor            * ctor,
     1033bool        tr_ctorGetMetainfo (const tr_ctor            * ctor,
    10341034                                const struct tr_variant ** setme);
    10351035
    10361036/** @brief Get the "delete .torrent file" flag from this peer constructor */
    1037 int         tr_ctorGetDeleteSource (const tr_ctor  * ctor,
     1037bool        tr_ctorGetDeleteSource (const tr_ctor  * ctor,
    10381038                                    bool           * setmeDoDelete);
    10391039
  • trunk/libtransmission/web.c

    r14480 r14532  
    639639}
    640640
    641 static int
     641static bool
    642642is_rfc2396_alnum (uint8_t ch)
    643643{
Note: See TracChangeset for help on using the changeset viewer.