]> granicus.if.org Git - transmission/commitdiff
Fix a number of other style inconsistencies met along the way
authorMike Gelfand <mikedld@mikedld.com>
Sun, 30 Apr 2017 16:30:03 +0000 (19:30 +0300)
committerMike Gelfand <mikedld@mikedld.com>
Sun, 30 Apr 2017 16:33:55 +0000 (19:33 +0300)
35 files changed:
daemon/remote.c
gtk/tr-core.c
gtk/util.c
libtransmission/announcer-udp.c
libtransmission/announcer.c
libtransmission/bandwidth.c
libtransmission/bitfield.c
libtransmission/completion.c
libtransmission/handshake.c
libtransmission/history.h
libtransmission/log.c
libtransmission/magnet.c
libtransmission/peer-io.c
libtransmission/peer-mgr.c
libtransmission/peer-msgs.c
libtransmission/platform-quota.c
libtransmission/ptrarray.c
libtransmission/resume.c
libtransmission/rpc-server.c
libtransmission/rpcimpl.c
libtransmission/session-id.c
libtransmission/session.c
libtransmission/torrent.c
libtransmission/trevent.c
libtransmission/utils.c
libtransmission/utils.h
libtransmission/variant-json.c
libtransmission/variant.c
libtransmission/web.c
libtransmission/webseed.c
qt/DetailsDialog.cc
qt/FilterBar.cc
qt/MainWindow.cc
qt/TrackerDelegate.cc
utils/edit.c

index 16b06a7ffd088ae6e94ec8bdfedb522a7ca71f81..4df6bb6e69760de5dbb7c6780f8f797b5ddd1578 100644 (file)
@@ -827,7 +827,7 @@ static char* getStatusString(tr_variant* t, char* buf, size_t buflen)
 
                 if (tr_variantDictFindReal(t, TR_KEY_recheckProgress, &percent))
                 {
-                    tr_snprintf(buf, buflen, "%s (%.0f%%)", str, floor(percent * 100.0));
+                    tr_snprintf(buf, buflen, "%s (%.0f%%)", str, (floor)(percent * 100.0));
                 }
                 else
                 {
@@ -1252,7 +1252,7 @@ static void printFileList(tr_variant* top)
                             break;
                         }
 
-                        printf("%3d: %3.0f%% %-8s %-3s %9s  %s\n", j, floor(100.0 * percent), pristr, wanted ? "Yes" : "No",
+                        printf("%3d: %3.0f%% %-8s %-3s %9s  %s\n", j, (floor)(100.0 * percent), pristr, wanted ? "Yes" : "No",
                             sizestr, filename);
                     }
                 }
index b504bf41a2a88303bb87b5b751fda2132b1d5087..4b30a01f518f209bf24eaa0625d6575b57f2e913 100644 (file)
@@ -1778,7 +1778,7 @@ static void core_read_rpc_response(tr_session* session UNUSED, tr_variant* respo
     gdk_threads_add_idle(core_read_rpc_response_idle, response_copy);
 }
 
