static inline struct io_u *io_u_qpop(struct io_u_queue *q)
{
- if (q->nr)
- return q->io_us[--q->nr];
+ if (q->nr) {
+ const unsigned int next = --q->nr;
+ struct io_u *io_u = q->io_us[next];
+
+ q->io_us[next] = NULL;
+ return io_u;
+ }
return NULL;
}
}
#define io_u_qiter(q, io_u, i) \
- for (i = 0, io_u = (q)->io_us[0]; i < (q)->nr; i++, io_u = (q)->io_us[i])
+ for (i = 0; i < (q)->nr && (io_u = (q)->io_us[i]); i++)
int io_u_qinit(struct io_u_queue *q, unsigned int nr);
void io_u_qexit(struct io_u_queue *q);