From 4a23c9425237d835bd040829f6e6da6c52e766a4 Mon Sep 17 00:00:00 2001 From: Mike Gelfand Date: Sat, 9 May 2015 14:09:05 +0000 Subject: [PATCH] Fix some issues revealed by coverity --- libtransmission/file-posix.c | 6 +++--- libtransmission/net.c | 27 ++++++++++++++++++--------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/libtransmission/file-posix.c b/libtransmission/file-posix.c index 35d634288..a4f0c6bab 100644 --- a/libtransmission/file-posix.c +++ b/libtransmission/file-posix.c @@ -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 diff --git a/libtransmission/net.c b/libtransmission/net.c index 130ace0b7..246253364 100644 --- a/libtransmission/net.c +++ b/libtransmission/net.c @@ -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