-static void core_send_rpc_request(TrCore* core, tr_variant const* request, int tag, server_response_func* response_func,
+static void core_send_rpc_request(TrCore* core, tr_variant const* request, int tag, server_response_func response_func,
     void* response_func_user_data)
 {
     tr_session* session = gtr_core_session(core);
index 421ea8f984c61ad8d4857528478a811b4e8ac461..fb9b70bba1b637da095a2c5ca48a03c0a35e1f0b 100644 (file)
@@ -272,7 +272,7 @@ void gtr_add_torrent_error_dialog(GtkWidget* child, int err, tr_torrent* duplica
     g_free(secondary);
 }
 
-typedef void (PopupFunc)(GtkWidget*, GdkEventButton*);
+typedef void (PopupFunc)(GtkWidget*, GdkEventButton*);
 
 /* pop up the context menu if a user right-clicks.
    if the row they right-click on isn't selected, select it. */
@@ -299,7 +299,7 @@ gboolean on_tree_view_button_pressed(GtkWidget* view, GdkEventButton* event, gpo
 
         if (func != NULL)
         {
-            ((PopupFunc*)func)(view, event);
+            (*(PopupFunc)func)(view, event);
         }
 
         return TRUE;
index c24bc50f7847870a8bdb5bbdb7565357541da84b..026733fce3687776d138196097c7f77beb0368a3 100644 (file)
@@ -531,7 +531,7 @@ static void tau_tracker_on_dns(int errcode, struct evutil_addrinfo* addr, void*
     {
         dbgmsg(tracker->key, "DNS lookup succeeded");
         tracker->addr = addr;
-        tracker->addr_expiration_time = tr_time() + (60 * 60); /* one hour */
+        tracker->addr_expiration_time = tr_time() + 60 * 60; /* one hour */
         tau_tracker_upkeep(tracker);
     }
 }
@@ -940,7 +940,7 @@ bool tau_handle_message(tr_session* session, uint8_t const* msg, size_t msglen)
     tau = session->announcer_udp;
     transaction_id = evbuffer_read_ntoh_32(buf);
 
-    /*fprintf(stderr, "UDP got a transaction_id %u...\n", transaction_id);*/
+    /* fprintf(stderr, "UDP got a transaction_id %u...\n", transaction_id); */
     for (i = 0, n = tr_ptrArraySize(&tau->trackers); i < n; ++i)
     {
         int j, jn;
index fbed5663d35e2e3b2dbaca23e8001ce613d1a4a8..bb88ab9a4b4f1a4d1fef2601869ef5bb322d4bc5 100644 (file)
@@ -1000,19 +1000,19 @@ static int getRetryInterval(tr_tracker const* t)
         return 20;
 
     case 2:
-        return tr_rand_int_weak(60) + (60 * 5);
+        return tr_rand_int_weak(60) + 60 * 5;
 
     case 3:
-        return tr_rand_int_weak(60) + (60 * 15);
+        return tr_rand_int_weak(60) + 60 * 15;
 
     case 4:
-        return tr_rand_int_weak(60) + (60 * 30);
+        return tr_rand_int_weak(60) + 60 * 30;
 
     case 5:
-        return tr_rand_int_weak(60) + (60 * 60);
+        return tr_rand_int_weak(60) + 60 * 60;
 
     default:
-        return tr_rand_int_weak(60) + (60 * 120);
+        return tr_rand_int_weak(60) + 60 * 120;
     }
 }
 
index 61a096c992780f082babc7a2999f25f72f490dff..4ac089019e2de7f10cce44924ad7567341c1dc83 100644 (file)
@@ -64,7 +64,7 @@ static unsigned int getSpeed_Bps(struct bratecontrol const* r, unsigned int inte
             }
         }
 
-        rvolatile->cache_val = (unsigned int)((bytes * 1000u) / interval_msec);
+        rvolatile->cache_val = (unsigned int)(bytes * 1000u / interval_msec);
         rvolatile->cache_time = now;
     }
 
index 92cf7a583507bdb5190b28d1ce32c439d8aabaa0..e480e8b1d2d06861767c97db8fe298af1ad48097 100644 (file)
@@ -373,7 +373,7 @@ void tr_bitfieldSetRaw(tr_bitfield* b, void const* bits, size_t byte_count, bool
 
         if (excess_bit_count)
         {
-            b->bits[b->alloc_count - 1] &= ((0xff) << excess_bit_count);
+            b->bits[b->alloc_count - 1] &= 0xff << excess_bit_count;
         }
     }
 
@@ -404,7 +404,7 @@ void tr_bitfieldAdd(tr_bitfield* b, size_t nth)
 {
     if (!tr_bitfieldHas(b, nth) && tr_bitfieldEnsureNthBitAlloced(b, nth))
     {
-        b->bits[nth >> 3u] |= (0x80 >> (nth & 7u));
+        b->bits[nth >> 3u] |= 0x80 >> (nth & 7u);
         tr_bitfieldIncTrueCount(b, 1);
     }
 }
@@ -440,7 +440,7 @@ void tr_bitfieldAddRange(tr_bitfield* b, size_t begin, size_t end)
 
     if (sb == eb)
     {
-        b->bits[sb] |= (sm & em);
+        b->bits[sb] |= sm & em;
     }
     else
     {
@@ -462,7 +462,7 @@ void tr_bitfieldRem(tr_bitfield* b, size_t nth)
 
     if (tr_bitfieldHas(b, nth) && tr_bitfieldEnsureNthBitAlloced(b, nth))
     {
-        b->bits[nth >> 3u] &= (0xff7f >> (nth & 7u));
+        b->bits[nth >> 3u] &= 0xff7f >> (nth & 7u);
         tr_bitfieldDecTrueCount(b, 1);
     }
 }
@@ -498,7 +498,7 @@ void tr_bitfieldRemRange(tr_bitfield* b, size_t begin, size_t end)
 
     if (sb == eb)
     {
-        b->bits[sb] &= (sm | em);
+        b->bits[sb] &= sm | em;
     }
     else
     {
index 159afbd073a3db479d410a8cfc6a0a93b785a74a..a1a55dbd65a15a2555bc55d221186989a6712aed 100644 (file)
@@ -188,7 +188,7 @@ uint64_t tr_cpSizeWhenDone(tr_completion const* ccp)
 
                     if (l == cp->tor->blockCount - 1 && tr_bitfieldHas(&cp->blockBitfield, l))
                     {
-                        n -= (cp->tor->blockSize - cp->tor->lastBlockSize);
+                        n -= cp->tor->blockSize - cp->tor->lastBlockSize;
                     }
                 }
 
