Fix a number of other style inconsistencies met along the way

This commit is contained in:
Mike Gelfand 2017-04-30 19:30:03 +03:00
parent a762c770f2
commit fbd8d4c79f
35 changed files with 91 additions and 84 deletions

View 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);
}
}

View 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);

View 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;

View 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;

View 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;
}
}

View 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;
}

View 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
{

View 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;
}
}

View 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 */

View 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;

View 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;

View 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)

View 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);
}
}

View 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;
}

View 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

View 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)

View 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;
}
/**

View 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))
{

View 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
{

View 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;

View 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
{

View 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;

View 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));

View 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;

View 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

View 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);

View 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
{

View 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;
}

View 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);
}

View 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;

View 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()
{

View 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)

View 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();

View File

@ -169,7 +169,7 @@ QString timeToStringRounded(int seconds)
{
if (seconds > 60)
{
seconds -= (seconds % 60);
seconds -= seconds % 60;
}
return Formatter::timeToString(seconds);

View 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