From: Niranjan Dighe <niranjan.dighe@gmail.com>
To: "Oleg Drokin" <oleg.drokin@intel.com>,
"Andreas Dilger" <andreas.dilger@intel.com>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Shivani Bhardwaj" <shivanib134@gmail.com>,
"Dmitry Eremin" <dmitry.eremin@intel.com>,
"Mike Rapoport" <mike.rapoport@gmail.com>,
"Shraddha Barke" <shraddha.6596@gmail.com>,
"Frank Zago" <fzago@cray.com>,
"Hatice ERTÜRK" <haticeerturk27@gmail.com>,
"Mike Shuey" <shuey@purdue.edu>
Cc: lustre-devel@lists.lustre.org, devel@driverdev.osuosl.org,
linux-kernel@vger.kernel.org
Subject: [lustre-devel] [PATCH] staging: lustre/lnet: Fix wrong typecasting warning generated by sparse
Date: Sun, 14 Feb 2016 08:51:48 +0530 [thread overview]
Message-ID: <20160214032148.GA19507@codebox> (raw)
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
WARNING: multiple messages have this Message-ID (diff)
From: Niranjan Dighe <niranjan.dighe@gmail.com>
To: "Oleg Drokin" <oleg.drokin@intel.com>,
"Andreas Dilger" <andreas.dilger@intel.com>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Shivani Bhardwaj" <shivanib134@gmail.com>,
"Dmitry Eremin" <dmitry.eremin@intel.com>,
"Mike Rapoport" <mike.rapoport@gmail.com>,
"Shraddha Barke" <shraddha.6596@gmail.com>,
"Frank Zago" <fzago@cray.com>,
"Hatice ERTÜRK" <haticeerturk27@gmail.com>,
"Mike Shuey" <shuey@purdue.edu>
Cc: lustre-devel@lists.lustre.org, devel@driverdev.osuosl.org,
linux-kernel@vger.kernel.org
Subject: [PATCH] staging: lustre/lnet: Fix wrong typecasting warning generated by sparse
Date: Sun, 14 Feb 2016 08:51:48 +0530 [thread overview]
Message-ID: <20160214032148.GA19507@codebox> (raw)
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
next reply other threads:[~2016-02-14 3:21 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-14 3:21 Niranjan Dighe [this message]
2016-02-14 3:21 ` [PATCH] staging: lustre/lnet: Fix wrong typecasting warning generated by sparse Niranjan Dighe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160214032148.GA19507@codebox \
--to=niranjan.dighe@gmail.com \
--cc=andreas.dilger@intel.com \
--cc=devel@driverdev.osuosl.org \
--cc=dmitry.eremin@intel.com \
--cc=fzago@cray.com \
--cc=gregkh@linuxfoundation.org \
--cc=haticeerturk27@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lustre-devel@lists.lustre.org \
--cc=mike.rapoport@gmail.com \
--cc=oleg.drokin@intel.com \
--cc=shivanib134@gmail.com \
--cc=shraddha.6596@gmail.com \
--cc=shuey@purdue.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.