index dc0c7a66acc726ce0bf92f061b89be8fc5622025..4f16737334323b9a5fff390969fefb1d6c3c4b65 100644 (file)
@@ -788,7 +788,7 @@ static ReadState readYa(tr_handshake* handshake, struct evbuffer* inbuf)
 
 static ReadState readPadA(tr_handshake* handshake, struct evbuffer* inbuf)
 {
-    /* resynchronizing on HASH('req1',S) */
+    /* resynchronizing on HASH('req1', S) */
     struct evbuffer_ptr ptr = evbuffer_search(inbuf, (char const*)handshake->myReq1, SHA_DIGEST_LENGTH, NULL);
 
     if (ptr.pos != -1) /* match */
index c19ab13eff2c8f9022a80a0813de81769cabb1aa..5a66bd47d89f1147976226863f5b67fe89b4d136 100644 (file)
@@ -36,7 +36,8 @@ typedef struct tr_recentHistory
     {
         unsigned int n;
         time_t date;
-    } slices[TR_RECENT_HISTORY_PERIOD_SEC];
+    }
+    slices[TR_RECENT_HISTORY_PERIOD_SEC];
 }
 tr_recentHistory;
 
index bfea61f363fbc9fb08e955811a0f2d65a30d44af..29c509642721fe23caba1599c1e204552c9f2658 100644 (file)
@@ -164,7 +164,7 @@ bool tr_logGetDeepEnabled(void)
 
     if (deepLoggingIsActive < 0)
     {
-        deepLoggingIsActive = IsDebuggerPresent() || (tr_logGetFile() != TR_BAD_SYS_FILE);
+        deepLoggingIsActive = IsDebuggerPresent() || tr_logGetFile() != TR_BAD_SYS_FILE;
     }
 
     return deepLoggingIsActive != 0;
index 39cceac07ab073aa82e00d7e0474c8bc83b0de2a..9537b8ab340513131dd723032ebf16147f5f742c 100644 (file)
@@ -89,7 +89,7 @@ static void base32_to_sha1(uint8_t* out, char const* in, size_t const inlen)
         else
         {
             index = (index + 5) % 8;
-            out[offset] |= (digit >> index);
+            out[offset] |= digit >> index;
             offset++;
 
             if (offset >= outlen)
index 9df75042d1d737b9bd9a7ba1a540b6a0c909e2a4..86ee43b16ddbc50f8d348e3554821135677b3971 100644 (file)
@@ -1024,7 +1024,7 @@ void tr_peerIoSetPeersId(tr_peerIo* io, uint8_t const* peer_id)
     }
     else
     {
-        memset(io->peerId, 0, 20);
+        memset(io->peerId, '\0', 20);
     }
 }
 
