public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: lustre/lnet: Fix wrong typecasting warning generated by sparse
@ 2016-02-14  3:21 Niranjan Dighe
  0 siblings, 0 replies; only message in thread
From: Niranjan Dighe @ 2016-02-14  3:21 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

Fix the following warning generated about type casting by sparse

warning: cast removes address space of expression

The current implementation casts the structure pointers with (char *)
without __user annotation and then adds sizeof struct to it, thereby
generating the sparse warning. Fixed this by removing the unnecessary
char pointer type cast.

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

diff --git a/drivers/staging/lustre/lnet/selftest/console.c b/drivers/staging/lustre/lnet/selftest/console.c
index 366211e..bc236c9 100644
--- a/drivers/staging/lustre/lnet/selftest/console.c
+++ b/drivers/staging/lustre/lnet/selftest/console.c
@@ -1460,10 +1460,8 @@ lstcon_statrpc_readent(int transop, srpc_msg_t *msg,
 		return 0;
 
 	sfwk_stat = (sfw_counters_t __user *)&ent_up->rpe_payload[0];
-	srpc_stat = (srpc_counters_t __user *)
-				      ((char *)sfwk_stat + sizeof(*sfwk_stat));
-	lnet_stat = (lnet_counters_t __user *)
-				      ((char *)srpc_stat + sizeof(*srpc_stat));
+	srpc_stat = (srpc_counters_t __user *)(sfwk_stat + 1);
+	lnet_stat = (lnet_counters_t __user *)(srpc_stat + 1);
 
 	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] only message in thread

only message in thread, other threads:[~2016-02-14  3:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-14  3:21 [PATCH] staging: lustre/lnet: Fix wrong typecasting warning generated by sparse Niranjan Dighe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox