linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH] staging: comedi: fix sparse warning in comedi_compat32.c
  2015-06-20 16:49 [PATCH] staging: comedi: fix sparse warning in comedi_compat32.c Geliang Tang
@ 2015-06-20 10:38 ` Sudip Mukherjee
  2015-06-20 14:38   ` Geliang Tang
  0 siblings, 1 reply; 8+ messages in thread
From: Sudip Mukherjee @ 2015-06-20 10:38 UTC (permalink / raw)
  To: Geliang Tang; +Cc: abbotti, hsweeten, gregkh, devel, linux-kernel

On Sat, Jun 20, 2015 at 04:49:13PM +0000, Geliang Tang wrote:
> This patch fixes the following sparse warning:
> 
> drivers/staging/comedi/comedi_compat32.c:205:16: warning: cast removes
> address space of expression
> 
> Signed-off-by: Geliang Tang <geliangtang@163.com>
> ---
>  drivers/staging/comedi/comedi_compat32.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/comedi/comedi_compat32.c b/drivers/staging/comedi/comedi_compat32.c
> index 2584824..29a10fe4 100644
> --- a/drivers/staging/comedi/comedi_compat32.c
> +++ b/drivers/staging/comedi/comedi_compat32.c
> @@ -202,7 +202,7 @@ static int get_compat_cmd(struct comedi_cmd __user *cmd,
>  	err |= __get_user(temp.uint, &cmd32->stop_arg);
>  	err |= __put_user(temp.uint, &cmd->stop_arg);
>  	err |= __get_user(temp.uptr, &cmd32->chanlist);
> -	err |= __put_user(compat_ptr(temp.uptr), &cmd->chanlist);
> +	err |= __put_user((unsigned int __force *)compat_ptr(temp.uptr), &cmd->chanlist);
compat_ptr is already a typecast.
static inline void __user *compat_ptr(compat_uptr_t uptr)
{
	return (void __user *)(unsigned long)uptr;
}

so you are adding another typecast to an already exitsing typecast. :(

and besides, this also introduces one new checkpatch warning of
line more than 80 char.

regards
sudip
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
Please read the FAQ at  http://www.tux.org/lkml/

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

* Re: [PATCH] staging: comedi: fix sparse warning in comedi_compat32.c
  2015-06-20 10:38 ` Sudip Mukherjee
@ 2015-06-20 14:38   ` Geliang Tang
  2015-06-20 14:38     ` [PATCH v2] staging: comedi: fix cast " Geliang Tang
  0 siblings, 1 reply; 8+ messages in thread
From: Geliang Tang @ 2015-06-20 14:38 UTC (permalink / raw)
  To: Sudip Mukherjee
  Cc: Geliang Tang, abbotti, hsweeten, gregkh, devel, linux-kernel

On Sat, Jun 20, 2015 at 04:08:19PM +0530, Sudip Mukherjee wrote:
> compat_ptr is already a typecast.
> static inline void __user *compat_ptr(compat_uptr_t uptr)
> {
>       return (void __user *)(unsigned long)uptr;
> }
> 
> so you are adding another typecast to an already exitsing typecast. :(
> 
> and besides, this also introduces one new checkpatch warning of
> line more than 80 char.
> 
> regards
> sudip

Thank you for your review. I revised the patch as you suggested. Here it is.

Geliang Tang (1):
  staging: comedi: fix cast warning in comedi_compat32.c

 drivers/staging/comedi/comedi_compat32.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

-- 
2.3.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
Please read the FAQ at  http://www.tux.org/lkml/

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

* [PATCH v2] staging: comedi: fix cast warning in comedi_compat32.c
  2015-06-20 14:38   ` Geliang Tang
@ 2015-06-20 14:38     ` Geliang Tang
  2015-06-22  9:43       ` Ian Abbott
  0 siblings, 1 reply; 8+ messages in thread
From: Geliang Tang @ 2015-06-20 14:38 UTC (permalink / raw)
  To: Sudip Mukherjee
  Cc: Geliang Tang, abbotti, hsweeten, gregkh, devel, linux-kernel

This patch fixes the following sparse warning:

drivers/staging/comedi/comedi_compat32.c:205:16: warning: cast removes
address space of expression

Signed-off-by: Geliang Tang <geliangtang@163.com>
---
Changes in v2:
  - compat_ptr() is substituted by 'unsigned long'.
---
 drivers/staging/comedi/comedi_compat32.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/comedi/comedi_compat32.c b/drivers/staging/comedi/comedi_compat32.c
index 2584824..894a50c 100644
--- a/drivers/staging/comedi/comedi_compat32.c
+++ b/drivers/staging/comedi/comedi_compat32.c
@@ -202,7 +202,7 @@ static int get_compat_cmd(struct comedi_cmd __user *cmd,
 	err |= __get_user(temp.uint, &cmd32->stop_arg);
 	err |= __put_user(temp.uint, &cmd->stop_arg);
 	err |= __get_user(temp.uptr, &cmd32->chanlist);
-	err |= __put_user(compat_ptr(temp.uptr), &cmd->chanlist);
+	err |= __put_user((unsigned long)(temp.uptr), &cmd->chanlist);
 	err |= __get_user(temp.uint, &cmd32->chanlist_len);
 	err |= __put_user(temp.uint, &cmd->chanlist_len);
 	err |= __get_user(temp.uptr, &cmd32->data);
-- 
2.3.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
Please read the FAQ at  http://www.tux.org/lkml/

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

* [PATCH] staging: comedi: fix sparse warning in comedi_compat32.c
@ 2015-06-20 16:49 Geliang Tang
  2015-06-20 10:38 ` Sudip Mukherjee
  0 siblings, 1 reply; 8+ messages in thread
From: Geliang Tang @ 2015-06-20 16:49 UTC (permalink / raw)
  To: abbotti, hsweeten, gregkh; +Cc: devel, linux-kernel, Geliang Tang

This patch fixes the following sparse warning:

drivers/staging/comedi/comedi_compat32.c:205:16: warning: cast removes
address space of expression

Signed-off-by: Geliang Tang <geliangtang@163.com>
---
 drivers/staging/comedi/comedi_compat32.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/comedi/comedi_compat32.c b/drivers/staging/comedi/comedi_compat32.c
index 2584824..29a10fe4 100644
--- a/drivers/staging/comedi/comedi_compat32.c
+++ b/drivers/staging/comedi/comedi_compat32.c
@@ -202,7 +202,7 @@ static int get_compat_cmd(struct comedi_cmd __user *cmd,
 	err |= __get_user(temp.uint, &cmd32->stop_arg);
 	err |= __put_user(temp.uint, &cmd->stop_arg);
 	err |= __get_user(temp.uptr, &cmd32->chanlist);
-	err |= __put_user(compat_ptr(temp.uptr), &cmd->chanlist);
+	err |= __put_user((unsigned int __force *)compat_ptr(temp.uptr), &cmd->chanlist);
 	err |= __get_user(temp.uint, &cmd32->chanlist_len);
 	err |= __put_user(temp.uint, &cmd->chanlist_len);
 	err |= __get_user(temp.uptr, &cmd32->data);
-- 
1.9.1


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
Please read the FAQ at  http://www.tux.org/lkml/

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

* Re: [PATCH v2] staging: comedi: fix cast warning in comedi_compat32.c
  2015-06-20 14:38     ` [PATCH v2] staging: comedi: fix cast " Geliang Tang
@ 2015-06-22  9:43       ` Ian Abbott
  2015-06-22 15:33         ` Geliang Tang
  0 siblings, 1 reply; 8+ messages in thread
From: Ian Abbott @ 2015-06-22  9:43 UTC (permalink / raw)
  To: Geliang Tang, Sudip Mukherjee; +Cc: hsweeten, gregkh, devel, linux-kernel

On 20/06/15 15:38, Geliang Tang wrote:
> This patch fixes the following sparse warning:
>
> drivers/staging/comedi/comedi_compat32.c:205:16: warning: cast removes
> address space of expression
>
> Signed-off-by: Geliang Tang <geliangtang@163.com>
> ---
> Changes in v2:
>    - compat_ptr() is substituted by 'unsigned long'.
> ---
>   drivers/staging/comedi/comedi_compat32.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/staging/comedi/comedi_compat32.c b/drivers/staging/comedi/comedi_compat32.c
> index 2584824..894a50c 100644
> --- a/drivers/staging/comedi/comedi_compat32.c
> +++ b/drivers/staging/comedi/comedi_compat32.c
> @@ -202,7 +202,7 @@ static int get_compat_cmd(struct comedi_cmd __user *cmd,
>   	err |= __get_user(temp.uint, &cmd32->stop_arg);
>   	err |= __put_user(temp.uint, &cmd->stop_arg);
>   	err |= __get_user(temp.uptr, &cmd32->chanlist);
> -	err |= __put_user(compat_ptr(temp.uptr), &cmd->chanlist);
> +	err |= __put_user((unsigned long)(temp.uptr), &cmd->chanlist);
>   	err |= __get_user(temp.uint, &cmd32->chanlist_len);
>   	err |= __put_user(temp.uint, &cmd->chanlist_len);
>   	err |= __get_user(temp.uptr, &cmd32->data);
>

Now it removes the call to compat_ptr(), so it won't work.  Your first 
patch was better, apart from exceeding the 80 character line limit.

-- 
-=( Ian Abbott @ MEV Ltd.    E-mail: <abbotti@mev.co.uk> )=-
-=(                          Web: http://www.mev.co.uk/  )=-
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
Please read the FAQ at  http://www.tux.org/lkml/

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

* Re: [PATCH v2] staging: comedi: fix cast warning in comedi_compat32.c
  2015-06-22  9:43       ` Ian Abbott
@ 2015-06-22 15:33         ` Geliang Tang
  2015-06-22 15:33           ` [PATCH v3] " Geliang Tang
  0 siblings, 1 reply; 8+ messages in thread
From: Geliang Tang @ 2015-06-22 15:33 UTC (permalink / raw)
  To: Ian Abbott
  Cc: Geliang Tang, sudipm.mukherjee, hsweeten, gregkh, devel, linux-kernel

On Mon, Jun 22, 2015 at 10:43:38AM +0100, Ian Abbott wrote:
> Now it removes the call to compat_ptr(), so it won't work.  Your first patch
> was better, apart from exceeding the 80 character line limit.
Thank you. I revised the patch again.

Geliang Tang (1):
  staging: comedi: fix cast warning in comedi_compat32.c

 drivers/staging/comedi/comedi_compat32.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

-- 
2.3.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
Please read the FAQ at  http://www.tux.org/lkml/

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

* [PATCH v3] staging: comedi: fix cast warning in comedi_compat32.c
  2015-06-22 15:33         ` Geliang Tang
@ 2015-06-22 15:33           ` Geliang Tang
  2015-06-22 16:08             ` Ian Abbott
  0 siblings, 1 reply; 8+ messages in thread
From: Geliang Tang @ 2015-06-22 15:33 UTC (permalink / raw)
  To: Ian Abbott
  Cc: Geliang Tang, sudipm.mukherjee, hsweeten, gregkh, devel, linux-kernel

This patch fixes the following sparse warning:

drivers/staging/comedi/comedi_compat32.c:205:16: warning: cast removes
address space of expression

Signed-off-by: Geliang Tang <geliangtang@163.com>
---
Changes in v3:
  - fix the 80 character line limit.

Changes in v2:
  - compat_ptr() is substituted by 'unsigned long'.
---
 drivers/staging/comedi/comedi_compat32.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/comedi/comedi_compat32.c b/drivers/staging/comedi/comedi_compat32.c
index 2584824..f356386 100644
--- a/drivers/staging/comedi/comedi_compat32.c
+++ b/drivers/staging/comedi/comedi_compat32.c
@@ -202,7 +202,8 @@ static int get_compat_cmd(struct comedi_cmd __user *cmd,
 	err |= __get_user(temp.uint, &cmd32->stop_arg);
 	err |= __put_user(temp.uint, &cmd->stop_arg);
 	err |= __get_user(temp.uptr, &cmd32->chanlist);
-	err |= __put_user(compat_ptr(temp.uptr), &cmd->chanlist);
+	err |= __put_user((unsigned int __force *)compat_ptr(temp.uptr),
+			&cmd->chanlist);
 	err |= __get_user(temp.uint, &cmd32->chanlist_len);
 	err |= __put_user(temp.uint, &cmd->chanlist_len);
 	err |= __get_user(temp.uptr, &cmd32->data);
-- 
2.3.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
Please read the FAQ at  http://www.tux.org/lkml/

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

* Re: [PATCH v3] staging: comedi: fix cast warning in comedi_compat32.c
  2015-06-22 15:33           ` [PATCH v3] " Geliang Tang
@ 2015-06-22 16:08             ` Ian Abbott
  0 siblings, 0 replies; 8+ messages in thread
From: Ian Abbott @ 2015-06-22 16:08 UTC (permalink / raw)
  To: Geliang Tang; +Cc: sudipm.mukherjee, hsweeten, gregkh, devel, linux-kernel

On 22/06/15 16:33, Geliang Tang wrote:
> This patch fixes the following sparse warning:
>
> drivers/staging/comedi/comedi_compat32.c:205:16: warning: cast removes
> address space of expression
>
> Signed-off-by: Geliang Tang <geliangtang@163.com>
> ---
> Changes in v3:
>    - fix the 80 character line limit.
>
> Changes in v2:
>    - compat_ptr() is substituted by 'unsigned long'.
> ---
>   drivers/staging/comedi/comedi_compat32.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/staging/comedi/comedi_compat32.c b/drivers/staging/comedi/comedi_compat32.c
> index 2584824..f356386 100644
> --- a/drivers/staging/comedi/comedi_compat32.c
> +++ b/drivers/staging/comedi/comedi_compat32.c
> @@ -202,7 +202,8 @@ static int get_compat_cmd(struct comedi_cmd __user *cmd,
>   	err |= __get_user(temp.uint, &cmd32->stop_arg);
>   	err |= __put_user(temp.uint, &cmd->stop_arg);
>   	err |= __get_user(temp.uptr, &cmd32->chanlist);
> -	err |= __put_user(compat_ptr(temp.uptr), &cmd->chanlist);
> +	err |= __put_user((unsigned int __force *)compat_ptr(temp.uptr),
> +			&cmd->chanlist);
>   	err |= __get_user(temp.uint, &cmd32->chanlist_len);
>   	err |= __put_user(temp.uint, &cmd->chanlist_len);
>   	err |= __get_user(temp.uptr, &cmd32->data);
>

Looks okay now apart from it being ugly, but that can't be helped since 
comedi uses that chanlist member for both user and kernel addresses!

Reviewed-by: Ian Abbott <abbotti@mev.co.uk>

-- 
-=( Ian Abbott @ MEV Ltd.    E-mail: <abbotti@mev.co.uk> )=-
-=(                          Web: http://www.mev.co.uk/  )=-
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
Please read the FAQ at  http://www.tux.org/lkml/

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

end of thread, other threads:[~2015-06-22 16:08 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-20 16:49 [PATCH] staging: comedi: fix sparse warning in comedi_compat32.c Geliang Tang
2015-06-20 10:38 ` Sudip Mukherjee
2015-06-20 14:38   ` Geliang Tang
2015-06-20 14:38     ` [PATCH v2] staging: comedi: fix cast " Geliang Tang
2015-06-22  9:43       ` Ian Abbott
2015-06-22 15:33         ` Geliang Tang
2015-06-22 15:33           ` [PATCH v3] " Geliang Tang
2015-06-22 16:08             ` Ian Abbott

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).