* [PATCH] staging: lustre/lnet: Fix wrong type casting warning generated by sparse
@ 2016-02-13 18:04 Niranjan Dighe
2016-02-13 21:49 ` Dan Carpenter
0 siblings, 1 reply; 3+ messages in thread
From: Niranjan Dighe @ 2016-02-13 18:04 UTC (permalink / raw)
To: Oleg Drokin, Andreas Dilger, Greg Kroah-Hartman, Shivani Bhardwaj,
Dmitry Eremin, Mike Rapoport, Shraddha Barke, Frank Zago,
Hatice ERTÜRK, Mike Shuey
Cc: lustre-devel, devel, linux-kernel
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] staging: lustre/lnet: Fix wrong type casting warning generated by sparse
2016-02-13 18:04 [PATCH] staging: lustre/lnet: Fix wrong type casting warning generated by sparse Niranjan Dighe
@ 2016-02-13 21:49 ` Dan Carpenter
2016-02-14 2:45 ` Niranjan Dighe
0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2016-02-13 21:49 UTC (permalink / raw)
To: Niranjan Dighe
Cc: Oleg Drokin, Andreas Dilger, Greg Kroah-Hartman, Shivani Bhardwaj,
Dmitry Eremin, Mike Rapoport, Shraddha Barke, Frank Zago,
Hatice ERTÜRK, Mike Shuey, devel, linux-kernel, lustre-devel
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] staging: lustre/lnet: Fix wrong type casting warning generated by sparse
2016-02-13 21:49 ` Dan Carpenter
@ 2016-02-14 2:45 ` Niranjan Dighe
0 siblings, 0 replies; 3+ messages in thread
From: Niranjan Dighe @ 2016-02-14 2:45 UTC (permalink / raw)
To: Dan Carpenter
Cc: Oleg Drokin, Andreas Dilger, Greg Kroah-Hartman, Shivani Bhardwaj,
Dmitry Eremin, Mike Rapoport, Shraddha Barke, Frank Zago,
Hatice ERTÜRK, Mike Shuey, devel, linux-kernel, lustre-devel
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.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-02-14 2:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-13 18:04 [PATCH] staging: lustre/lnet: Fix wrong type casting warning generated by sparse Niranjan Dighe
2016-02-13 21:49 ` Dan Carpenter
2016-02-14 2:45 ` Niranjan Dighe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox