Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

more linting #174

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
remove useless else
avoid some warning: no 'else' at end of 'if ... else if' chain
  • Loading branch information
fperrad committed Nov 12, 2022
commit f2f02c444c6024e109196377d3106210ac4479ad
14 changes: 9 additions & 5 deletions src/mqtt.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,14 +214,16 @@ void mqtt_reinit(struct mqtt_client* client,
client->error = (enum MQTTErrors)tmp; \
if (release) MQTT_PAL_MUTEX_UNLOCK(&client->mutex); \
return (enum MQTTErrors)tmp; \
} else if (tmp == 0) { \
} \
if (tmp == 0) { \
mqtt_mq_clean(&client->mq); \
tmp = pack_call; \
if (tmp < 0) { \
client->error = (enum MQTTErrors)tmp; \
if (release) MQTT_PAL_MUTEX_UNLOCK(&client->mutex); \
return (enum MQTTErrors)tmp; \
} else if(tmp == 0) { \
} \
if(tmp == 0) { \
client->error = MQTT_ERROR_SEND_BUFFER_IS_FULL; \
if (release) MQTT_PAL_MUTEX_UNLOCK(&client->mutex); \
return (enum MQTTErrors)MQTT_ERROR_SEND_BUFFER_IS_FULL; \
Expand Down Expand Up @@ -676,7 +678,8 @@ ssize_t __mqtt_recv(struct mqtt_client *client)
client->error = (enum MQTTErrors)consumed;
MQTT_PAL_MUTEX_UNLOCK(&client->mutex);
return consumed;
} else if (consumed == 0) {
}
if (consumed == 0) {
/* if curr_sz is 0 then the buffer is too small to ever fit the message */
if (client->recv_buffer.curr_sz == 0) {
client->error = MQTT_ERROR_RECV_BUFFER_TOO_SMALL;
Expand Down Expand Up @@ -1650,7 +1653,8 @@ void mqtt_mq_clean(struct mqtt_message_queue *mq) {
mq->queue_tail = (struct mqtt_queued_message *)mq->mem_end;
mq->curr_sz = mqtt_mq_currsz(mq);
return;
} else if (new_head == mqtt_mq_get(mq, 0)) {
}
if (new_head == mqtt_mq_get(mq, 0)) {
/* do nothing */
return;
}
Expand Down Expand Up @@ -1703,7 +1707,7 @@ ssize_t mqtt_unpack_response(struct mqtt_response* response, const uint8_t *buf,
const uint8_t *const start = buf;
ssize_t rv = mqtt_unpack_fixed_header(response, buf, bufsz);
if (rv <= 0) return rv;
else buf += rv;
buf += rv;
switch(response->fixed_header.control_type) {
case MQTT_CONTROL_CONNACK:
rv = mqtt_unpack_connack_response(response, buf);
Expand Down