]> granicus.if.org Git - transmission/commitdiff
more treating-bools-as-bools
authorJordan Lee <jordan@transmissionbt.com>
Sat, 24 Aug 2013 18:18:38 +0000 (18:18 +0000)
committerJordan Lee <jordan@transmissionbt.com>
Sat, 24 Aug 2013 18:18:38 +0000 (18:18 +0000)
libtransmission/blocklist.c
libtransmission/cache.c
libtransmission/makemeta.c
libtransmission/makemeta.h
libtransmission/torrent-ctor.c
libtransmission/torrent.c

index 994070296501e1331bfae1ceb5f7dbeec95ec520..72894891824425f2b9b9941948dedd95fda9cb54 100644 (file)
@@ -198,7 +198,10 @@ tr_blocklistFileIsEnabled (tr_blocklistFile * b)
 void
 tr_blocklistFileSetEnabled (tr_blocklistFile * b, bool isEnabled)
 {
-  b->isEnabled = isEnabled ? 1 : 0;
+  assert (b != NULL);
+  assert (tr_isBool (isEnabled));
+
+  b->isEnabled = isEnabled;
 }
 
 int
index 3df155c1a3bde09ccf48b81f544499dd020fd338..e80ca5daba3b82b34b30e15377d6645ef08efd94 100644 (file)
@@ -106,7 +106,7 @@ getBlockRun (const tr_cache * cache, int pos, struct run_info * info)
       const struct cache_block * b = blocks[i-1];
       info->last_block_time = b->time;
       info->is_piece_done = tr_torrentPieceIsComplete (b->tor, b->piece);
-      info->is_multi_piece = b->piece != blocks[pos]->piece ? true : false;
+      info->is_multi_piece = b->piece != blocks[pos]->piece;
       info->len = i - pos;
       info->pos = pos;
     }
index 41dd1730eff0adea31082a1d7ff29b7fb17446c3..9460bb366c4d738aef007628e0744b937a7390b1 100644 (file)
@@ -449,7 +449,7 @@ tr_realMakeMetaInfo (tr_metainfo_builder * builder)
   tr_variantFree (&top);
   if (builder->abortFlag)
     builder->result = TR_MAKEMETA_CANCELLED;
-  builder->isDone = 1;
+  builder->isDone = true;
 }
 
 /***
@@ -506,11 +506,13 @@ tr_makeMetaInfo (tr_metainfo_builder   * builder,
                  const tr_tracker_info * trackers,
                  int                     trackerCount,
                  const char            * comment,
-                 int                     isPrivate)
+                 bool                    isPrivate)
 {
   int i;
   tr_lock * lock;
 
+  assert (tr_isBool (isPrivate));
+
   /* free any variables from a previous run */
   for (i=0; i<builder->trackerCount; ++i)
     tr_free (builder->trackers[i].announce);
@@ -519,9 +521,9 @@ tr_makeMetaInfo (tr_metainfo_builder   * builder,
   tr_free (builder->outputFile);
 
   /* initialize the builder variables */
-  builder->abortFlag = 0;
+  builder->abortFlag = false;
   builder->result = 0;
-  builder->isDone = 0;
+  builder->isDone = false;
   builder->pieceIndex = 0;
   builder->trackerCount = trackerCount;
   builder->trackers = tr_new0 (tr_tracker_info, builder->trackerCount);
index a54c244a9d1ec8c3eebcfbabb0fee557b6eb4ea6..8ed34db14b15e80de1091be46b4585e4ec432f93 100644 (file)
@@ -60,7 +60,7 @@ typedef struct tr_metainfo_builder
     int                trackerCount;
     char *             comment;
     char *             outputFile;
-    int                isPrivate;
+    bool               isPrivate;
 
     /**
     ***  These are set inside tr_makeMetaInfo () so the client
@@ -70,8 +70,8 @@ typedef struct tr_metainfo_builder
     **/
 
     uint32_t                   pieceIndex;
-    int                        abortFlag;
-    int                        isDone;
+    bool                       abortFlag;
+    bool                       isDone;
     tr_metainfo_builder_err    result;
 
     /* file in use when result was set to _IO_READ or _IO_WRITE,
@@ -124,7 +124,7 @@ void tr_makeMetaInfo (tr_metainfo_builder *   builder,
                       const tr_tracker_info * trackers,
                       int                     trackerCount,
                       const char *            comment,
-                      int                     isPrivate);
+                      bool                    isPrivate);
 
 
 #ifdef __cplusplus
index fe45ed919cbfd0739bef9ef2c58a3c23ed0b2c0a..b64bde872a0646238de86c3753c962c57df9ee83 100644 (file)
@@ -40,7 +40,7 @@ struct tr_ctor
     tr_priority_t           bandwidthPriority;
     bool                    isSet_metainfo;
     bool                    isSet_delete;
-    tr_variant                 metainfo;
+    tr_variant              metainfo;
     char *                  sourceFile;
 
     struct optional_args    optionalArgs[2];
@@ -77,7 +77,7 @@ clearMetainfo (tr_ctor * ctor)
 {
     if (ctor->isSet_metainfo)
     {
-        ctor->isSet_metainfo = 0;
+        ctor->isSet_metainfo = false;
         tr_variantFree (&ctor->metainfo);
     }
 
index cca3e063b82f8007cce87c867e17e7fba4c4dfa8..4b73e6228d6722c809be2242562bb7bda69c9785 100644 (file)
@@ -853,7 +853,7 @@ setLocalErrorIfFilesDisappeared (tr_torrent * tor)
 static void
 torrentInit (tr_torrent * tor, const tr_ctor * ctor)
 {
-  int doStart;
+  bool doStart;
   uint64_t loaded;
   const char * dir;
   bool isNewTorrent;
@@ -910,7 +910,7 @@ torrentInit (tr_torrent * tor, const tr_ctor * ctor)
   refreshCurrentDir (tor);
 
   doStart = tor->isRunning;
-  tor->isRunning = 0;
+  tor->isRunning = false;
 
   if (!(loaded & TR_FR_SPEEDLIMIT))
     {
@@ -1886,8 +1886,8 @@ tr_torrentStop (tr_torrent * tor)
     {
       tr_sessionLock (tor->session);
 
-      tor->isRunning = 0;
-      tor->isStopping = 0;
+      tor->isRunning = false;
+      tor->isStopping = false;
       tr_torrentSetDirty (tor);
       tr_runInEventThread (tor->session, stopTorrent, tor);
 
@@ -1917,7 +1917,7 @@ closeTorrent (void * vtor)
       tr_torrentRemoveResume (tor);
     }
 
-  tor->isRunning = 0;
+  tor->isRunning = false;
   freeTorrent (tor);
 }