diff --git a/lib/loop.c b/lib/loop.c index 24ec984a..00b99ee3 100644 --- a/lib/loop.c +++ b/lib/loop.c @@ -103,7 +103,7 @@ int mosquitto_loop(struct mosquitto *mosq, int timeout, int max_packets) /* sockpairR is used to break out of select() before the timeout, on a * call to publish() etc. */ FD_SET(mosq->sockpairR, &readfds); - if(mosq->sockpairR > maxfd){ + if((int)mosq->sockpairR > maxfd){ maxfd = mosq->sockpairR; } } @@ -246,7 +246,7 @@ static int interruptible_sleep(struct mosquitto *mosq, time_t reconnect_delay) int mosquitto_loop_forever(struct mosquitto *mosq, int timeout, int max_packets) { int run = 1; - int rc; + int rc = MOSQ_ERR_SUCCESS; unsigned long reconnect_delay; enum mosquitto_client_state state; @@ -361,7 +361,7 @@ static int mosquitto__loop_rc_handle(struct mosquitto *mosq, int rc) int mosquitto_loop_read(struct mosquitto *mosq, int max_packets) { - int rc; + int rc = MOSQ_ERR_SUCCESS; int i; if(max_packets < 1) return MOSQ_ERR_INVAL; @@ -402,7 +402,7 @@ int mosquitto_loop_read(struct mosquitto *mosq, int max_packets) int mosquitto_loop_write(struct mosquitto *mosq, int max_packets) { - int rc; + int rc = MOSQ_ERR_SUCCESS; int i; if(max_packets < 1) return MOSQ_ERR_INVAL; diff --git a/lib/misc_mosq.c b/lib/misc_mosq.c index f092527f..75b2eaac 100644 --- a/lib/misc_mosq.c +++ b/lib/misc_mosq.c @@ -52,7 +52,7 @@ FILE *mosquitto__fopen(const char *path, const char *mode, bool restrict_read) EXPLICIT_ACCESS_A ea; PACL pacl = NULL; char username[UNLEN + 1]; - int ulen = UNLEN; + DWORD ulen = UNLEN; SECURITY_DESCRIPTOR sd; DWORD dwCreationDisposition; diff --git a/lib/mosquitto.c b/lib/mosquitto.c index 2af233d7..52fd30da 100644 --- a/lib/mosquitto.c +++ b/lib/mosquitto.c @@ -58,7 +58,7 @@ int mosquitto_lib_init(void) if (init_refcount == 0) { #ifdef WIN32 - srand(GetTickCount64()); + srand((unsigned int)GetTickCount64()); #elif _POSIX_TIMERS>0 && defined(_POSIX_MONOTONIC_CLOCK) struct timespec tp; @@ -348,7 +348,7 @@ int mosquitto_sub_topic_tokenise(const char *subtopic, char ***topics, int *coun size_t len; size_t hier_count = 1; size_t start, stop; - int hier; + size_t hier; size_t tlen; size_t i, j; diff --git a/lib/net_mosq.c b/lib/net_mosq.c index 0d961a46..1000d4ed 100644 --- a/lib/net_mosq.c +++ b/lib/net_mosq.c @@ -397,6 +397,8 @@ static int net__try_connect_tcp(const char *host, uint16_t port, mosq_sock_t *so uint32_t val = 1; #endif + ainfo_bind = NULL; + *sock = INVALID_SOCKET; memset(&hints, 0, sizeof(struct addrinfo)); hints.ai_family = AF_UNSPEC; @@ -926,7 +928,7 @@ int net__socket_connect(struct mosquitto *mosq, const char *host, uint16_t port, if(mosq->tcp_nodelay){ int flag = 1; - if(setsockopt(mosq->sock, IPPROTO_TCP, TCP_NODELAY, &flag, sizeof(int)) != 0){ + if(setsockopt(mosq->sock, IPPROTO_TCP, TCP_NODELAY, (const void*)&flag, sizeof(int)) != 0){ log__printf(mosq, MOSQ_LOG_WARNING, "Warning: Unable to set TCP_NODELAY."); } } diff --git a/lib/send_connect.c b/lib/send_connect.c index 65a5b3ee..29b29c69 100644 --- a/lib/send_connect.c +++ b/lib/send_connect.c @@ -143,9 +143,9 @@ int send__connect(struct mosquitto *mosq, uint16_t keepalive, bool clean_session /* Variable header */ if(version == MQTT_PROTOCOL_V31){ - packet__write_string(packet, PROTOCOL_NAME_v31, strlen(PROTOCOL_NAME_v31)); + packet__write_string(packet, PROTOCOL_NAME_v31, (uint16_t)strlen(PROTOCOL_NAME_v31)); }else{ - packet__write_string(packet, PROTOCOL_NAME, strlen(PROTOCOL_NAME)); + packet__write_string(packet, PROTOCOL_NAME, (uint16_t)strlen(PROTOCOL_NAME)); } #if defined(WITH_BROKER) && defined(WITH_BRIDGE) if(mosq->bridge && mosq->bridge->protocol_version != mosq_p_mqtt5 && mosq->bridge->try_private && mosq->bridge->try_private_accepted){