Fix minor Coverity issues

1400727 - unused value
1400726 - dereference after null check
1400728 - derefence before null check
pull/1239/head
Roger A. Light 7 years ago
parent 689989cc56
commit 3e6cb42a40

@ -58,9 +58,9 @@ int send__pingreq(struct mosquitto *mosq)
int send__pingresp(struct mosquitto *mosq)
{
#ifdef WITH_BROKER
if(mosq) log__printf(NULL, MOSQ_LOG_DEBUG, "Sending PINGRESP to %s", mosq->id);
log__printf(NULL, MOSQ_LOG_DEBUG, "Sending PINGRESP to %s", mosq->id);
#else
if(mosq) log__printf(mosq, MOSQ_LOG_DEBUG, "Client %s sending PINGRESP", mosq->id);
log__printf(mosq, MOSQ_LOG_DEBUG, "Client %s sending PINGRESP", mosq->id);
#endif
return send__simple_command(mosq, CMD_PINGRESP);
}
@ -93,9 +93,9 @@ int send__pubcomp(struct mosquitto *mosq, uint16_t mid)
int send__pubrec(struct mosquitto *mosq, uint16_t mid, uint8_t reason_code)
{
#ifdef WITH_BROKER
if(mosq) log__printf(NULL, MOSQ_LOG_DEBUG, "Sending PUBREC to %s (m%d, rc%d)", mosq->id, mid, reason_code);
log__printf(NULL, MOSQ_LOG_DEBUG, "Sending PUBREC to %s (m%d, rc%d)", mosq->id, mid, reason_code);
#else
if(mosq) log__printf(mosq, MOSQ_LOG_DEBUG, "Client %s sending PUBREC (m%d, rc%d)", mosq->id, mid, reason_code);
log__printf(mosq, MOSQ_LOG_DEBUG, "Client %s sending PUBREC (m%d, rc%d)", mosq->id, mid, reason_code);
#endif
if(reason_code >= 0x80 && mosq->protocol == mosq_p_mqtt5){
util__increment_receive_quota(mosq);
@ -107,9 +107,9 @@ int send__pubrec(struct mosquitto *mosq, uint16_t mid, uint8_t reason_code)
int send__pubrel(struct mosquitto *mosq, uint16_t mid)
{
#ifdef WITH_BROKER
if(mosq) log__printf(NULL, MOSQ_LOG_DEBUG, "Sending PUBREL to %s (m%d)", mosq->id, mid);
log__printf(NULL, MOSQ_LOG_DEBUG, "Sending PUBREL to %s (m%d)", mosq->id, mid);
#else
if(mosq) log__printf(mosq, MOSQ_LOG_DEBUG, "Client %s sending PUBREL (m%d)", mosq->id, mid);
log__printf(mosq, MOSQ_LOG_DEBUG, "Client %s sending PUBREL (m%d)", mosq->id, mid);
#endif
/* We don't use Reason String or User Property yet. */
return send__command_with_mid(mosq, CMD_PUBREL|2, mid, false, 0, NULL);

@ -941,7 +941,7 @@ int db__message_write(struct mosquitto_db *db, struct mosquitto *context)
int msg_count = 0;
mosquitto_property *cmsg_props = NULL, *store_props = NULL;
time_t now = 0;
uint32_t expiry_interval = 0;
uint32_t expiry_interval;
if(!context || context->sock == INVALID_SOCKET
|| (context->state == mosq_cs_connected && !context->id)){

@ -164,7 +164,7 @@ int handle__publish(struct mosquitto_db *db, struct mosquitto *context)
}
mosquitto_property_free_all(&properties);
if(topic_alias == 0 || topic_alias > context->listener->max_topic_alias){
if(topic_alias == 0 || (context->listener && topic_alias > context->listener->max_topic_alias)){
mosquitto__free(topic);
send__disconnect(context, MQTT_RC_TOPIC_ALIAS_INVALID, NULL);
return MOSQ_ERR_PROTOCOL;

Loading…
Cancel
Save