From 094163814395ee6e59b68fd44118a699fe2155ff Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Wed, 13 Mar 2019 13:47:01 +0000 Subject: [PATCH] Fix signed/unsigned comparion warnings. Closes #1196. --- client/client_shared.c | 6 +++--- lib/packet_mosq.c | 2 +- lib/socks_mosq.c | 2 +- lib/util_mosq.c | 2 +- lib/util_topic.c | 8 ++++---- src/mosquitto_passwd.c | 4 ++-- src/security_default.c | 2 +- src/sys_tree.c | 6 +++--- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/client/client_shared.c b/client/client_shared.c index 585b0996..46bfc02d 100644 --- a/client/client_shared.c +++ b/client/client_shared.c @@ -1179,11 +1179,11 @@ static int mosquitto__urldecode(char *str) static int mosquitto__parse_socks_url(struct mosq_config *cfg, char *url) { char *str; - int i; + size_t i; char *username = NULL, *password = NULL, *host = NULL, *port = NULL; char *username_or_host = NULL; - int start; - int len; + size_t start; + size_t len; bool have_auth = false; int port_int; diff --git a/lib/packet_mosq.c b/lib/packet_mosq.c index abc03922..07f1eceb 100644 --- a/lib/packet_mosq.c +++ b/lib/packet_mosq.c @@ -153,7 +153,7 @@ int packet__queue(struct mosquitto *mosq, struct mosquitto__packet *packet) int packet__check_oversize(struct mosquitto *mosq, uint32_t remaining_length) { - int len; + uint32_t len; if(mosq->maximum_packet_size == 0) return MOSQ_ERR_SUCCESS; diff --git a/lib/socks_mosq.c b/lib/socks_mosq.c index 60fcf657..2ab02893 100644 --- a/lib/socks_mosq.c +++ b/lib/socks_mosq.c @@ -390,7 +390,7 @@ int socks5__read(struct mosquitto *mosq) mosq->in_packet.to_process += 16+2-1; /* 16 bytes IPv6, 2 bytes port, -1 byte because we've already read the first byte */ mosq->in_packet.packet_length += 16+2-1; }else if(mosq->in_packet.payload[3] == SOCKS_ATYPE_DOMAINNAME){ - if(mosq->in_packet.payload[4] > 0 && mosq->in_packet.payload[4] <= 255){ + if(mosq->in_packet.payload[4] > 0){ mosq->in_packet.to_process += mosq->in_packet.payload[4]; mosq->in_packet.packet_length += mosq->in_packet.payload[4]; } diff --git a/lib/util_mosq.c b/lib/util_mosq.c index b7036061..d59add21 100644 --- a/lib/util_mosq.c +++ b/lib/util_mosq.c @@ -169,7 +169,7 @@ int mosquitto__hex2bin(const char *hex, unsigned char *bin, int bin_max_len) int len; int leading_zero = 0; int start = 0; - int i = 0; + size_t i = 0; /* Count the number of leading zero */ for(i=0; i 65535) return MOSQ_ERR_INVAL; @@ -109,7 +109,7 @@ int mosquitto_sub_topic_check(const char *str) int mosquitto_sub_topic_check2(const char *str, size_t len) { char c = '\0'; - int i; + size_t i; if(len > 65535) return MOSQ_ERR_INVAL; @@ -149,8 +149,8 @@ int mosquitto_topic_matches_sub(const char *sub, const char *topic, bool *result /* Does a topic match a subscription? */ int mosquitto_topic_matches_sub2(const char *sub, size_t sublen, const char *topic, size_t topiclen, bool *result) { - int i; - int spos, tpos; + size_t i; + size_t spos, tpos; bool multilevel_wildcard = false; if(!result) return MOSQ_ERR_INVAL; diff --git a/src/mosquitto_passwd.c b/src/mosquitto_passwd.c index cde212fa..3e64c00c 100644 --- a/src/mosquitto_passwd.c +++ b/src/mosquitto_passwd.c @@ -64,7 +64,7 @@ static unsigned char tmpfile_path[36]; static FILE *mpw_tmpfile(void) { int fd; - int i; + size_t i; if(RAND_bytes(tmpfile_path, sizeof(tmpfile_path)) != 1){ return NULL; @@ -356,7 +356,7 @@ int get_password(char *password, int len) int copy_contents(FILE *src, FILE *dest) { char buf[MAX_BUFFER_LEN]; - int len; + size_t len; rewind(src); rewind(dest); diff --git a/src/security_default.c b/src/security_default.c index 5edacb56..ee52f03e 100644 --- a/src/security_default.c +++ b/src/security_default.c @@ -840,7 +840,7 @@ static int psk__file_parse(struct mosquitto_db *db, struct mosquitto__unpwd **ps #ifdef WITH_TLS static int mosquitto__memcmp_const(const void *a, const void *b, size_t len) { - int i; + size_t i; int rc = 0; if(!a || !b) return 1; diff --git a/src/sys_tree.c b/src/sys_tree.c index 207f44c6..415c45a6 100644 --- a/src/sys_tree.c +++ b/src/sys_tree.c @@ -57,13 +57,13 @@ void sys_tree__init(struct mosquitto_db *db) static void sys_tree__update_clients(struct mosquitto_db *db, char *buf) { - static unsigned int client_count = -1; + static int client_count = -1; static int clients_expired = -1; - static unsigned int client_max = 0; + static int client_max = 0; static int disconnected_count = -1; static int connected_count = -1; - unsigned int count_total, count_by_sock; + int count_total, count_by_sock; count_total = HASH_CNT(hh_id, db->contexts_by_id); count_by_sock = HASH_CNT(hh_sock, db->contexts_by_sock);