Skip to content

Commit

Permalink
Merge pull request #170 from fperrad/lint
Browse files Browse the repository at this point in the history
some linting
  • Loading branch information
LiamBindle authored Oct 27, 2022
2 parents 2ee39b9 + 6220c65 commit 7a986a6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions include/mqtt.h
Original file line number Diff line number Diff line change
Expand Up @@ -1058,7 +1058,7 @@ struct mqtt_queued_message* mqtt_mq_register(struct mqtt_message_queue *mq, size
* @relates mqtt_message_queue
* @returns The found message. \c NULL if the message was not found.
*/
struct mqtt_queued_message* mqtt_mq_find(struct mqtt_message_queue *mq, enum MQTTControlPacketType control_type, uint16_t *packet_id);
struct mqtt_queued_message* mqtt_mq_find(const struct mqtt_message_queue *mq, enum MQTTControlPacketType control_type, const uint16_t *packet_id);

/**
* @brief Returns the mqtt_queued_message at \p index.
Expand All @@ -1081,7 +1081,7 @@ struct mqtt_queued_message* mqtt_mq_find(struct mqtt_message_queue *mq, enum MQT
* @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 : ((uint8_t*) ((mq_ptr)->queue_tail - 1)) - (mq_ptr)->curr)

/* CLIENT */

Expand Down
28 changes: 14 additions & 14 deletions src/mqtt.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ void mqtt_init_reconnect(struct mqtt_client *client,

client->socketfd = (mqtt_pal_socket_handle) -1;

mqtt_mq_init(&client->mq, NULL, 0);
mqtt_mq_init(&client->mq, NULL, 0uL);

client->recv_buffer.mem_start = NULL;
client->recv_buffer.mem_size = 0;
Expand Down Expand Up @@ -902,12 +902,12 @@ ssize_t __mqtt_recv(struct mqtt_client *client)
#define MQTT_BITFIELD_RULE_VIOLOATION(bitfield, rule_value, rule_mask) ((bitfield ^ rule_value) & rule_mask)

struct mqtt_fixed_header_rules_s{
const uint8_t control_type_is_valid[16];
const uint8_t required_flags[16];
const uint8_t mask_required_flags[16];
uint8_t control_type_is_valid[16];
uint8_t required_flags[16];
uint8_t mask_required_flags[16];
} ;

struct mqtt_fixed_header_rules_s mqtt_fixed_header_rules ={
static const struct mqtt_fixed_header_rules_s mqtt_fixed_header_rules ={
{ /* boolean value, true if type is valid */
0x00, /* MQTT_CONTROL_RESERVED */
0x01, /* MQTT_CONTROL_CONNECT */
Expand Down Expand Up @@ -1206,16 +1206,16 @@ ssize_t mqtt_pack_connection_request(uint8_t* buf, size_t bufsz,

/* pack the payload */
buf += __mqtt_pack_str(buf, client_id);
if (connect_flags & MQTT_CONNECT_WILL_FLAG) {
if (will_topic != NULL) {
buf += __mqtt_pack_str(buf, will_topic);
buf += __mqtt_pack_uint16(buf, (uint16_t)will_message_size);
memcpy(buf, will_message, will_message_size);
buf += will_message_size;
}
if (connect_flags & MQTT_CONNECT_USER_NAME) {
if (user_name != NULL) {
buf += __mqtt_pack_str(buf, user_name);
}
if (connect_flags & MQTT_CONNECT_PASSWORD) {
if (password != NULL) {
buf += __mqtt_pack_str(buf, password);
}

Expand Down Expand Up @@ -1482,7 +1482,7 @@ ssize_t mqtt_pack_subscribe_request(uint8_t *buf, size_t bufsz, unsigned int pac

/* parse all subscriptions */
va_start(args, packet_id);
while(1) {
for(;;) {
topic[num_subs] = va_arg(args, const char*);
if (topic[num_subs] == NULL) {
/* end of list */
Expand Down Expand Up @@ -1563,7 +1563,7 @@ ssize_t mqtt_pack_unsubscribe_request(uint8_t *buf, size_t bufsz, unsigned int p

/* parse all subscriptions */
va_start(args, packet_id);
while(1) {
for(;;) {
topic[num_subs] = va_arg(args, const char*);
if (topic[num_subs] == NULL) {
/* end of list */
Expand Down Expand Up @@ -1683,7 +1683,7 @@ void mqtt_mq_clean(struct mqtt_message_queue *mq) {
mq->curr_sz = (size_t) (mqtt_mq_currsz(mq));
}

struct mqtt_queued_message* mqtt_mq_find(struct mqtt_message_queue *mq, enum MQTTControlPacketType control_type, uint16_t *packet_id)
struct mqtt_queued_message* mqtt_mq_find(const struct mqtt_message_queue *mq, enum MQTTControlPacketType control_type, const uint16_t *packet_id)
{
struct mqtt_queued_message *curr;
for(curr = mqtt_mq_get(mq, 0); curr >= mq->queue_tail; --curr) {
Expand Down Expand Up @@ -1744,14 +1744,14 @@ ssize_t mqtt_unpack_response(struct mqtt_response* response, const uint8_t *buf,
ssize_t __mqtt_pack_uint16(uint8_t *buf, uint16_t integer)
{
uint16_t integer_htons = MQTT_PAL_HTONS(integer);
memcpy(buf, &integer_htons, 2);
memcpy(buf, &integer_htons, 2uL);
return 2;
}

uint16_t __mqtt_unpack_uint16(const uint8_t *buf)
{
uint16_t integer_htons;
memcpy(&integer_htons, buf, 2);
memcpy(&integer_htons, buf, 2uL);
return MQTT_PAL_NTOHS(integer_htons);
}

Expand All @@ -1770,7 +1770,7 @@ ssize_t __mqtt_pack_str(uint8_t *buf, const char* str) {
return length + 2;
}

static const char *MQTT_ERRORS_STR[] = {
static const char * const MQTT_ERRORS_STR[] = {
"MQTT_UNKNOWN_ERROR",
__ALL_MQTT_ERRORS(GENERATE_STRING)
};
Expand Down

0 comments on commit 7a986a6

Please sign in to comment.