From: Mike Gelfand Date: Fri, 2 Jan 2015 04:02:13 +0000 (+0000) Subject: Kill some warnings when compiling on Windows X-Git-Tag: 2.90~265 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9a3b965ce4db12fc4806f4fa670f42eefd98d96a;p=transmission Kill some warnings when compiling on Windows --- diff --git a/libtransmission/fdlimit.c b/libtransmission/fdlimit.c index 5c3616775..4ace4b253 100644 --- a/libtransmission/fdlimit.c +++ b/libtransmission/fdlimit.c @@ -531,9 +531,9 @@ tr_fdSocketCreate (tr_session * session, int domain, int type) int i; socklen_t size = sizeof (int); buf_logged = true; - getsockopt (s, SOL_SOCKET, SO_SNDBUF, &i, &size); + getsockopt (s, SOL_SOCKET, SO_SNDBUF, (void *) &i, &size); tr_logAddDebug ("SO_SNDBUF size is %d", i); - getsockopt (s, SOL_SOCKET, SO_RCVBUF, &i, &size); + getsockopt (s, SOL_SOCKET, SO_RCVBUF, (void *) &i, &size); tr_logAddDebug ("SO_RCVBUF size is %d", i); } } diff --git a/libtransmission/file-test.c b/libtransmission/file-test.c index c4be94cf4..30b11157d 100644 --- a/libtransmission/file-test.c +++ b/libtransmission/file-test.c @@ -148,6 +148,9 @@ validate_permissions (const char * path, #else + (void) path; + (void) permissions; + /* No UNIX permissions on Windows */ return true; diff --git a/libtransmission/file-win32.c b/libtransmission/file-win32.c index f3f69b7fb..8138d56e2 100644 --- a/libtransmission/file-win32.c +++ b/libtransmission/file-win32.c @@ -145,6 +145,8 @@ create_dir (const char * path, assert (path != NULL); + (void) permissions; + wide_path = tr_win32_utf8_to_native (path, -1); if ((flags & TR_SYS_DIR_CREATE_PARENTS) != 0) @@ -225,12 +227,6 @@ create_temp_path (char * path_template, else memcpy (path_template, path, path_size); - goto cleanup; - -fail: - set_system_error (error, GetLastError ()); - -cleanup: tr_free (path); } @@ -444,6 +440,8 @@ tr_sys_path_basename (const char * path, assert (path != NULL); + (void) error; + /* TODO: Error handling */ if (_splitpath_s (path, NULL, 0, NULL, 0, fname, sizeof (fname), ext, sizeof (ext)) == 0 && @@ -467,6 +465,8 @@ tr_sys_path_dirname (const char * path, assert (path != NULL); + (void) error; + /* TODO: Error handling */ if (_splitpath_s (path, drive, sizeof (drive), dir, sizeof (dir), NULL, 0, NULL, 0) == 0 && @@ -613,6 +613,8 @@ tr_sys_file_open (const char * path, assert (path != NULL); assert ((flags & (TR_SYS_FILE_READ | TR_SYS_FILE_WRITE)) != 0); + (void) permissions; + if (flags & TR_SYS_FILE_READ) native_access |= GENERIC_READ; if (flags & TR_SYS_FILE_WRITE) @@ -941,6 +943,11 @@ tr_sys_file_prefetch (tr_sys_file_t handle, assert (handle != TR_BAD_SYS_FILE); assert (size > 0); + (void) handle; + (void) offset; + (void) size; + (void) error; + /* ??? */ return ret; @@ -1015,6 +1022,8 @@ tr_sys_file_unmap (const void * address, assert (address != NULL); assert (size > 0); + (void) size; + ret = UnmapViewOfFile (address); if (!ret) diff --git a/libtransmission/net.c b/libtransmission/net.c index 1515498f3..66d6bd50d 100644 --- a/libtransmission/net.c +++ b/libtransmission/net.c @@ -75,7 +75,7 @@ tr_net_strerror (char * buf, size_t buflen, int err) { *buf = '\0'; #ifdef _WIN32 - FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM, NULL, err, 0, buf, buflen, NULL); + FormatMessageA (FORMAT_MESSAGE_FROM_SYSTEM, NULL, err, 0, buf, buflen, NULL); #else tr_strlcpy (buf, tr_strerror (err), buflen); #endif @@ -148,7 +148,7 @@ int tr_netSetTOS (int s, int tos) { #ifdef IP_TOS - return setsockopt (s, IPPROTO_IP, IP_TOS, (char*)&tos, sizeof (tos)); + return setsockopt (s, IPPROTO_IP, IP_TOS, (const void *) &tos, sizeof (tos)); #else return 0; #endif @@ -159,7 +159,7 @@ tr_netSetCongestionControl (int s UNUSED, const char *algorithm UNUSED) { #ifdef TCP_CONGESTION return setsockopt (s, IPPROTO_TCP, TCP_CONGESTION, - algorithm, strlen (algorithm) + 1); + (const void *) algorithm, strlen (algorithm) + 1); #else errno = ENOSYS; return -1; @@ -248,7 +248,7 @@ tr_netOpenPeerSocket (tr_session * session, /* seeds don't need much of a read buffer... */ if (clientIsSeed) { int n = 8192; - if (setsockopt (s, SOL_SOCKET, SO_RCVBUF, &n, sizeof (n))) + if (setsockopt (s, SOL_SOCKET, SO_RCVBUF, (const void *) &n, sizeof (n))) tr_logAddInfo ("Unable to set SO_RCVBUF on socket %d: %s", s, tr_strerror (sockerrno)); } @@ -337,12 +337,12 @@ tr_netBindTCPImpl (const tr_address * addr, tr_port port, bool suppressMsgs, int } optval = 1; - setsockopt (fd, SOL_SOCKET, SO_KEEPALIVE, &optval, sizeof (optval)); - setsockopt (fd, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof (optval)); + setsockopt (fd, SOL_SOCKET, SO_KEEPALIVE, (const void *) &optval, sizeof (optval)); + setsockopt (fd, SOL_SOCKET, SO_REUSEADDR, (const void *) &optval, sizeof (optval)); #ifdef IPV6_V6ONLY if (addr->type == TR_AF_INET6) - if (setsockopt (fd, IPPROTO_IPV6, IPV6_V6ONLY, &optval, sizeof (optval)) == -1) + if (setsockopt (fd, IPPROTO_IPV6, IPV6_V6ONLY, (const void *) &optval, sizeof (optval)) == -1) if (sockerrno != ENOPROTOOPT) { /* if the kernel doesn't support it, ignore it */ *errOut = sockerrno; return -1; diff --git a/libtransmission/tr-lpd.c b/libtransmission/tr-lpd.c index 29dd788aa..4a484c982 100644 --- a/libtransmission/tr-lpd.c +++ b/libtransmission/tr-lpd.c @@ -292,7 +292,7 @@ int tr_lpdInit (tr_session* ss, tr_address* tr_addr UNUSED) goto fail; if (setsockopt (lpd_socket, SOL_SOCKET, SO_REUSEADDR, - &opt_on, sizeof opt_on) < 0) + (const void *) &opt_on, sizeof opt_on) < 0) goto fail; memset (&lpd_mcastAddr, 0, sizeof lpd_mcastAddr); @@ -311,11 +311,11 @@ int tr_lpdInit (tr_session* ss, tr_address* tr_addr UNUSED) mcastReq.imr_multiaddr = lpd_mcastAddr.sin_addr; mcastReq.imr_interface.s_addr = htonl (INADDR_ANY); if (setsockopt (lpd_socket, IPPROTO_IP, IP_ADD_MEMBERSHIP, - &mcastReq, sizeof mcastReq) < 0) + (const void *) &mcastReq, sizeof mcastReq) < 0) goto fail; if (setsockopt (lpd_socket, IPPROTO_IP, IP_MULTICAST_LOOP, - &opt_off, sizeof opt_off) < 0) + (const void *) &opt_off, sizeof opt_off) < 0) goto fail; } @@ -332,11 +332,11 @@ int tr_lpdInit (tr_session* ss, tr_address* tr_addr UNUSED) /* configure outbound multicast TTL */ if (setsockopt (lpd_socket2, IPPROTO_IP, IP_MULTICAST_TTL, - &scope, sizeof scope) < 0) + (const void *) &scope, sizeof scope) < 0) goto fail; if (setsockopt (lpd_socket2, IPPROTO_IP, IP_MULTICAST_LOOP, - &opt_off, sizeof opt_off) < 0) + (const void *) &opt_off, sizeof opt_off) < 0) goto fail; } @@ -463,7 +463,7 @@ tr_lpdSendAnnounce (const tr_torrent* t) /* destination address info has already been set up in tr_lpdInit (), * so we refrain from preparing another sockaddr_in here */ - int res = sendto (lpd_socket2, query, len, 0, + int res = sendto (lpd_socket2, (const void *) query, len, 0, (const struct sockaddr*) &lpd_mcastAddr, sizeof lpd_mcastAddr); if (res != len) @@ -646,7 +646,7 @@ static void event_callback (evutil_socket_t s UNUSED, short type, void* ignore U char foreignMsg[lpd_maxDatagramLength + 1] = { 0 }; /* process local announcement from foreign peer */ - int res = recvfrom (lpd_socket, foreignMsg, lpd_maxDatagramLength, + int res = recvfrom (lpd_socket, (void *) foreignMsg, lpd_maxDatagramLength, 0, (struct sockaddr*) &foreignAddr, (socklen_t*) &addrLen); /* besides, do we get flooded? then bail out! */ diff --git a/libtransmission/tr-udp.c b/libtransmission/tr-udp.c index 2f5f33b4a..c2022f47d 100644 --- a/libtransmission/tr-udp.c +++ b/libtransmission/tr-udp.c @@ -57,23 +57,23 @@ set_socket_buffers (int fd, int large) socklen_t rbuf_len = sizeof (rbuf), sbuf_len = sizeof (sbuf); size = large ? RECV_BUFFER_SIZE : SMALL_BUFFER_SIZE; - rc = setsockopt (fd, SOL_SOCKET, SO_RCVBUF, &size, sizeof (size)); + rc = setsockopt (fd, SOL_SOCKET, SO_RCVBUF, (const void *) &size, sizeof (size)); if (rc < 0) tr_logAddNamedError ("UDP", "Failed to set receive buffer: %s", tr_strerror (errno)); size = large ? SEND_BUFFER_SIZE : SMALL_BUFFER_SIZE; - rc = setsockopt (fd, SOL_SOCKET, SO_SNDBUF, &size, sizeof (size)); + rc = setsockopt (fd, SOL_SOCKET, SO_SNDBUF, (const void *) &size, sizeof (size)); if (rc < 0) tr_logAddNamedError ("UDP", "Failed to set send buffer: %s", tr_strerror (errno)); if (large) { - rc = getsockopt (fd, SOL_SOCKET, SO_RCVBUF, &rbuf, &rbuf_len); + rc = getsockopt (fd, SOL_SOCKET, SO_RCVBUF, (void *) &rbuf, &rbuf_len); if (rc < 0) rbuf = 0; - rc = getsockopt (fd, SOL_SOCKET, SO_SNDBUF, &sbuf, &sbuf_len); + rc = getsockopt (fd, SOL_SOCKET, SO_SNDBUF, (void *) &sbuf, &sbuf_len); if (rc < 0) sbuf = 0; @@ -147,7 +147,7 @@ rebind_ipv6 (tr_session *ss, bool force) #ifdef IPV6_V6ONLY /* Since we always open an IPv4 socket on the same port, this shouldn't matter. But I'm superstitious. */ - setsockopt (s, IPPROTO_IPV6, IPV6_V6ONLY, &one, sizeof (one)); + setsockopt (s, IPPROTO_IPV6, IPV6_V6ONLY, (const void *) &one, sizeof (one)); #endif memset (&sin6, 0, sizeof (sin6)); @@ -205,7 +205,7 @@ event_callback (evutil_socket_t s, short type UNUSED, void *sv) assert (type == EV_READ); fromlen = sizeof (from); - rc = recvfrom (s, buf, 4096 - 1, 0, + rc = recvfrom (s, (void *) buf, 4096 - 1, 0, (struct sockaddr*)&from, &fromlen); /* Since most packets we receive here are µTP, make quick inline diff --git a/libtransmission/tr-utp.c b/libtransmission/tr-utp.c index ca87e4896..90d12860a 100644 --- a/libtransmission/tr-utp.c +++ b/libtransmission/tr-utp.c @@ -131,9 +131,9 @@ tr_utpSendTo (void *closure, const unsigned char *buf, size_t buflen, tr_session *ss = closure; if (to->sa_family == AF_INET && ss->udp_socket) - sendto (ss->udp_socket, buf, buflen, 0, to, tolen); + sendto (ss->udp_socket, (const void *) buf, buflen, 0, to, tolen); else if (to->sa_family == AF_INET6 && ss->udp_socket) - sendto (ss->udp6_socket, buf, buflen, 0, to, tolen); + sendto (ss->udp6_socket, (const void *) buf, buflen, 0, to, tolen); } static void diff --git a/libtransmission/web.c b/libtransmission/web.c index 1dfacf01b..79b56a793 100644 --- a/libtransmission/web.c +++ b/libtransmission/web.c @@ -147,8 +147,8 @@ sockoptfunction (void * vtask, curl_socket_t fd, curlsocktype purpose UNUSED) { const int sndbuf = isScrape ? 4096 : 1024; const int rcvbuf = isScrape ? 4096 : 3072; - setsockopt (fd, SOL_SOCKET, SO_SNDBUF, &sndbuf, sizeof (sndbuf)); - setsockopt (fd, SOL_SOCKET, SO_RCVBUF, &rcvbuf, sizeof (rcvbuf)); + setsockopt (fd, SOL_SOCKET, SO_SNDBUF, (const void *) &sndbuf, sizeof (sndbuf)); + setsockopt (fd, SOL_SOCKET, SO_RCVBUF, (const void *) &rcvbuf, sizeof (rcvbuf)); } /* return nonzero if this function encountered an error */