index 98ac95fada86f5e5f30d10569924f997bee1f98a..f85ded87b6fdc1ebe8e46267dcf1fe09facd3303 100644 (file)
@@ -1480,7 +1480,7 @@ void tr_peerMgrGetNextRequests(tr_torrent* tor, tr_peer* peer, int numwant, tr_b
     }
 
     /* In most cases we've just changed the weights of a small number of pieces.
-     * So rather than qsort ()ing the entire array, it's faster to apply an
+     * So rather than qsort()ing the entire array, it's faster to apply an
      * adaptive insertion sort algorithm. */
     if (got > 0)
     {
@@ -3467,14 +3467,14 @@ static bool shouldPeerBeClosed(tr_swarm const* s, tr_peer const* peer, int peerC
     /* disconnect if it's been too long since piece data has been transferred.
      * this is on a sliding scale based on number of available peers... */
     {
-        int const relaxStrictnessIfFewerThanN = (int)((getMaxPeerCount(tor) * 0.9) + 0.5);
+        int const relaxStrictnessIfFewerThanN = (int)(getMaxPeerCount(tor) * 0.9 + 0.5);
         /* if we have >= relaxIfFewerThan, strictness is 100%.
          * if we have zero connections, strictness is 0% */
         float const strictness = peerCount >= relaxStrictnessIfFewerThanN ? 1.0 :
             peerCount / (float)relaxStrictnessIfFewerThanN;
         int const lo = MIN_UPLOAD_IDLE_SECS;
         int const hi = MAX_UPLOAD_IDLE_SECS;
-        int const limit = hi - ((hi - lo) * strictness);
+        int const limit = hi - (hi - lo) * strictness;
         int const idleTime = now - MAX(atom->time, atom->piece_data_time);
 
         /*
@@ -4160,7 +4160,7 @@ static bool torrentWasRecentlyStarted(tr_torrent const* tor)
 
 static inline uint64_t addValToKey(uint64_t value, int width, uint64_t addme)
 {
-    value = (value << (uint64_t)width);
+    value = value << (uint64_t)width;
     value |= addme;
     return value;
 }
index 649edc48aaf1d7e63004df7e9cec79d27c3f178c..2042382e1c60e3f7015677d5a16e8264bcce7460 100644 (file)
@@ -859,8 +859,8 @@ static bool requestIsValid(tr_peerMsgs const* msgs, struct peer_request const* r
 void tr_peerMsgsCancel(tr_peerMsgs* msgs, tr_block_index_t block)
 {
     struct peer_request req;
-    // fprintf(stderr, "SENDING CANCEL MESSAGE FOR BLOCK %zu\n\t\tFROM PEER %p ------------------------------------\n", (size_t)block,
-    //     msgs->peer);
+    // fprintf(stderr, "SENDING CANCEL MESSAGE FOR BLOCK %zu\n\t\tFROM PEER %p ------------------------------------\n",
+    //     (size_t)block, msgs->peer);
     blockToReq(msgs->torrent, block, &req);
     protocolSendCancel(msgs, &req);
 }
@@ -1516,7 +1516,7 @@ static int readBtMessage(tr_peerMsgs* msgs, struct evbuffer* inbuf, size_t inlen
     uint32_t msglen = msgs->incoming.length;
     uint8_t const id = msgs->incoming.id;
 #ifndef NDEBUG
-     size_t const startBufLen = evbuffer_get_length(inbuf);
+    size_t const startBufLen = evbuffer_get_length(inbuf);
 #endif
     bool const fext = tr_peerIoSupportsFEXT(msgs->io);
 
@@ -2316,7 +2316,7 @@ static inline void pexElementCb(void* vpex, void* userData)
     diffs->elements[diffs->elementCount++] = *pex;
 }
 
-typedef void (tr_set_func)(void* element, void* userData);
+typedef void (tr_set_func)(void* element, void* userData);
 
 /**
  * @brief find the differences and commonalities in two sorted sets
index aaa5889cd08f7e424ab76aec80fafeafe5b0531d..d81cac0a12b7f9f44f62ec62d9923133375de31f 100644 (file)
@@ -324,6 +324,7 @@ static int64_t getquota(char const* device)
 
     if (quotactl(device, QCMD(Q_GETQUOTA, USRQUOTA), getuid(), (caddr_t)&dq) == 0)
     {
+
 #elif defined(__sun)
 
     struct quotctl op;
@@ -346,6 +347,7 @@ static int64_t getquota(char const* device)
 
     if (quotactl(QCMD(Q_GETQUOTA, USRQUOTA), device, getuid(), (caddr_t)&dq) == 0)
     {
+
 #endif
 
         if (dq.dqb_bsoftlimit > 0)
index 8e3e20118ad83e98e905a92919b0acb7b96ca908..5f4af685c3073a8882b705a950acebe8cb3973f2 100644 (file)
@@ -96,7 +96,7 @@ void tr_ptrArrayErase(tr_ptrArray* t, int begin, int end)
 
     memmove(t->items + begin, t->items + end, sizeof(void*) * (t->n_items - end));
 
-    t->n_items -= (end - begin);
+    t->n_items -= end - begin;
 }
 
 /**
index 4495e8d604e8b8e0380bd7d45905fd9b64bf2733..1af499a0c8db1f2a3c9878b5f74d8df0da781215 100644 (file)
@@ -72,7 +72,7 @@ static int addPeers(tr_torrent* tor, uint8_t const* buf, int buflen)
     for (i = 0; i < count && numAdded < MAX_REMEMBERED_PEERS; ++i)
     {
         tr_pex pex;
-        memcpy(&pex, buf + (i * sizeof(tr_pex)), sizeof(tr_pex));
+        memcpy(&pex, buf + i * sizeof(tr_pex), sizeof(tr_pex));
 
         if (tr_isPex(&pex))
         {
index 00b3c08b7ff5925ff883f5090c63f4c9af4fb93d..3de52419b37c7c33a5a8fe766bea1f4239b77d9c 100644 (file)
@@ -142,7 +142,7 @@ static void extract_parts_from_multipart(struct evkeyvalq const* headers, struct
         size_t part_len;
         char const* part = delim + boundary_len;
 
-        inlen -= (part - in);
+        inlen -= part - in;
         in = part;
 
         delim = tr_memmem(in, inlen, boundary, boundary_len);
@@ -366,8 +366,7 @@ static void add_response(struct evhttp_request* req, struct tr_rpc_server* serve
 
 #endif
 
-            evhttp_add_header(req->output_headers,
-                "Content-Encoding", "gzip");
+            evhttp_add_header(req->output_headers, "Content-Encoding", "gzip");
         }
         else
         {
index 2cdcb6ba55c9fdb32bb11c754b158d7e600b9184..a015b5bd200f6a287e11c4fd5a029fdfe41b1349 100644 (file)
@@ -38,7 +38,7 @@
 
 #define RECENTLY_ACTIVE_SECONDS 60
 
-#define TR_N_ELEMENTS(ary)(sizeof(ary) / sizeof(*ary))
+#define TR_N_ELEMENTS(ary) (sizeof(ary) / sizeof(*ary))
 
 #if 0
 
@@ -74,7 +74,7 @@ static tr_rpc_callback_status notify(tr_session* session, int type, tr_torrent*
 
     if (session->rpc_func != NULL)
     {
-        status = session->rpc_func(session, type, tor, session->rpc_func_user_data);
+        status = (*session->rpc_func)(session, type, tor, session->rpc_func_user_data);
     }
 
     return status;
index 850e756dc92c36d2096b485e2ea38e93d3ff6308..032febfd8b94fa3bc687fcdc08173f09c6e3e1e0 100644 (file)
@@ -187,10 +187,8 @@ bool tr_session_id_is_local(char const* session_id)
             if (!tr_sys_file_lock(lock_file, TR_SYS_FILE_LOCK_SH | TR_SYS_FILE_LOCK_NB, &error))
             {
 #ifndef _WIN32
-
                 if (error->code == EWOULDBLOCK)
 #else
-
                 if (error->code == ERROR_LOCK_VIOLATION)
 #endif
                 {
index 2f8035e9fe54dc0c995c26c63a1ad351966c4d99..b532bb52e33acb40887d6040b87e4983b2d667be 100644 (file)
@@ -1446,6 +1446,7 @@ bool tr_sessionGetActiveSpeedLimit_Bps(tr_session const* session, tr_direction d
 
     return isLimited;
 }
+
 bool tr_sessionGetActiveSpeedLimit_KBps(tr_session const* session, tr_direction dir, double* setme_KBps)
 {
     unsigned int Bps = 0;
index ade2c8c413a138aa7621585c78c5acd03d14b365..10d2131991bab4d289f8c834ed30721ef15884ac 100644 (file)
@@ -207,7 +207,7 @@ static int peerIdTTL(tr_torrent const* tor)
     }
     else
     {
-        ttl = (int)difftime(tor->peer_id_creation_time + (tor->session->peer_id_ttl_hours * 3600), tr_time());
+        ttl = (int)difftime(tor->peer_id_creation_time + tor->session->peer_id_ttl_hours * 3600, tr_time());
     }
 
     return ttl;
@@ -541,7 +541,7 @@ void tr_torrentCheckSeedLimit(tr_torrent* tor)
         /* maybe notify the client */
         if (tor->ratio_limit_hit_func != NULL)
         {
-            tor->ratio_limit_hit_func(tor, tor->ratio_limit_hit_func_user_data);
+            (*tor->ratio_limit_hit_func)(tor, tor->ratio_limit_hit_func_user_data);
         }
     }
     /* if we're seeding and reach our inactiviy limit, stop the torrent */
@@ -555,7 +555,7 @@ void tr_torrentCheckSeedLimit(tr_torrent* tor)
         /* maybe notify the client */
         if (tor->idle_limit_hit_func != NULL)
         {
-            tor->idle_limit_hit_func(tor, tor->idle_limit_hit_func_user_data);
+            (*tor->idle_limit_hit_func)(tor, tor->idle_limit_hit_func_user_data);
         }
     }
 }
