shell: mqtt: fix uint32_t compared against 0
Fix unsigned compared against 0 reported by coverity check. CID: 321096 Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
This commit is contained in:
parent
934c6d7b33
commit
7fba7d3957
1 changed files with 8 additions and 5 deletions
|
@ -564,7 +564,9 @@ static void mqtt_evt_handler(struct mqtt_client *const client, const struct mqtt
|
||||||
|
|
||||||
case MQTT_EVT_PUBLISH: {
|
case MQTT_EVT_PUBLISH: {
|
||||||
const struct mqtt_publish_param *pub = &evt->param.publish;
|
const struct mqtt_publish_param *pub = &evt->param.publish;
|
||||||
uint32_t size, payload_left;
|
uint32_t payload_left;
|
||||||
|
size_t size;
|
||||||
|
int rc;
|
||||||
|
|
||||||
payload_left = pub->message.payload.len;
|
payload_left = pub->message.payload.len;
|
||||||
|
|
||||||
|
@ -581,18 +583,19 @@ static void mqtt_evt_handler(struct mqtt_client *const client, const struct mqtt
|
||||||
|
|
||||||
while (payload_left > 0) {
|
while (payload_left > 0) {
|
||||||
/* Attempt to claim `payload_left` bytes of buffer in rb */
|
/* Attempt to claim `payload_left` bytes of buffer in rb */
|
||||||
size = ring_buf_put_claim(&sh_mqtt->rx_rb, &sh_mqtt->rx_rb_ptr,
|
size = (size_t)ring_buf_put_claim(&sh_mqtt->rx_rb, &sh_mqtt->rx_rb_ptr,
|
||||||
payload_left);
|
payload_left);
|
||||||
/* Read `size` bytes of payload from mqtt */
|
/* Read `size` bytes of payload from mqtt */
|
||||||
size = mqtt_read_publish_payload_blocking(client, sh_mqtt->rx_rb_ptr, size);
|
rc = mqtt_read_publish_payload_blocking(client, sh_mqtt->rx_rb_ptr, size);
|
||||||
|
|
||||||
/* errno value, return */
|
/* errno value, return */
|
||||||
if (size < 0) {
|
if (rc < 0) {
|
||||||
(void)ring_buf_put_finish(&sh_mqtt->rx_rb, 0U);
|
(void)ring_buf_put_finish(&sh_mqtt->rx_rb, 0U);
|
||||||
sh_mqtt_rx_rb_flush();
|
sh_mqtt_rx_rb_flush();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size = (size_t)rc;
|
||||||
/* Indicate that `size` bytes of payload has been written into rb */
|
/* Indicate that `size` bytes of payload has been written into rb */
|
||||||
(void)ring_buf_put_finish(&sh_mqtt->rx_rb, size);
|
(void)ring_buf_put_finish(&sh_mqtt->rx_rb, size);
|
||||||
/* Update `payload_left` */
|
/* Update `payload_left` */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue