Fix some issues revealed by coverity

This commit is contained in:
Mike Gelfand 2015-05-09 14:09:05 +00:00
parent cdf3cf62f9
commit 4a23c94252
2 changed files with 21 additions and 12 deletions

View File

@ -137,14 +137,14 @@ set_file_for_single_pass (tr_sys_file_t handle)
#ifdef HAVE_POSIX_FADVISE
posix_fadvise (handle, 0, 0, POSIX_FADV_SEQUENTIAL);
(void) posix_fadvise (handle, 0, 0, POSIX_FADV_SEQUENTIAL);
#endif
#ifdef __APPLE__
fcntl (handle, F_RDAHEAD, 1);
fcntl (handle, F_NOCACHE, 1);
(void) fcntl (handle, F_RDAHEAD, 1);
(void) fcntl (handle, F_NOCACHE, 1);
#endif

View File

@ -144,28 +144,37 @@ tr_address_compare (const tr_address * a, const tr_address * b)
* TCP sockets
**********************************************************************/
int
void
tr_netSetTOS (tr_socket_t s,
int tos)
{
#ifdef IP_TOS
return setsockopt (s, IPPROTO_IP, IP_TOS, (const void *) &tos, sizeof (tos));
if (setsockopt (s, IPPROTO_IP, IP_TOS, (const void *) &tos, sizeof (tos)) != -1)
return;
#else
return 0;
(void) s;
errno = ENOSYS;
#endif
tr_logAddNamedInfo ("Net", "Can't set TOS '%d': %s", tos, tr_strerror (errno));
}
int
tr_netSetCongestionControl (tr_socket_t s UNUSED,
const char * algorithm UNUSED)
void
tr_netSetCongestionControl (tr_socket_t s,
const char * algorithm)
{
#ifdef TCP_CONGESTION
return setsockopt (s, IPPROTO_TCP, TCP_CONGESTION,
(const void *) algorithm, strlen (algorithm) + 1);
if (setsockopt (s, IPPROTO_TCP, TCP_CONGESTION,
(const void *) algorithm, strlen (algorithm) + 1) != -1)
return;
#else
(void) s;
errno = ENOSYS;
return -1;
#endif
tr_logAddNamedInfo ("Net", "Can't set congestion control algorithm '%s': %s",
algorithm, tr_strerror (errno));
}
bool