staging: lustre/lnet: Fix wrong typecasting warning generated by sparse
authorNiranjan Dighe <niranjan.dighe@gmail.com>
Sun, 14 Feb 2016 03:21:48 +0000 (08:51 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 15 Feb 2016 00:21:15 +0000 (16:21 -0800)
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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/lustre/lnet/selftest/console.c

index 59cd554e47b91d0366ea36869e104e4c3fd36fa9..54fb1ab521bd2cb96bc02a63b3d4674608435f82 100644 (file)
@@ -1462,10 +1462,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)) ||