Netdev List
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Alexander Duyck <alexander.h.duyck@intel.com>
Cc: Krzysztof Majzerowicz-Jaszcz <cristos@vipserv.org>,
	jeffrey.t.kirsher@intel.com, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drivers: net: ethernet: intel: e1000: e1000_ethtool.c coding style fixes
Date: Mon, 18 Aug 2014 09:29:39 -0700	[thread overview]
Message-ID: <1408379379.2741.9.camel@joe-AO725> (raw)
In-Reply-To: <53F21FB1.7060607@intel.com>

On Mon, 2014-08-18 at 08:45 -0700, Alexander Duyck wrote:
> On 08/18/2014 08:31 AM, Joe Perches wrote:
> > On Mon, 2014-08-18 at 08:29 -0700, Alexander Duyck wrote:
> >> Doing any kind of pointer math on a void pointer is generally unsafe as
> >> it is an incomplete type.  The only reason why it works in GCC is
> >> because GCC has a nonstandard extension that makes it report as having a
> >> size of 1.
> > 
> > I know.  It's used in quite a few places in kernel code
> > so I believe it's now a base assumption for the kernel.
> 
> Well that is something that should probably be fixed then.  I don't
> believe it is safe to be doing any kind of pointer math on a void pointer.
> 
> We really shouldn't be using any GCC specific bits unless we absolutely
> have to.

Good luck with that.

Here's a little coccinelle script to find them:

$ cat void_arithmetic.spatch
@@
void *p;
expression e;
@@

*	p + e
$

There are at least 23 uses just in lib/

$ spatch -sp_file void_arithmetic.spatch lib | \
  grep "^\-[^\-]" | wc -l
23

I'm fairly confident there are more than that,
but using spatch with --recursive-includes is
pretty slow on my machine.

      reply	other threads:[~2014-08-18 16:29 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-16  9:12 [PATCH] drivers: net: ethernet: intel: e1000: e1000_ethtool.c coding style fixes Krzysztof Majzerowicz-Jaszcz
2014-08-16 18:41 ` Joe Perches
2014-08-18 15:29   ` Alexander Duyck
2014-08-18 15:31     ` Joe Perches
2014-08-18 15:36       ` Krzysztof Majzerowicz-Jaszcz
2014-08-18 15:40         ` Joe Perches
2014-08-18 15:43           ` Krzysztof Majzerowicz-Jaszcz
2014-08-18 15:45       ` Alexander Duyck
2014-08-18 16:29         ` Joe Perches [this message]

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=1408379379.2741.9.camel@joe-AO725 \
    --to=joe@perches.com \
    --cc=alexander.h.duyck@intel.com \
    --cc=cristos@vipserv.org \
    --cc=jeffrey.t.kirsher@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --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