Re: [PATCH] cfq-iosched: Fix a gcc 4.5 warning and put some comments

From: Jeff Moyer
Date: Thu Oct 21 2010 - 16:38:35 EST


Vivek Goyal <vgoyal@xxxxxxxxxx> writes:

> - Andi encountedred following warning with gcc 4.5
>
> linux/block/cfq-iosched.c: In function âcfq_dispatch_requestsâ:
> linux/block/cfq-iosched.c:2156:3: warning: array subscript is above array
> bounds
>
> - Warning happens due to following code.
>
> slice = group_slice * count /
> max_t(unsigned, cfqg->busy_queues_avg[cfqd->serving_prio],
> cfq_group_busy_queues_wl(cfqd->serving_prio, cfqd, cfqg));
>
> gcc is complaining about cfqg->busy_queues_avg[] being indexed by CFQ
> prio classes (RT, BE and IDLE) while the array size is only 2.
>
> - At run time, we never access cfqg->busy_queues_avg[IDLE] and return from
> function before this code hits.
>
> - To fix warning increase the array size though it will remain unused. This
> patch also puts some comments to clarify some of the confusions.
>
> - I have taken Jens's patch and modified it a bit.
>
> - Compile tested with gcc 4.4 and boot tested. I don't have gcc 4.5
> running, Andi can you please test it with gcc 4.5 to make sure it
> worked.
>
> Reported-by: Andi Kleen <ak@xxxxxxxxxxxxxxx>
> Signed-off-by: Vivek Goyal <vgoyal@xxxxxxxxxx>
> Signed-off-by: Jens Axboe <axboe@xxxxxxxxx>

Acked-by: Jeff Moyer <jmoyer@xxxxxxxxxx>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/