All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ALSA: control: remove compilation warning on 32-bit
@ 2011-11-05  2:28 Olof Johansson
  2011-11-05 22:00 ` Clemens Ladisch
  0 siblings, 1 reply; 2+ messages in thread
From: Olof Johansson @ 2011-11-05  2:28 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: Olof Johansson, alsa-devel, Clemens Ladisch

This was introduced by 'ALSA: control: add support for ENUMERATED user
space controls' which adds a u64 variable that gets cast to a pointer:

sound/core/control.c: In function 'snd_ctl_elem_init_enum_names':
sound/core/control.c:1089: warning: cast to pointer from integer of different size

Since we don't support 64-bit userspace on 32-bit kernel, it's safe to
cast to long before casting to pointer to avoid the warning.

Signed-off-by: Olof Johansson <olof@lixom.net>
---
 sound/core/control.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/sound/core/control.c b/sound/core/control.c
index 978fe1a..d09c335 100644
--- a/sound/core/control.c
+++ b/sound/core/control.c
@@ -1081,12 +1081,12 @@ static int snd_ctl_elem_init_enum_names(struct user_element *ue)
 	char *names, *p;
 	size_t buf_len, name_len;
 	unsigned int i;
+	const long user_ptrval = ue->info.value.enumerated.names_ptr;
 
 	if (ue->info.value.enumerated.names_length > 64 * 1024)
 		return -EINVAL;
 
-	names = memdup_user(
-		(const void __user *)ue->info.value.enumerated.names_ptr,
+	names = memdup_user((const void __user *)user_ptrval,
 		ue->info.value.enumerated.names_length);
 	if (IS_ERR(names))
 		return PTR_ERR(names);
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ALSA: control: remove compilation warning on 32-bit
  2011-11-05  2:28 [PATCH] ALSA: control: remove compilation warning on 32-bit Olof Johansson
@ 2011-11-05 22:00 ` Clemens Ladisch
  0 siblings, 0 replies; 2+ messages in thread
From: Clemens Ladisch @ 2011-11-05 22:00 UTC (permalink / raw)
  To: Olof Johansson; +Cc: Takashi Iwai, alsa-devel

Olof Johansson wrote:
> This was introduced by 'ALSA: control: add support for ENUMERATED user
> space controls' which adds a u64 variable that gets cast to a pointer:
>
> sound/core/control.c: In function 'snd_ctl_elem_init_enum_names':
> sound/core/control.c:1089: warning: cast to pointer from integer of different size
>
> Since we don't support 64-bit userspace on 32-bit kernel, it's safe to
> cast to long before casting to pointer to avoid the warning.
>
> Signed-off-by: Olof Johansson <olof@lixom.net>
> ---
>  sound/core/control.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)

Applied (with uintptr_t instead of long); thanks!


Clemens


> diff --git a/sound/core/control.c b/sound/core/control.c
> index 978fe1a..d09c335 100644
> --- a/sound/core/control.c
> +++ b/sound/core/control.c
> @@ -1081,12 +1081,12 @@ static int snd_ctl_elem_init_enum_names(struct user_element *ue)
>  	char *names, *p;
>  	size_t buf_len, name_len;
>  	unsigned int i;
> +	const long user_ptrval = ue->info.value.enumerated.names_ptr;
>
>  	if (ue->info.value.enumerated.names_length > 64 * 1024)
>  		return -EINVAL;
>
> -	names = memdup_user(
> -		(const void __user *)ue->info.value.enumerated.names_ptr,
> +	names = memdup_user((const void __user *)user_ptrval,
>  		ue->info.value.enumerated.names_length);
>  	if (IS_ERR(names))
>  		return PTR_ERR(names);

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-11-05 22:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-05  2:28 [PATCH] ALSA: control: remove compilation warning on 32-bit Olof Johansson
2011-11-05 22:00 ` Clemens Ladisch

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.