Re: [PATCH] dma: ixm-dma: fix warning comparison of distinct pointer types

From: Olof Johansson
Date: Sun Jan 13 2019 - 15:14:00 EST


On Thu, Jan 10, 2019 at 3:15 AM Anders Roxell <anders.roxell@xxxxxxxxxx> wrote:
>
> The warning got introduced by commit 930507c18304 ("arm64: add basic
> Kconfig symbols for i.MX8"). Since it got enabled for arm64. The warning
> haven't been seen before since size_t was 'unsigned int' when built on
> arm32.
>
> ../drivers/dma/imx-dma.c: In function âimxdma_sg_nextâ:
> ../include/linux/kernel.h:846:29: warning: comparison of distinct pointer types lacks a cast
> (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
> ^~
> ../include/linux/kernel.h:860:4: note: in expansion of macro â__typecheckâ
> (__typecheck(x, y) && __no_side_effects(x, y))
> ^~~~~~~~~~~
> ../include/linux/kernel.h:870:24: note: in expansion of macro â__safe_cmpâ
> __builtin_choose_expr(__safe_cmp(x, y), \
> ^~~~~~~~~~
> ../include/linux/kernel.h:879:19: note: in expansion of macro â__careful_cmpâ
> #define min(x, y) __careful_cmp(x, y, <)
> ^~~~~~~~~~~~~
> ../drivers/dma/imx-dma.c:288:8: note: in expansion of macro âminâ
> now = min(d->len, sg_dma_len(sg));
> ^~~
>
> Rework so that we use min_t and pass in the size_t that returns the
> minimum of two values, using the specified type.
>
> Signed-off-by: Anders Roxell <anders.roxell@xxxxxxxxxx>

'now' should probably also be a size_t, but it can be done separately.
imxdma_sg_next()'s return value is never checked anywhere, so the
function can be changed to void as well.

That being said, I think this specific patch should go in now to keep
warnings out of our standard builds. The more we keep around, the
harder it is to spot when a new legitimate one shows up.

Acked-by: Olof Johansson <olof@xxxxxxxxx>


-Olof