mirror of
https://github.com/eclipse-mosquitto/mosquitto.git
synced 2026-02-05 18:50:06 +08:00
More warning fixes
This commit is contained in:
@@ -202,7 +202,7 @@ static ssize_t read_ws_payloadlen_extended(struct mosquitto *mosq)
|
||||
for(ssize_t i=0; i<len; i++){
|
||||
mosq->wsd.payloadlen = (mosq->wsd.payloadlen << 8) + hbuf[i];
|
||||
}
|
||||
mosq->wsd.payloadlen_bytes -= (uint8_t)len;
|
||||
mosq->wsd.payloadlen_bytes = (uint8_t)(mosq->wsd.payloadlen_bytes - len);
|
||||
|
||||
return len;
|
||||
}
|
||||
@@ -216,7 +216,7 @@ static ssize_t read_ws_mask(struct mosquitto *mosq)
|
||||
if(len <= 0){
|
||||
return len;
|
||||
}
|
||||
mosq->wsd.mask_bytes -= (uint8_t)len;
|
||||
mosq->wsd.mask_bytes = (uint8_t)(mosq->wsd.mask_bytes - len);
|
||||
if(mosq->wsd.mask_bytes > 0){
|
||||
errno = EAGAIN;
|
||||
return -1;
|
||||
|
||||
@@ -165,7 +165,7 @@ int packet__read_uint16(struct mosquitto__packet_in *packet, uint16_t *word)
|
||||
}
|
||||
|
||||
memcpy(&val, &packet->payload[packet->pos], sizeof(uint16_t));
|
||||
packet->pos += sizeof(uint16_t);
|
||||
packet->pos = packet->pos + (uint32_t)sizeof(uint16_t);
|
||||
|
||||
*word = ntohs(val);
|
||||
|
||||
@@ -195,7 +195,7 @@ int packet__read_uint32(struct mosquitto__packet_in *packet, uint32_t *word)
|
||||
}
|
||||
|
||||
memcpy(&val, &packet->payload[packet->pos], sizeof(uint32_t));
|
||||
packet->pos += sizeof(uint32_t);
|
||||
packet->pos = packet->pos + (uint32_t)sizeof(uint32_t);
|
||||
|
||||
*word = ntohl(val);
|
||||
|
||||
|
||||
@@ -573,8 +573,8 @@ static int packet__read_single(struct mosquitto *mosq, enum mosquitto_client_sta
|
||||
}
|
||||
memcpy(mosq->in_packet.payload, &mosq->in_packet.packet_buffer[mosq->in_packet.packet_buffer_pos], len);
|
||||
if(len < mosq->in_packet.packet_buffer_to_process){
|
||||
mosq->in_packet.packet_buffer_pos += (uint16_t)len;
|
||||
mosq->in_packet.packet_buffer_to_process -= (uint16_t)len;
|
||||
mosq->in_packet.packet_buffer_pos = (uint16_t)(mosq->in_packet.packet_buffer_pos + len);
|
||||
mosq->in_packet.packet_buffer_to_process = (uint16_t)(mosq->in_packet.packet_buffer_to_process - len);
|
||||
}else{
|
||||
mosq->in_packet.packet_buffer_pos = 0;
|
||||
mosq->in_packet.packet_buffer_to_process = 0;
|
||||
|
||||
@@ -95,8 +95,8 @@ static int read_tlv_ssl(struct mosquitto *context, uint16_t len, bool *have_cert
|
||||
|
||||
ssl.client = context->proxy.buf[context->proxy.pos];
|
||||
ssl.verify = ntohl(*(uint32_t *)(&context->proxy.buf[context->proxy.pos + sizeof(uint8_t)]));
|
||||
context->proxy.pos += sizeof(uint8_t) + sizeof(uint32_t);
|
||||
len -= (uint16_t)(sizeof(uint8_t) + sizeof(uint32_t));
|
||||
context->proxy.pos = (uint16_t)(context->proxy.pos + sizeof(uint8_t) + sizeof(uint32_t));
|
||||
len = (uint16_t)(len - (sizeof(uint8_t) + sizeof(uint32_t)));
|
||||
|
||||
if(ssl.client & PP2_CLIENT_SSL && ssl.client & PP2_CLIENT_CERT_SESS && !ssl.verify){
|
||||
*have_certificate = true;
|
||||
@@ -108,7 +108,7 @@ static int read_tlv_ssl(struct mosquitto *context, uint16_t len, bool *have_cert
|
||||
}
|
||||
struct pp2_tlv *tlv = (struct pp2_tlv *)(&context->proxy.buf[context->proxy.pos]);
|
||||
uint16_t tlv_len = (uint16_t)((tlv->length_h<<8) + tlv->length_l);
|
||||
context->proxy.pos += (uint16_t)sizeof(struct pp2_tlv);
|
||||
context->proxy.pos = (uint16_t)(context->proxy.pos + sizeof(struct pp2_tlv));
|
||||
|
||||
if(tlv_len > context->proxy.len - context->proxy.pos){
|
||||
return MOSQ_ERR_INVAL;
|
||||
@@ -135,8 +135,8 @@ static int read_tlv_ssl(struct mosquitto *context, uint16_t len, bool *have_cert
|
||||
}
|
||||
break;
|
||||
}
|
||||
len -= (uint16_t)(sizeof(uint8_t) + sizeof(uint8_t) + sizeof(uint8_t) + tlv_len);
|
||||
context->proxy.pos += tlv_len;
|
||||
len = (uint16_t)(len - (sizeof(uint8_t) + sizeof(uint8_t) + sizeof(uint8_t) + tlv_len));
|
||||
context->proxy.pos = (uint16_t)(context->proxy.pos + tlv_len);
|
||||
}
|
||||
context->proxy.have_tls = true;
|
||||
|
||||
@@ -152,7 +152,7 @@ static int read_tlv(struct mosquitto *context, bool *have_certificate)
|
||||
}
|
||||
struct pp2_tlv *tlv = (struct pp2_tlv *)(&context->proxy.buf[context->proxy.pos]);
|
||||
uint16_t tlv_len = (uint16_t)((tlv->length_h<<8) + tlv->length_l);
|
||||
context->proxy.pos += (uint16_t)sizeof(struct pp2_tlv);
|
||||
context->proxy.pos = (uint16_t)(context->proxy.pos + sizeof(struct pp2_tlv));
|
||||
|
||||
if(tlv_len > context->proxy.len - context->proxy.pos){
|
||||
return MOSQ_ERR_INVAL;
|
||||
@@ -168,7 +168,7 @@ static int read_tlv(struct mosquitto *context, bool *have_certificate)
|
||||
}
|
||||
break;
|
||||
default:
|
||||
context->proxy.pos += (uint16_t)tlv_len;
|
||||
context->proxy.pos = (uint16_t)(context->proxy.pos + tlv_len);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -225,7 +225,7 @@ int proxy_v2__read(struct mosquitto *context)
|
||||
}
|
||||
break;
|
||||
}
|
||||
context->proxy.buf = mosquitto_calloc(1, context->proxy.len+1);
|
||||
context->proxy.buf = mosquitto_calloc(1, (size_t)(context->proxy.len+1));
|
||||
if(!context->proxy.buf){
|
||||
return MOSQ_ERR_NOMEM;
|
||||
}
|
||||
@@ -238,9 +238,9 @@ int proxy_v2__read(struct mosquitto *context)
|
||||
}
|
||||
|
||||
if(context->proxy.pos < context->proxy.len){
|
||||
ssize_t rc = net__read(context, context->proxy.buf, context->proxy.len - context->proxy.pos);
|
||||
ssize_t rc = net__read(context, context->proxy.buf, (size_t)(context->proxy.len - context->proxy.pos));
|
||||
if(rc > 0){
|
||||
context->proxy.pos += (uint16_t)rc;
|
||||
context->proxy.pos = (uint16_t)(context->proxy.pos + rc);
|
||||
}else{
|
||||
proxy_cleanup(context);
|
||||
return MOSQ_ERR_CONN_LOST;
|
||||
@@ -267,7 +267,7 @@ int proxy_v2__read(struct mosquitto *context)
|
||||
union proxy_addr *addr = (union proxy_addr *)context->proxy.buf;
|
||||
context->address = mosquitto_strndup((char *)addr->unix_addr.src_addr, sizeof(addr->unix_addr.src_addr));
|
||||
context->remote_port = 0;
|
||||
context->proxy.pos = (uint16_t)strlen(context->address) + 1;
|
||||
context->proxy.pos = (uint16_t)(strlen(context->address) + 1);
|
||||
}else{
|
||||
/* Must be LOCAL */
|
||||
/* Ignore address */
|
||||
|
||||
@@ -43,7 +43,9 @@ static struct mosquitto__retainhier *retain__add_hier_entry(struct mosquitto__re
|
||||
}
|
||||
child->parent = parent;
|
||||
child->topic_len = len;
|
||||
strncpy(child->topic, topic, len);
|
||||
if(len > 0){
|
||||
strncpy(child->topic, topic, (size_t)(len+1));
|
||||
}
|
||||
|
||||
HASH_ADD(hh, *sibling, topic, child->topic_len, child);
|
||||
|
||||
|
||||
@@ -553,7 +553,7 @@ static struct mosquitto__subhier *sub__add_hier_entry(struct mosquitto__subhier
|
||||
child->parent = parent;
|
||||
child->topic_len = len;
|
||||
if(len > 0){
|
||||
strncpy(child->topic, topic, len);
|
||||
strncpy(child->topic, topic, (size_t)(len+1));
|
||||
}
|
||||
|
||||
HASH_ADD(hh, *sibling, topic, child->topic_len, child);
|
||||
|
||||
Reference in New Issue
Block a user