From: Ben Hutchings <bhutchings@solarflare.com>
To: Joe Perches <joe@perches.com>
Cc: "David S. Miller" <davem@davemloft.net>, <netdev@vger.kernel.org>
Subject: Re: [PATCH] net: Remove casts to same type
Date: Mon, 4 Jun 2012 17:04:41 +0100 [thread overview]
Message-ID: <1338825881.3979.203.camel@deadeye> (raw)
In-Reply-To: <4b3738493b23bc386d3372012faa8cd3672a138d.1338780551.git.joe@perches.com>
On Sun, 2012-06-03 at 20:41 -0700, Joe Perches wrote:
> Adding casts of objects to the same type is unnecessary
> and confusing for a human reader.
>
> For example, this cast:
>
> int y;
> int *p = (int *)&y;
>
> I used the coccinelle script below to find and remove these
> unnecessary casts. I manually removed the conversions this
> script produces of casts with __force and __user.
[...]
> diff --git a/net/9p/client.c b/net/9p/client.c
> index a170893..5cbea90 100644
> --- a/net/9p/client.c
> +++ b/net/9p/client.c
> @@ -1548,7 +1548,7 @@ p9_client_read(struct p9_fid *fid, char *data, char __user *udata, u64 offset,
> kernel_buf = 1;
> indata = data;
> } else
> - indata = (char *)udata;
> + indata = udata;
> /*
> * response header len is 11
> * PDU Header(7) + IO Size (4)
[...]
This one is casting char __user * to char *. We need a cast to let
sparse know this is deliberate, though presumably we need __force as
well.
Ben.
--
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
next prev parent reply other threads:[~2012-06-04 16:04 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-04 3:41 [PATCH] net: Remove casts to same type Joe Perches
2012-06-04 15:45 ` David Miller
2012-06-04 15:52 ` Joe Perches
2012-06-04 15:53 ` David Miller
2012-06-04 16:04 ` Ben Hutchings [this message]
2012-06-04 17:16 ` [PATCH] net/9p: Add __force to cast of __user pointer Joe Perches
2012-06-04 18:12 ` David Miller
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=1338825881.3979.203.camel@deadeye \
--to=bhutchings@solarflare.com \
--cc=davem@davemloft.net \
--cc=joe@perches.com \
--cc=netdev@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).