@@ -920,9 +920,8 @@ static bool setLocalErrorIfFilesDisappeared(tr_torrent* tor)
     if (disappeared)
     {
         tr_deeplog_tor(tor, "%s", "[LAZY] uh oh, the files disappeared");
-        tr_torrentSetLocalError(tor, "%s",
-            _(
-            "No data found! Ensure your drives are connected or use \"Set Location\". To re-download, remove the torrent and re-add it."));
+        tr_torrentSetLocalError(tor, "%s", _("No data found! Ensure your drives are connected or use \"Set Location\". "
+            "To re-download, remove the torrent and re-add it."));
     }
 
     return disappeared;
@@ -1545,7 +1544,7 @@ static uint64_t countFileBytesCompleted(tr_torrent const* tor, tr_file_index_t i
             /* the first block */
             if (tr_torrentBlockIsComplete(tor, first))
             {
-                total += tor->blockSize - (f->offset % tor->blockSize);
+                total += tor->blockSize - f->offset % tor->blockSize;
             }
 
             /* the middle blocks */
@@ -1559,7 +1558,7 @@ static uint64_t countFileBytesCompleted(tr_torrent const* tor, tr_file_index_t i
             /* the last block */
             if (tr_torrentBlockIsComplete(tor, last))
             {
-                total += (f->offset + f->length) - ((uint64_t)tor->blockSize * last);
+                total += f->offset + f->length - (uint64_t)tor->blockSize * last;
             }
         }
     }
@@ -2171,7 +2170,7 @@ static void fireCompletenessChange(tr_torrent* tor, tr_completeness status, bool
 
     if (tor->completeness_func != NULL)
     {
-        tor->completeness_func(tor, status, wasRunning, tor->completeness_func_user_data);
+        (*tor->completeness_func)(tor, status, wasRunning, tor->completeness_func_user_data);
     }
 }
 
@@ -2434,7 +2433,7 @@ static void tr_torrentFireMetadataCompleted(tr_torrent* tor)
 
     if (tor->metadata_func != NULL)
     {
-        tor->metadata_func(tor, tor->metadata_func_user_data);
+        (*tor->metadata_func)(tor, tor->metadata_func_user_data);
     }
 }
 
