Skip to content

Commit

Permalink
Fix minor Coverity issues
Browse files Browse the repository at this point in the history
1400727 - unused value
1400726 - dereference after null check
1400728 - derefence before null check
  • Loading branch information
ralight committed Apr 17, 2019
1 parent 689989c commit 3e6cb42
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions lib/send_mosq.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/database.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)){
Expand Down
2 changes: 1 addition & 1 deletion src/handle_publish.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 3e6cb42

Please sign in to comment.