diff --git a/MQTTKit/MQTTKit.h b/MQTTKit/MQTTKit.h index 14be2b2..66d2032 100644 --- a/MQTTKit/MQTTKit.h +++ b/MQTTKit/MQTTKit.h @@ -7,20 +7,20 @@ // Copyright 2012 Nicholas Humfrey. All rights reserved. // -typedef enum MQTTConnectionReturnCode : NSUInteger { +typedef NS_ENUM(NSUInteger, MQTTConnectionReturnCode) { ConnectionAccepted, ConnectionRefusedUnacceptableProtocolVersion, ConnectionRefusedIdentiferRejected, ConnectionRefusedServerUnavailable, ConnectionRefusedBadUserNameOrPassword, ConnectionRefusedNotAuthorized -} MQTTConnectionReturnCode; +}; -typedef enum MQTTQualityOfService : NSUInteger { +typedef NS_ENUM(NSUInteger, MQTTQualityOfService) { AtMostOnce, AtLeastOnce, ExactlyOnce -} MQTTQualityOfService; +}; #pragma mark - MQTT Message diff --git a/MQTTKit/MQTTKit.m b/MQTTKit/MQTTKit.m index e1b9951..f65f1c1 100644 --- a/MQTTKit/MQTTKit.m +++ b/MQTTKit/MQTTKit.m @@ -272,7 +272,7 @@ - (void)setWillData:(NSData *)payload retain:(BOOL)retain { const char* cstrTopic = [willTopic cStringUsingEncoding:NSUTF8StringEncoding]; - mosquitto_will_set(mosq, cstrTopic, payload.length, payload.bytes, willQos, retain); + mosquitto_will_set(mosq, cstrTopic, (int)payload.length, payload.bytes, willQos, retain); } - (void)setWill:(NSString *)payload @@ -303,7 +303,7 @@ - (void)publishData:(NSData *)payload [self.publishHandlers setObject:completionHandler forKey:[NSNumber numberWithInt:0]]; } int mid; - mosquitto_publish(mosq, &mid, cstrTopic, payload.length, payload.bytes, qos, retain); + mosquitto_publish(mosq, &mid, cstrTopic, (int)payload.length, payload.bytes, qos, retain); if (completionHandler) { if (qos == 0) { completionHandler(mid); diff --git a/libmosquitto/logging_mosq.c b/libmosquitto/logging_mosq.c index de0ba3b..38150b4 100644 --- a/libmosquitto/logging_mosq.c +++ b/libmosquitto/logging_mosq.c @@ -39,7 +39,7 @@ int _mosquitto_log_printf(struct mosquitto *mosq, int priority, const char *fmt, { va_list va; char *s; - int len; + size_t len; assert(mosq); assert(fmt); diff --git a/libmosquitto/mosquitto.c b/libmosquitto/mosquitto.c index a31f277..fcd0dfb 100644 --- a/libmosquitto/mosquitto.c +++ b/libmosquitto/mosquitto.c @@ -80,7 +80,7 @@ int mosquitto_lib_init(void) struct timeval tv; gettimeofday(&tv, NULL); - srand(tv.tv_sec*1000 + tv.tv_usec/1000); + srand((unsigned int)(tv.tv_sec*1000 + tv.tv_usec/1000)); #endif _mosquitto_net_init(); @@ -898,7 +898,7 @@ int mosquitto_loop_forever(struct mosquitto *mosq, int timeout, int max_packets) #ifdef WIN32 Sleep(reconnect_delay*1000); #else - sleep(reconnect_delay); + sleep((unsigned int)reconnect_delay); #endif pthread_mutex_lock(&mosq->state_mutex); @@ -1143,7 +1143,7 @@ const char *mosquitto_connack_string(int connack_code) int mosquitto_sub_topic_tokenise(const char *subtopic, char ***topics, int *count) { - int len; + size_t len; int hier_count = 1; int start, stop; int hier; diff --git a/libmosquitto/send_client_mosq.c b/libmosquitto/send_client_mosq.c index 2920256..083a6ef 100644 --- a/libmosquitto/send_client_mosq.c +++ b/libmosquitto/send_client_mosq.c @@ -45,7 +45,7 @@ POSSIBILITY OF SUCH DAMAGE. int _mosquitto_send_connect(struct mosquitto *mosq, uint16_t keepalive, bool clean_session) { struct _mosquitto_packet *packet = NULL; - int payloadlen; + size_t payloadlen; uint8_t will = 0; uint8_t byte; int rc; @@ -72,7 +72,7 @@ int _mosquitto_send_connect(struct mosquitto *mosq, uint16_t keepalive, bool cle } packet->command = CONNECT; - packet->remaining_length = 12+payloadlen; + packet->remaining_length = (uint32_t)(12+payloadlen); rc = _mosquitto_packet_alloc(packet); if(rc){ _mosquitto_free(packet); @@ -152,7 +152,7 @@ int _mosquitto_send_subscribe(struct mosquitto *mosq, int *mid, bool dup, const packet = _mosquitto_calloc(1, sizeof(struct _mosquitto_packet)); if(!packet) return MOSQ_ERR_NOMEM; - packetlen = 2 + 2+strlen(topic) + 1; + packetlen = 2 + 2+(uint32_t)strlen(topic) + 1; packet->command = SUBSCRIBE | (dup<<3) | (1<<1); packet->remaining_length = packetlen; @@ -197,7 +197,7 @@ int _mosquitto_send_unsubscribe(struct mosquitto *mosq, int *mid, bool dup, cons packet = _mosquitto_calloc(1, sizeof(struct _mosquitto_packet)); if(!packet) return MOSQ_ERR_NOMEM; - packetlen = 2 + 2+strlen(topic); + packetlen = 2 + 2+(uint32_t)strlen(topic); packet->command = UNSUBSCRIBE | (dup<<3) | (1<<1); packet->remaining_length = packetlen; diff --git a/libmosquitto/send_mosq.c b/libmosquitto/send_mosq.c index 1836ce9..1d38f7a 100644 --- a/libmosquitto/send_mosq.c +++ b/libmosquitto/send_mosq.c @@ -254,7 +254,7 @@ int _mosquitto_send_simple_command(struct mosquitto *mosq, uint8_t command) int _mosquitto_send_real_publish(struct mosquitto *mosq, uint16_t mid, const char *topic, uint32_t payloadlen, const void *payload, int qos, bool retain, bool dup) { struct _mosquitto_packet *packet = NULL; - int packetlen; + size_t packetlen; int rc; assert(mosq); @@ -267,7 +267,7 @@ int _mosquitto_send_real_publish(struct mosquitto *mosq, uint16_t mid, const cha packet->mid = mid; packet->command = PUBLISH | ((dup&0x1)<<3) | (qos<<1) | retain; - packet->remaining_length = packetlen; + packet->remaining_length = (uint32_t)packetlen; rc = _mosquitto_packet_alloc(packet); if(rc){ _mosquitto_free(packet); diff --git a/libmosquitto/util_mosq.c b/libmosquitto/util_mosq.c index cdb5d1d..26da15f 100644 --- a/libmosquitto/util_mosq.c +++ b/libmosquitto/util_mosq.c @@ -213,7 +213,7 @@ int _mosquitto_topic_wildcard_len_check(const char *str) int mosquitto_topic_matches_sub(const char *sub, const char *topic, bool *result) { char *local_sub, *local_topic; - int slen, tlen; + size_t slen, tlen; int spos, tpos; int rc; bool multilevel_wildcard = false;