From 236aaa011fbff65908867357647ef04e66f32a00 Mon Sep 17 00:00:00 2001 From: Peter Lieven Date: Fri, 19 Oct 2012 23:48:04 +0200 Subject: [PATCH] Fix compiler warnings These patch fixes 3 compiler warnings introduce by my recent patches. --- lib/connect.c | 1 + lib/init.c | 2 +- lib/socket.c | 58 +++++++++++++++++++++++++-------------------------- 3 files changed, 31 insertions(+), 30 deletions(-) diff --git a/lib/connect.c b/lib/connect.c index 2f5b003..c20e4ed 100644 --- a/lib/connect.c +++ b/lib/connect.c @@ -24,6 +24,7 @@ #include #include #include +#include #include "slist.h" #include "iscsi.h" #include "iscsi-private.h" diff --git a/lib/init.c b/lib/init.c index 61852f2..0269e43 100644 --- a/lib/init.c +++ b/lib/init.c @@ -280,7 +280,7 @@ iscsi_set_error(struct iscsi_context *iscsi, const char *error_string, ...) va_end(ap); - DPRINTF(iscsi,1,str); + DPRINTF(iscsi,1,"%s",str); } void diff --git a/lib/socket.c b/lib/socket.c index 930a1eb..1327ee0 100644 --- a/lib/socket.c +++ b/lib/socket.c @@ -58,6 +58,34 @@ static void set_nonblocking(int fd) #endif } +#ifndef TCP_USER_TIMEOUT +#define TCP_USER_TIMEOUT 18 +#endif + +int set_tcp_user_timeout(struct iscsi_context *iscsi) +{ + int level, value; + + #if defined(__FreeBSD__) || defined(__sun) + struct protoent *buf; + + if ((buf = getprotobyname("tcp")) != NULL) + level = buf->p_proto; + else + return -1; + #else + level = SOL_TCP; + #endif + + value = iscsi->tcp_user_timeout; + if (setsockopt(iscsi->fd, level, TCP_USER_TIMEOUT, &value, sizeof(value)) != 0) { + iscsi_set_error(iscsi, "TCP: Failed to set tcp user timeout. Error %s(%d)", strerror(errno), errno); + return -1; + } + DPRINTF(iscsi,3,"TCP_USER_TIMEOUT set to %d",value); + return 0; +} + int iscsi_connect_async(struct iscsi_context *iscsi, const char *portal, iscsi_command_cb cb, void *private_data) @@ -178,7 +206,7 @@ iscsi_connect_async(struct iscsi_context *iscsi, const char *portal, freeaddrinfo(ai); - if (iscsi->connected_portal) free(iscsi->connected_portal); + if (iscsi->connected_portal) free(discard_const(iscsi->connected_portal)); iscsi->connected_portal=strdup(portal); return 0; @@ -529,34 +557,6 @@ iscsi_free_iscsi_inqueue(struct iscsi_in_pdu *inqueue) } } -#ifndef TCP_USER_TIMEOUT -#define TCP_USER_TIMEOUT 18 -#endif - -int set_tcp_user_timeout(struct iscsi_context *iscsi) -{ - int level, value; - - #if defined(__FreeBSD__) || defined(__sun) - struct protoent *buf; - - if ((buf = getprotobyname("tcp")) != NULL) - level = buf->p_proto; - else - return -1; - #else - level = SOL_TCP; - #endif - - value = iscsi->tcp_user_timeout; - if (setsockopt(iscsi->fd, level, TCP_USER_TIMEOUT, &value, sizeof(value)) != 0) { - iscsi_set_error(iscsi, "TCP: Failed to set tcp user timeout. Error %s(%d)", strerror(errno), errno); - return -1; - } - DPRINTF(iscsi,3,"TCP_USER_TIMEOUT set to %d",value); - return 0; -} - void iscsi_set_tcp_user_timeout(struct iscsi_context *iscsi, int timeout_ms) { iscsi->tcp_user_timeout=timeout_ms;