Re: drivers/net/mac8390.c: Remove useless memcpy casting

From: Geert Uytterhoeven
Date: Sun Mar 07 2010 - 04:19:51 EST


On Tue, Mar 2, 2010 at 21:01, Linux Kernel Mailing List
<linux-kernel@xxxxxxxxxxxxxxx> wrote:
> Gitweb: Â Â http://git.kernel.org/linus/5c7fffd0e3b57cb63f50bbd710868f012d67654f
> Commit: Â Â 5c7fffd0e3b57cb63f50bbd710868f012d67654f
> Parent: Â Â 35076402a9936fa8a73b57a1f97fecbeceeec34a
> Author: Â Â Joe Perches <joe@xxxxxxxxxxx>
> AuthorDate: Mon Jan 4 11:53:00 2010 +0000
> Committer: ÂDavid S. Miller <davem@xxxxxxxxxxxxx>
> CommitDate: Wed Jan 6 20:44:02 2010 -0800
>
> Â Âdrivers/net/mac8390.c: Remove useless memcpy casting
>
> Â ÂSigned-off-by: Joe Perches <joe@xxxxxxxxxxx>
> Â ÂSigned-off-by: David S. Miller <davem@xxxxxxxxxxxxx>
> ---
> Âdrivers/net/mac8390.c | Â 19 ++++++++++---------
> Â1 files changed, 10 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/net/mac8390.c b/drivers/net/mac8390.c
> index 6b6f375..517cee4 100644
> --- a/drivers/net/mac8390.c
> +++ b/drivers/net/mac8390.c
> @@ -237,14 +237,14 @@ static enum mac8390_access __init mac8390_testio(volatile unsigned long membase)

As indicated by the prototype above, membase is not a pointer...

> Â Â Â Âunsigned long outdata = 0xA5A0B5B0;
> Â Â Â Âunsigned long indata = Â0x00000000;
> Â Â Â Â/* Try writing 32 bits */
> - Â Â Â memcpy((char *)membase, (char *)&outdata, 4);
> + Â Â Â memcpy(membase, &outdata, 4);
> Â Â Â Â/* Now compare them */
> Â Â Â Âif (memcmp((char *)&outdata, (char *)membase, 4) == 0)
> Â Â Â Â Â Â Â Âreturn ACCESS_32;
> Â Â Â Â/* Write 16 bit output */
> - Â Â Â word_memcpy_tocard((char *)membase, (char *)&outdata, 4);
> + Â Â Â word_memcpy_tocard(membase, &outdata, 4);
> Â Â Â Â/* Now read it back */
> - Â Â Â word_memcpy_fromcard((char *)&indata, (char *)membase, 4);
> + Â Â Â word_memcpy_fromcard(&indata, membase, 4);
> Â Â Â Âif (outdata == indata)
> Â Â Â Â Â Â Â Âreturn ACCESS_16;
> Â Â Â Âreturn ACCESS_UNKNOWN;

... hence you introduced 3 compiler warnings:

drivers/net/mac8390.c:249: warning: passing argument 1 of
'__builtin_memcpy' makes pointer from integer without a cast
drivers/net/mac8390.c:254: warning: passing argument 1 of
'word_memcpy_tocard' makes pointer from integer without a cast
drivers/net/mac8390.c:256: warning: passing argument 2 of
'word_memcpy_fromcard' makes pointer from integer without a cast

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
--
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/