Skip to content

Commit

Permalink
Fixed some VS2017 compilation error and warnings (eclipse#1916)
Browse files Browse the repository at this point in the history
* Fixed some VS2017 compilation errors and warnings.

Signed-off-by: raspopov <[email protected]>
  • Loading branch information
raspopov authored and fAuernigg committed Jan 4, 2021
1 parent 005dfb1 commit f000198
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions lib/loop.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion lib/misc_mosq.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions lib/mosquitto.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion lib/net_mosq.c
Original file line number Diff line number Diff line change
Expand Up @@ -928,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.");
}
}
Expand Down
4 changes: 2 additions & 2 deletions lib/send_connect.c
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down

0 comments on commit f000198

Please sign in to comment.