mqtt: Slightly improve mqtt_create_request

Mainly for better readability, also save NULL test while iterating the for loop.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
This commit is contained in:
Axel Lin 2017-01-07 22:13:12 +08:00 committed by Dirk Ziegelmeier
parent 7faa4bcbe2
commit a2915b7142

View File

@ -257,7 +257,7 @@ mqtt_create_request(struct mqtt_request_t *r_objs, u16_t pkt_id, mqtt_request_cb
struct mqtt_request_t *r = NULL;
u8_t n;
LWIP_ASSERT("mqtt_create_request: r_objs != NULL", r_objs != NULL);
for (n = 0; n < MQTT_REQ_MAX_IN_FLIGHT && r == NULL; n++) {
for (n = 0; n < MQTT_REQ_MAX_IN_FLIGHT; n++) {
/* Item point to itself if not in use */
if (r_objs[n].next == &r_objs[n]) {
r = &r_objs[n];
@ -265,6 +265,7 @@ mqtt_create_request(struct mqtt_request_t *r_objs, u16_t pkt_id, mqtt_request_cb
r->cb = cb;
r->arg = arg;
r->pkt_id = pkt_id;
break;
}
}
return r;