* [PATCH] rocker: fix harmless warning on 32-bit machines
@ 2015-01-13 14:23 Arnd Bergmann
2015-01-13 14:36 ` Jiri Pirko
2015-01-13 21:56 ` David Miller
0 siblings, 2 replies; 3+ messages in thread
From: Arnd Bergmann @ 2015-01-13 14:23 UTC (permalink / raw)
To: netdev; +Cc: David Miller, Jiri Pirko, Scott Feldman, linux-arm-kernel
The rocker driver tries to assign a pointer to a 64-bit integer
and then back to a pointer. This is safe on all architectures,
but causes a compiler warning when pointers are shorter than
64-bit:
rocker/rocker.c: In function 'rocker_desc_cookie_ptr_get':
rocker/rocker.c:809:9: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
return (void *) desc_info->desc->cookie;
^
This adds another cast to uintptr_t to tell the compiler
that it's safe.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
diff --git a/drivers/net/ethernet/rocker/rocker.c b/drivers/net/ethernet/rocker/rocker.c
index 2f398fa4b9e6..cad8cf962cdf 100644
--- a/drivers/net/ethernet/rocker/rocker.c
+++ b/drivers/net/ethernet/rocker/rocker.c
@@ -806,13 +806,13 @@ static bool rocker_desc_gen(struct rocker_desc_info *desc_info)
static void *rocker_desc_cookie_ptr_get(struct rocker_desc_info *desc_info)
{
- return (void *) desc_info->desc->cookie;
+ return (void *)(uintptr_t)desc_info->desc->cookie;
}
static void rocker_desc_cookie_ptr_set(struct rocker_desc_info *desc_info,
void *ptr)
{
- desc_info->desc->cookie = (long) ptr;
+ desc_info->desc->cookie = (uintptr_t) ptr;
}
static struct rocker_desc_info *
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] rocker: fix harmless warning on 32-bit machines
2015-01-13 14:23 [PATCH] rocker: fix harmless warning on 32-bit machines Arnd Bergmann
@ 2015-01-13 14:36 ` Jiri Pirko
2015-01-13 21:56 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: Jiri Pirko @ 2015-01-13 14:36 UTC (permalink / raw)
To: Arnd Bergmann; +Cc: netdev, David Miller, Scott Feldman, linux-arm-kernel
Tue, Jan 13, 2015 at 03:23:52PM CET, arnd@arndb.de wrote:
>The rocker driver tries to assign a pointer to a 64-bit integer
>and then back to a pointer. This is safe on all architectures,
>but causes a compiler warning when pointers are shorter than
>64-bit:
>
>rocker/rocker.c: In function 'rocker_desc_cookie_ptr_get':
>rocker/rocker.c:809:9: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
> return (void *) desc_info->desc->cookie;
> ^
>
>This adds another cast to uintptr_t to tell the compiler
>that it's safe.
>
>Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Jiri Pirko <jiri@resnulli.us>
>
>diff --git a/drivers/net/ethernet/rocker/rocker.c b/drivers/net/ethernet/rocker/rocker.c
>index 2f398fa4b9e6..cad8cf962cdf 100644
>--- a/drivers/net/ethernet/rocker/rocker.c
>+++ b/drivers/net/ethernet/rocker/rocker.c
>@@ -806,13 +806,13 @@ static bool rocker_desc_gen(struct rocker_desc_info *desc_info)
>
> static void *rocker_desc_cookie_ptr_get(struct rocker_desc_info *desc_info)
> {
>- return (void *) desc_info->desc->cookie;
>+ return (void *)(uintptr_t)desc_info->desc->cookie;
> }
>
> static void rocker_desc_cookie_ptr_set(struct rocker_desc_info *desc_info,
> void *ptr)
> {
>- desc_info->desc->cookie = (long) ptr;
>+ desc_info->desc->cookie = (uintptr_t) ptr;
> }
>
> static struct rocker_desc_info *
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] rocker: fix harmless warning on 32-bit machines
2015-01-13 14:23 [PATCH] rocker: fix harmless warning on 32-bit machines Arnd Bergmann
2015-01-13 14:36 ` Jiri Pirko
@ 2015-01-13 21:56 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2015-01-13 21:56 UTC (permalink / raw)
To: arnd; +Cc: netdev, jiri, sfeldma, linux-arm-kernel
From: Arnd Bergmann <arnd@arndb.de>
Date: Tue, 13 Jan 2015 15:23:52 +0100
> The rocker driver tries to assign a pointer to a 64-bit integer
> and then back to a pointer. This is safe on all architectures,
> but causes a compiler warning when pointers are shorter than
> 64-bit:
>
> rocker/rocker.c: In function 'rocker_desc_cookie_ptr_get':
> rocker/rocker.c:809:9: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
> return (void *) desc_info->desc->cookie;
> ^
>
> This adds another cast to uintptr_t to tell the compiler
> that it's safe.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Applied to net-next, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-01-13 21:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-13 14:23 [PATCH] rocker: fix harmless warning on 32-bit machines Arnd Bergmann
2015-01-13 14:36 ` Jiri Pirko
2015-01-13 21:56 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox