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
move cast inside macro mqtt_mq_currsz
the cast was present 3 times (see function mqtt_mq_register & mqtt_mq_clean)
but missing in function mqtt_mq_init
  • Loading branch information
fperrad committed Oct 28, 2022
commit 602c0d8c9465db56fc8f8a87d64f65729f62a2f0
2 changes: 1 addition & 1 deletion include/mqtt.h
Original file line number Diff line number Diff line change
Expand Up @@ -1081,7 +1081,7 @@ struct mqtt_queued_message* mqtt_mq_find(const struct mqtt_message_queue *mq, en
* @brief Used internally to recalculate the \c curr_sz.
* @ingroup details
*/
#define mqtt_mq_currsz(mq_ptr) (((mq_ptr)->curr >= (uint8_t*) ((mq_ptr)->queue_tail - 1)) ? 0 : ((uint8_t*) ((mq_ptr)->queue_tail - 1)) - (mq_ptr)->curr)
#define mqtt_mq_currsz(mq_ptr) (((mq_ptr)->curr >= (uint8_t*) ((mq_ptr)->queue_tail - 1)) ? 0 : (size_t) (((uint8_t*) ((mq_ptr)->queue_tail - 1)) - (mq_ptr)->curr))

/* CLIENT */

Expand Down
8 changes: 4 additions & 4 deletions src/mqtt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1619,7 +1619,7 @@ void mqtt_mq_init(struct mqtt_message_queue *mq, void *buf, size_t bufsz)
mq->mem_end = (uint8_t *)buf + bufsz;
mq->curr = (uint8_t *)buf;
mq->queue_tail = (struct mqtt_queued_message *)mq->mem_end;
mq->curr_sz = buf == NULL ? 0 : mqtt_mq_currsz(mq);
mq->curr_sz = (buf == NULL) ? 0 : mqtt_mq_currsz(mq);
}

struct mqtt_queued_message* mqtt_mq_register(struct mqtt_message_queue *mq, size_t nbytes)
Expand All @@ -1632,7 +1632,7 @@ struct mqtt_queued_message* mqtt_mq_register(struct mqtt_message_queue *mq, size

/* move curr and recalculate curr_sz */
mq->curr += nbytes;
mq->curr_sz = (size_t) (mqtt_mq_currsz(mq));
mq->curr_sz = mqtt_mq_currsz(mq);

return mq->queue_tail;
}
Expand All @@ -1648,7 +1648,7 @@ void mqtt_mq_clean(struct mqtt_message_queue *mq) {
if (new_head < mq->queue_tail) {
mq->curr = (uint8_t *)mq->mem_start;
mq->queue_tail = (struct mqtt_queued_message *)mq->mem_end;
mq->curr_sz = (size_t) (mqtt_mq_currsz(mq));
mq->curr_sz = mqtt_mq_currsz(mq);
return;
} else if (new_head == mqtt_mq_get(mq, 0)) {
/* do nothing */
Expand Down Expand Up @@ -1680,7 +1680,7 @@ void mqtt_mq_clean(struct mqtt_message_queue *mq) {
}

/* get curr_sz */
mq->curr_sz = (size_t) (mqtt_mq_currsz(mq));
mq->curr_sz = mqtt_mq_currsz(mq);
}

struct mqtt_queued_message* mqtt_mq_find(const struct mqtt_message_queue *mq, enum MQTTControlPacketType control_type, const uint16_t *packet_id)
Expand Down