Fix some issues reported by Coverity

This commit is contained in:
Mike Gelfand
2017-05-20 23:31:56 +03:00
parent 8f3cb1c68d
commit 82722476aa
5 changed files with 26 additions and 9 deletions

View File

@@ -568,13 +568,23 @@ tr_socket_t tr_fdSocketCreate(tr_session* session, int domain, int type)
if (!buf_logged)
{
int i;
socklen_t size = sizeof(int);
int i = 0;
socklen_t size = sizeof(i);
if (getsockopt(s, SOL_SOCKET, SO_SNDBUF, (void*)&i, &size) != -1)
{
tr_logAddDebug("SO_SNDBUF size is %d", i);
}
i = 0;
size = sizeof(i);
if (getsockopt(s, SOL_SOCKET, SO_RCVBUF, (void*)&i, &size) != -1)
{
tr_logAddDebug("SO_RCVBUF size is %d", i);
}
buf_logged = true;
getsockopt(s, SOL_SOCKET, SO_SNDBUF, (void*)&i, &size);
tr_logAddDebug("SO_SNDBUF size is %d", i);
getsockopt(s, SOL_SOCKET, SO_RCVBUF, (void*)&i, &size);
tr_logAddDebug("SO_RCVBUF size is %d", i);
}
}

View File

@@ -1546,6 +1546,9 @@ static void refillUpkeep(evutil_socket_t foo UNUSED, short bar UNUSED, void* vmg
if (msgs != NULL && request->sentAt <= too_old && !tr_peerMsgsIsReadingBlock(msgs, request->block))
{
assert(cancel != NULL);
assert(cancelCount < cancel_buflen);
cancel[cancelCount++] = *request;
}
else

View File

@@ -479,9 +479,10 @@ tr_quark tr_quark_new(void const* str, size_t len)
if (str == NULL)
{
len = 0;
goto finish;
}
else if (len == TR_BAD_SIZE)
if (len == TR_BAD_SIZE)
{
len = strlen(str);
}
@@ -491,6 +492,7 @@ tr_quark tr_quark_new(void const* str, size_t len)
ret = append_new_quark(str, len);
}
finish:
return ret;
}

View File

@@ -300,7 +300,7 @@ static inline double toSpeedKBps(unsigned int Bps)
static inline uint64_t toMemBytes(unsigned int MB)
{
uint64_t B = tr_mem_K * tr_mem_K;
uint64_t B = (uint64_t)tr_mem_K * tr_mem_K;
B *= MB;
return B;
}

View File

@@ -48,6 +48,8 @@ void TorrentFilter::refreshPref(int key)
/* force a re-sort */
sort(0, !myPrefs.getBool(Prefs::SORT_REVERSED) ? Qt::AscendingOrder : Qt::DescendingOrder);
// fall through
case Prefs::SORT_MODE:
case Prefs::SORT_REVERSED:
sort(0, myPrefs.getBool(Prefs::SORT_REVERSED) ? Qt::AscendingOrder : Qt::DescendingOrder);