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:
Yong Cong Sin 2023-07-11 21:37:30 +08:00 committed by Fabio Baltieri
commit 7fba7d3957

View file

@ -564,7 +564,9 @@ static void mqtt_evt_handler(struct mqtt_client *const client, const struct mqtt
case MQTT_EVT_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;
@ -581,18 +583,19 @@ static void mqtt_evt_handler(struct mqtt_client *const client, const struct mqtt
while (payload_left > 0) {
/* Attempt to claim `payload_left` bytes of buffer in rb */
size = ring_buf_put_claim(&sh_mqtt->rx_rb, &sh_mqtt->rx_rb_ptr,
payload_left);
size = (size_t)ring_buf_put_claim(&sh_mqtt->rx_rb, &sh_mqtt->rx_rb_ptr,
payload_left);
/* 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 */
if (size < 0) {
if (rc < 0) {
(void)ring_buf_put_finish(&sh_mqtt->rx_rb, 0U);
sh_mqtt_rx_rb_flush();
return;
}
size = (size_t)rc;
/* Indicate that `size` bytes of payload has been written into rb */
(void)ring_buf_put_finish(&sh_mqtt->rx_rb, size);
/* Update `payload_left` */