From: Jens Axboe Date: Fri, 20 Mar 2015 04:15:02 +0000 (-0600) Subject: io_u_queue: add debug assert check on adding too many elements X-Git-Tag: fio-2.2.7~14 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=6fb1bda0d0b61e2433f9ef34b4b979b2642d8706;p=fio.git io_u_queue: add debug assert check on adding too many elements Caught a bug in the io-threads branch, lets merge it into master. Signed-off-by: Jens Axboe --- diff --git a/io_u_queue.c b/io_u_queue.c index 80a32ba3..9994c787 100644 --- a/io_u_queue.c +++ b/io_u_queue.c @@ -8,6 +8,7 @@ int io_u_qinit(struct io_u_queue *q, unsigned int nr) return 1; q->nr = 0; + q->max = nr; return 0; } diff --git a/io_u_queue.h b/io_u_queue.h index bda40d5e..118e5934 100644 --- a/io_u_queue.h +++ b/io_u_queue.h @@ -8,6 +8,7 @@ struct io_u; struct io_u_queue { struct io_u **io_us; unsigned int nr; + unsigned int max; }; static inline struct io_u *io_u_qpop(struct io_u_queue *q) @@ -25,7 +26,12 @@ static inline struct io_u *io_u_qpop(struct io_u_queue *q) static inline void io_u_qpush(struct io_u_queue *q, struct io_u *io_u) { - q->io_us[q->nr++] = io_u; + if (q->nr < q->max) { + q->io_us[q->nr++] = io_u; + return; + } + + assert(0); } static inline int io_u_qempty(const struct io_u_queue *q)