@@ -2668,7 +2667,7 @@ void tr_torrentGetBlockLocation(tr_torrent const* tor, tr_block_index_t block, t
     uint64_t pos = block;
     pos *= tor->blockSize;
     *piece = pos / tor->info.pieceSize;
-    *offset = pos - (*piece * tor->info.pieceSize);
+    *offset = pos - *piece * tor->info.pieceSize;
     *length = tr_torBlockCountBytes(tor, block);
 }
 
@@ -2679,7 +2678,7 @@ tr_block_index_t _tr_block(tr_torrent const* tor, tr_piece_index_t index, uint32
     assert(tr_isTorrent(tor));
 
     ret = index;
-    ret *= (tor->info.pieceSize / tor->blockSize);
+    ret *= tor->info.pieceSize / tor->blockSize;
     ret += offset / tor->blockSize;
     return ret;
 }
@@ -2757,7 +2756,7 @@ void tr_torGetPieceBlockRange(tr_torrent const* tor, tr_piece_index_t const piec
     uint64_t offset = tor->info.pieceSize;
     offset *= piece;
     *first = offset / tor->blockSize;
-    offset += (tr_torPieceCountBytes(tor, piece) - 1);
+    offset += tr_torPieceCountBytes(tor, piece) - 1;
     *last = offset / tor->blockSize;
 }
 
@@ -3195,7 +3194,7 @@ static void deleteLocalData(tr_torrent* tor, tr_fileFunc func)
             if (strcmp(name, ".") != 0 && strcmp(name, "..") != 0)
             {
                 char* file = tr_buildPath(tmpdir, name, NULL);
-                func(file, NULL);
+                (*func)(file, NULL);
                 tr_free(file);
             }
         }
@@ -3211,7 +3210,7 @@ static void deleteLocalData(tr_torrent* tor, tr_fileFunc func)
         while (tr_sys_path_exists(walk, NULL) && !tr_sys_path_is_same(tmpdir, walk, NULL))
         {
             char* tmp = tr_sys_path_dirname(walk, NULL);
-            func(walk, NULL);
+            (*func)(walk, NULL);
             tr_free(walk);
             walk = tmp;
         }
@@ -3789,7 +3788,7 @@ void tr_torrentSetQueuePosition(tr_torrent* tor, int pos)
         }
     }
 
-    tor->queuePosition = MIN(pos, (back + 1));
+    tor->queuePosition = MIN(pos, back + 1);
     tor->anyDate = now;
 
     assert(queueIsSequenced(tor->session));
index 9f67eab19d40d1c39a65e353ed5879ffe34d8e68..0aa1e6eeb97f45f9a3ef29d04681659d61621cc0 100644 (file)
@@ -206,7 +206,7 @@ static void readFromPipe(evutil_socket_t fd, short eventType, void* veh)
             if (!eh->die && ngot == (ev_ssize_t)nwant)
             {
                 dbgmsg("invoking function in libevent thread");
-                (data.func)(data.user_data);
+                (*data.func)(data.user_data);
             }
 
             break;
