Re: [PATCH v2] ioatdma: silence GCC warnings

From: Jiang, Dave
Date: Mon Jul 22 2013 - 11:46:59 EST


On Sat, 2013-07-20 at 20:05 +0200, Paul Bolle wrote:
> Building dma_v3.o triggers a GCC warning:
> drivers/dma/ioat/dma_v3.c: In function â__ioat3_prep_pq16_lockâ:
> drivers/dma/ioat/dma_v3.c:264:11: warning: array subscript is below array bounds [-Warray-bounds]
> drivers/dma/ioat/dma_v3.c:264:11: warning: array subscript is below array bounds [-Warray-bounds]
>
> This warning is caused by pq16_set_src(). It uses "int idx" as an index
> to an eight element array. Changing "idx" to "unsigned" silences this
> warning. Apparently GCC can then determine that "idx" will never be
> negative.
>
> Signed-off-by: Paul Bolle <pebolle@xxxxxxxxxx>

Acked-by: Dave Jiang <dave.jiang@xxxxxxxxx>

> ---
> 0) v2: cut back to a one hunk change, as Dan suggested.
>
> 1) Still just compile tested.
>
> drivers/dma/ioat/dma_v3.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/dma/ioat/dma_v3.c b/drivers/dma/ioat/dma_v3.c
> index b642e03..2bb4601 100644
> --- a/drivers/dma/ioat/dma_v3.c
> +++ b/drivers/dma/ioat/dma_v3.c
> @@ -251,7 +251,7 @@ static bool is_bwd_noraid(struct pci_dev *pdev)
> }
>
> static void pq16_set_src(struct ioat_raw_descriptor *desc[3],
> - dma_addr_t addr, u32 offset, u8 coef, int idx)
> + dma_addr_t addr, u32 offset, u8 coef, unsigned idx)
> {
> struct ioat_pq_descriptor *pq = (struct ioat_pq_descriptor *)desc[0];
> struct ioat_pq16a_descriptor *pq16 =

¢éì®&Þ~º&¶¬–+-±éÝ¥Šw®žË±Êâmébžìdz¹Þ)í…æèw*jg¬±¨¶‰šŽŠÝj/êäz¹ÞŠà2ŠÞ¨è­Ú&¢)ß«a¶Úþø®G«éh®æj:+v‰¨Šwè†Ù>Wš±êÞiÛaxPjØm¶Ÿÿà -»+ƒùdš_