Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1333345 > unrolled thread

[PATCH] staging: lustre/lnet: Fix wrong type casting warning generated by sparse

Started byNiranjan Dighe <niranjan.dighe@gmail.com>
First post2016-02-13 19:10 +0100
Last post2016-02-14 03:50 +0100
Articles 3 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] staging: lustre/lnet: Fix wrong type casting warning  generated by sparse Niranjan Dighe <niranjan.dighe@gmail.com> - 2016-02-13 19:10 +0100
    Re: [PATCH] staging: lustre/lnet: Fix wrong type casting warning  generated by sparse Dan Carpenter <dan.carpenter@oracle.com> - 2016-02-13 22:50 +0100
      Re: [PATCH] staging: lustre/lnet: Fix wrong type casting warning  generated by sparse Niranjan Dighe <niranjan.dighe@gmail.com> - 2016-02-14 03:50 +0100

#1333345 — [PATCH] staging: lustre/lnet: Fix wrong type casting warning generated by sparse

FromNiranjan Dighe <niranjan.dighe@gmail.com>
Date2016-02-13 19:10 +0100
Subject[PATCH] staging: lustre/lnet: Fix wrong type casting warning generated by sparse
Message-ID<r1MNQ-8o9-9@gated-at.bofh.it>
Fixed the following warning reported by sparse about typecasting. A
userspace pointer was being typecasted by simply (char *) which causes
sparse to give the following warning -

warning: cast removes address space of expression

Fixed it by adding __user annotation to the typecasting.

Signed-off-by: Niranjan Dighe <niranjan.dighe@gmail.com>
---
 drivers/staging/lustre/lnet/selftest/console.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/lustre/lnet/selftest/console.c b/drivers/staging/lustre/lnet/selftest/console.c
index 366211e..64b6a70 100644
--- a/drivers/staging/lustre/lnet/selftest/console.c
+++ b/drivers/staging/lustre/lnet/selftest/console.c
@@ -1461,9 +1461,9 @@ lstcon_statrpc_readent(int transop, srpc_msg_t *msg,
 
 	sfwk_stat = (sfw_counters_t __user *)&ent_up->rpe_payload[0];
 	srpc_stat = (srpc_counters_t __user *)
-				      ((char *)sfwk_stat + sizeof(*sfwk_stat));
+				((char __user *)sfwk_stat + sizeof(*sfwk_stat));
 	lnet_stat = (lnet_counters_t __user *)
-				      ((char *)srpc_stat + sizeof(*srpc_stat));
+				((char __user *)srpc_stat + sizeof(*srpc_stat));
 
 	if (copy_to_user(sfwk_stat, &rep->str_fw, sizeof(*sfwk_stat)) ||
 	    copy_to_user(srpc_stat, &rep->str_rpc, sizeof(*srpc_stat)) ||
-- 
1.9.1

[toc] | [next] | [standalone]


#1333363

FromDan Carpenter <dan.carpenter@oracle.com>
Date2016-02-13 22:50 +0100
Message-ID<r1QeK-1UL-5@gated-at.bofh.it>
In reply to#1333345
On Sat, Feb 13, 2016 at 11:34:35PM +0530, Niranjan Dighe wrote:
> diff --git a/drivers/staging/lustre/lnet/selftest/console.c b/drivers/staging/lustre/lnet/selftest/console.c
> index 366211e..64b6a70 100644
> --- a/drivers/staging/lustre/lnet/selftest/console.c
> +++ b/drivers/staging/lustre/lnet/selftest/console.c
> @@ -1461,9 +1461,9 @@ lstcon_statrpc_readent(int transop, srpc_msg_t *msg,
>  
>  	sfwk_stat = (sfw_counters_t __user *)&ent_up->rpe_payload[0];
>  	srpc_stat = (srpc_counters_t __user *)
> -				      ((char *)sfwk_stat + sizeof(*sfwk_stat));
> +				((char __user *)sfwk_stat + sizeof(*sfwk_stat));

This is uglier than necessary.  Do it either like this:

	srpc_stat = (void __user *)sfwk_stat + sizeof(*sfwk_stat);

Or probably it's actually nicer to say:

	srpc_stat = sfwk_stat + 1;

regards,
dan carpenter

[toc] | [prev] | [next] | [standalone]


#1333408

FromNiranjan Dighe <niranjan.dighe@gmail.com>
Date2016-02-14 03:50 +0100
Message-ID<r1UV3-55l-1@gated-at.bofh.it>
In reply to#1333363
On Sun, Feb 14, 2016 at 3:19 AM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> On Sat, Feb 13, 2016 at 11:34:35PM +0530, Niranjan Dighe wrote:
>> diff --git a/drivers/staging/lustre/lnet/selftest/console.c b/drivers/staging/lustre/lnet/selftest/console.c
>> index 366211e..64b6a70 100644
>> --- a/drivers/staging/lustre/lnet/selftest/console.c
>> +++ b/drivers/staging/lustre/lnet/selftest/console.c
>> @@ -1461,9 +1461,9 @@ lstcon_statrpc_readent(int transop, srpc_msg_t *msg,
>>
>>       sfwk_stat = (sfw_counters_t __user *)&ent_up->rpe_payload[0];
>>       srpc_stat = (srpc_counters_t __user *)
>> -                                   ((char *)sfwk_stat + sizeof(*sfwk_stat));
>> +                             ((char __user *)sfwk_stat + sizeof(*sfwk_stat));
>
> This is uglier than necessary.  Do it either like this:
>
>         srpc_stat = (void __user *)sfwk_stat + sizeof(*sfwk_stat);
>
> Or probably it's actually nicer to say:
>
>         srpc_stat = sfwk_stat + 1;
>
> regards,
> dan carpenter
>

Yes, thanks Dan, I will send out a new patch. Please discard this one.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web