index 499dc64474d5eb4f04260d39abe1a99f129f1d71..f4992292fc945fafb91f6b58ddf658e8d46cf311 100644 (file)
@@ -1016,7 +1016,7 @@ static size_t quickfindPartition(char* base, size_t left, size_t right, size_t s
 
     for (i = left; i <= right - 1; ++i)
     {
-        if (compar(base + (size * i), base + (size * right)) <= 0)
+        if ((*compar)(base + (size * i), base + (size * right)) <= 0)
         {
             SWAP(base + (size * storeIndex), base + (size * i), size);
             ++storeIndex;
@@ -1034,12 +1034,12 @@ static size_t quickfindPartition(char* base, size_t left, size_t right, size_t s
 
     for (i = left; i < storeIndex; ++i)
     {
-        assert(compar(base + (size * i), base + (size * storeIndex)) <= 0);
+        assert((*compar)(base + (size * i), base + (size * storeIndex)) <= 0);
     }
 
     for (i = storeIndex + 1; i <= right; ++i)
     {
-        assert(compar(base + (size * i), base + (size * storeIndex)) >= 0);
+        assert((*compar)(base + (size * i), base + (size * storeIndex)) >= 0);
     }
 
 #endif
@@ -1076,7 +1076,7 @@ static void checkBestScoresComeFirst(char* base, size_t nmemb, size_t size, int
 
     for (i = 1; i < k; ++i)
     {
-        if (compar(base + (size * worstFirstPos), base + (size * i)) < 0)
+        if ((*compar)(base + (size * worstFirstPos), base + (size * i)) < 0)
         {
             worstFirstPos = i;
         }
@@ -1084,12 +1084,12 @@ static void checkBestScoresComeFirst(char* base, size_t nmemb, size_t size, int
 
     for (i = 0; i < k; ++i)
     {
-        assert(compar(base + (size * i), base + (size * worstFirstPos)) <= 0);
+        assert((*compar)(base + (size * i), base + (size * worstFirstPos)) <= 0);
     }
 
     for (i = k; i < nmemb; ++i)
     {
-        assert(compar(base + (size * i), base + (size * worstFirstPos)) >= 0);
+        assert((*compar)(base + (size * i), base + (size * worstFirstPos)) >= 0);
     }
 }
 
@@ -1372,7 +1372,7 @@ int tr_main_win32(int argc, char** argv, int (* real_main)(int, char**))
     tr_win32_make_args_utf8(&argc, &argv);
     SetConsoleCP(CP_UTF8);
     SetConsoleOutputCP(CP_UTF8);
-    return real_main(argc, argv);
+    return (*real_main)(argc, argv);
 }
 
 #endif
index 3a3aa2e0f74778217b366ebb1fae715f21fe6b49..4d511aa0dcbc47ec234134a4249c21fb063d2fc3 100644 (file)
@@ -201,7 +201,7 @@ int tr_main_win32(int argc, char** argv, int (* real_main)(int, char**));
     main_impl(__VA_ARGS__); \
     int main(int argc, char* argv[]) \
     { \
-        return tr_main_win32(argc, argv, & main_impl); \
+        return tr_main_win32(argc, argv, &main_impl); \
     } \
     int main_impl(__VA_ARGS__)
 
@@ -249,13 +249,13 @@ void tr_free(void* p);
 void* tr_memdup(void const* src, size_t byteCount);
 
 #define tr_new(struct_type, n_structs) \
-    ((struct_type*)tr_malloc(sizeof(struct_type)* ((size_t)(n_structs))))
+    ((struct_type*)tr_malloc(sizeof(struct_type) * (size_t)(n_structs)))
 
 #define tr_new0(struct_type, n_structs) \
-    ((struct_type*)tr_malloc0(sizeof(struct_type)* ((size_t)(n_structs))))
+    ((struct_type*)tr_malloc0(sizeof(struct_type) * (size_t)(n_structs)))
 
 #define tr_renew(struct_type, mem, n_structs) \
-    ((struct_type*)tr_realloc((mem), sizeof(struct_type)* ((size_t)(n_structs))))
+    ((struct_type*)tr_realloc((mem), sizeof(struct_type) * (size_t)(n_structs)))
 
 void* tr_valloc(size_t bufLen);
 
index ce62f813b795e86f38f8cbd10e5c9c34112b9ca7..280663e2fd8aa4fd940e4698f1185a22e336aba1 100644 (file)
@@ -141,15 +141,15 @@ static bool decode_hex_string(char const* in, unsigned int* setme)
 
         if ('0' <= *in && *in <= '9')
         {
-            val += (*in - '0');
+            val += *in - '0';
         }
         else if ('a' <= *in && *in <= 'f')
         {
-            val += (*in - 'a') + 10u;
+            val += *in - 'a' + 10u;
         }
         else if ('A' <= *in && *in <= 'F')
         {
-            val += (*in - 'A') + 10u;
+            val += *in - 'A' + 10u;
         }
         else
         {
index 7cb241978721c37bead133d2142e553286b042b3..19a54751eed76c9f78af388d009f8e5f04ded579 100644 (file)
@@ -1270,7 +1270,7 @@ int tr_variantFromBuf(tr_variant* setme, tr_variant_fmt fmt, void const* buf, si
         break;
 
     default /* TR_VARIANT_FMT_BENC */:
-        err = tr_variantParseBenc(buf, ((char const*)buf) + buflen, setme, setme_end);
+        err = tr_variantParseBenc(buf, (char const*)buf + buflen, setme, setme_end);
         break;
     }
 
index 01d0f6ade0948405131db0e9725e493d95a57fe0..9481c817c757979075e454e95c46f19a6999f5fa 100644 (file)
@@ -269,7 +269,7 @@ static void task_finish_func(void* vtask)
 
     if (task->done_func != NULL)
     {
-        task->done_func(task->session, task->did_connect, task->did_timeout, task->code, evbuffer_pullup(task->response, -1),
+        (*task->done_func)(task->session, task->did_connect, task->did_timeout, task->code, evbuffer_pullup(task->response, -1),
             evbuffer_get_length(task->response), task->done_func_user_data);
     }
 
index cfbe787c8ca84e6508d9c25350bdf2cbb91457ce..4075ffa28c0be85124636c49cb81c352f5322846 100644 (file)
@@ -78,7 +78,7 @@ static void publish(tr_webseed* w, tr_peer_event* e)
 {
     if (w->callback != NULL)
     {
-        w->callback(&w->parent, e, w->callback_data);
+        (*w->callback)(&w->parent, e, w->callback_data);
     }
 }
 
@@ -254,7 +254,7 @@ static void on_content_changed(struct evbuffer* buf, struct evbuffer_cb_info con
                 data->webseed = w;
                 data->real_url = tr_strdup(url);
                 data->piece_index = task->piece_index;
-                data->piece_offset = task->piece_offset + (task->blocks_done * task->block_size) + (len - 1);
+                data->piece_offset = task->piece_offset + task->blocks_done * task->block_size + len - 1;
 
                 /* processing this uses a tr_torrent pointer,
                    so push the work to the libevent thread... */
@@ -345,7 +345,7 @@ static void on_idle(tr_webseed* w)
             task->webseed = w;
             task->block = b;
             task->piece_index = tr_torBlockPiece(tor, b);
-            task->piece_offset = (tor->blockSize * b) - (tor->info.pieceSize * task->piece_index);
+            task->piece_offset = tor->blockSize * b - tor->info.pieceSize * task->piece_index;
             task->length = (be - b) * tor->blockSize + tr_torBlockCountBytes(tor, be);
             task->blocks_done = 0;
             task->response_code = 0;
@@ -474,7 +474,7 @@ static void task_request_next_chunk(struct tr_webseed_task* t)
 
         uint64_t const total_offset = tr_pieceOffset(tor, t->piece_index, t->piece_offset, t->length - remain);
         tr_piece_index_t const step_piece = total_offset / inf->pieceSize;
-        uint64_t const step_piece_offset = total_offset - (inf->pieceSize * step_piece);
+        uint64_t const step_piece_offset = total_offset - inf->pieceSize * step_piece;
 
         tr_file_index_t file_index;
         tr_file const* file;
index cded80dd2172b3638365e905d797af52b75819d5..40be63741a8daefdfdcc30b1db409586eb6b16dd 100644 (file)
@@ -364,6 +364,7 @@ void DetailsDialog::onTorrentChanged()
 
 namespace
 {
+
 void setIfIdle(QComboBox* box, int i)
 {
     if (!box->hasFocus())
@@ -393,7 +394,8 @@ void setIfIdle(QSpinBox* spin, int value)
         spin->blockSignals(false);
     }
 }
-}
+
+} // namespace
 
 void DetailsDialog::refresh()
 {
index c397726fbb9e08dde278459fba0c42ce9930af85..1ddef729266dee6354daa3b06897a10b6f6cf61e 100644 (file)
@@ -157,8 +157,8 @@ void FilterBar::refreshTrackers()
 
     // update the "All" row
     myTrackerModel->setData(myTrackerModel->index(0, 0), myTorrents.rowCount(), FilterBarComboBox::CountRole);
-    myTrackerModel->setData(myTrackerModel->index(0, 0), getCountString(
-        myTorrents.rowCount()), FilterBarComboBox::CountStringRole);
+    myTrackerModel->setData(myTrackerModel->index(0, 0), getCountString(myTorrents.rowCount()),
+        FilterBarComboBox::CountStringRole);
 
     // rows to update
     for (QString const& host : oldHosts & newHosts)
index a0573e913a1de0a09c5b2acd06347bf4880be1af..f04f5c38fcca52841fe5e0a73ca2d3350fc01143 100644 (file)
@@ -572,6 +572,9 @@ void MainWindow::setLocation()
     d->show();
 }
 
+namespace
+{
+
 // Open Folder & select torrent's file or top folder
 #undef HAVE_OPEN_SELECT
 
@@ -611,6 +614,8 @@ static void openSelect(QString const& path)
 
 #endif
 
+} // namespace
+
 void MainWindow::openFolder()
 {
     QSet<int> const selectedTorrents = getSelectedTorrents();
index cc27b73dfc18498274876ab4d79a62110b1b44b2..63e5f2a80116f329bf4e01c9dd88e2c404ad204a 100644 (file)
@@ -169,7 +169,7 @@ QString timeToStringRounded(int seconds)
 {
     if (seconds > 60)
     {
-        seconds -= (seconds % 60);
+        seconds -= seconds % 60;
     }
 
     return Formatter::timeToString(seconds);
index 8f3a25de3418cf23cca628fc7d2f6562ffe324e0..05061293554aaa5116785231c1b0d23142f15c7b 100644 (file)
@@ -114,7 +114,7 @@ static bool removeURL(tr_variant* metainfo, char const* url)
             {
                 if (tr_variantGetStr(node, &str, NULL) && strcmp(str, url) == 0)
                 {
-                    printf("\tRemoved \"%s\" from \"announce-list\" tier #%d\n", str, (tierIndex + 1));
+                    printf("\tRemoved \"%s\" from \"announce-list\" tier #%d\n", str, tierIndex + 1);
                     tr_variantListRemove(tier, nodeIndex);
                     changed = true;
                 }
@@ -126,7 +126,7 @@ static bool removeURL(tr_variant* metainfo, char const* url)
 
             if (tr_variantListSize(tier) == 0)
             {
-                printf("\tNo URLs left in tier #%d... removing tier\n", (tierIndex + 1));
+                printf("\tNo URLs left in tier #%d... removing tier\n", tierIndex + 1);
                 tr_variantListRemove(announce_list, tierIndex);
             }
             else