From: bernd@petrovitsch.priv.at (Bernd Petrovitsch)
To: cocci@systeme.lip6.fr
Subject: [Cocci] [PATCH] Coccicheck: Remove memcpy to struct assignment test
Date: Wed, 19 Mar 2014 15:05:27 +0100 [thread overview]
Message-ID: <1395237927.12633.29.camel@thorin> (raw)
In-Reply-To: <CA+MoWDoSYu-aSp39vBe7DmayH2iqagHNYP9BC7LefajMXk+FnQ@mail.gmail.com>
Hi!
On Mit, 2014-03-19 at 14:39 +0100, Peter Senna Tschudin wrote:
> On Wed, Mar 19, 2014 at 1:02 PM, Bernd Petrovitsch
> <bernd@petrovitsch.priv.at> wrote:
> > On Die, 2014-03-18 at 22:11 +0100, Peter Senna Tschudin wrote:
> >> The Coccinelle script scripts/coccinelle/misc/memcpy-assign.cocci look
> >> for opportunities to replace a call to memcpy by a struct assignment.
> >> This patch removes memcpy-assign.cocci as it is not clear that this
> >> convention has an impact on the generated code.
> >
> > Using struct assignment keeps the type check and is just for this reason
> > always preferable over memcpy().
> What about the assignment hiding that a potentially large memcpy is
> happening instead of just a pointer assignment?
It makes no difference if you copy 2KB with a struct assignment or with
a memcpy(). IMHO most probably each and every C compiler produces the
same code for both cases.
And - more important - I assume that people which actually read the code
(to understand the code) also know if the variables there are
pointers/ints or a (somewhat large) struct (if only one see an field
access in the struct, it should be pretty clear).
I don't think it makes actually much sense trying to read source without
that ....
Bernd
--
Bernd Petrovitsch Email : bernd at petrovitsch.priv.at
LUGA : http://www.luga.at
WARNING: multiple messages have this Message-ID (diff)
From: Bernd Petrovitsch <bernd@petrovitsch.priv.at>
To: cocci@systeme.lip6.fr
Subject: Re: [PATCH] Coccicheck: Remove memcpy to struct assignment test
Date: Wed, 19 Mar 2014 14:05:27 +0000 [thread overview]
Message-ID: <1395237927.12633.29.camel@thorin> (raw)
In-Reply-To: <CA+MoWDoSYu-aSp39vBe7DmayH2iqagHNYP9BC7LefajMXk+FnQ@mail.gmail.com>
Hi!
On Mit, 2014-03-19 at 14:39 +0100, Peter Senna Tschudin wrote:
> On Wed, Mar 19, 2014 at 1:02 PM, Bernd Petrovitsch
> <bernd@petrovitsch.priv.at> wrote:
> > On Die, 2014-03-18 at 22:11 +0100, Peter Senna Tschudin wrote:
> >> The Coccinelle script scripts/coccinelle/misc/memcpy-assign.cocci look
> >> for opportunities to replace a call to memcpy by a struct assignment.
> >> This patch removes memcpy-assign.cocci as it is not clear that this
> >> convention has an impact on the generated code.
> >
> > Using struct assignment keeps the type check and is just for this reason
> > always preferable over memcpy().
> What about the assignment hiding that a potentially large memcpy is
> happening instead of just a pointer assignment?
It makes no difference if you copy 2KB with a struct assignment or with
a memcpy(). IMHO most probably each and every C compiler produces the
same code for both cases.
And - more important - I assume that people which actually read the code
(to understand the code) also know if the variables there are
pointers/ints or a (somewhat large) struct (if only one see an field
access in the struct, it should be pretty clear).
I don't think it makes actually much sense trying to read source without
that ....
Bernd
--
Bernd Petrovitsch Email : bernd@petrovitsch.priv.at
LUGA : http://www.luga.at
WARNING: multiple messages have this Message-ID (diff)
From: Bernd Petrovitsch <bernd@petrovitsch.priv.at>
To: Peter Senna Tschudin <peter.senna@gmail.com>
Cc: Julia Lawall <Julia.Lawall@lip6.fr>,
Gilles Muller <Gilles.Muller@lip6.fr>,
Nicolas Palix <nicolas.palix@imag.fr>,
mmarek@suse.cz,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"cocci@systeme.lip6.fr" <cocci@systeme.lip6.fr>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Andreea Bernat <bernat.ada@gmail.com>,
Ezequiel Garcia <elezegarcia@gmail.com>,
kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] Coccicheck: Remove memcpy to struct assignment test
Date: Wed, 19 Mar 2014 15:05:27 +0100 [thread overview]
Message-ID: <1395237927.12633.29.camel@thorin> (raw)
In-Reply-To: <CA+MoWDoSYu-aSp39vBe7DmayH2iqagHNYP9BC7LefajMXk+FnQ@mail.gmail.com>
Hi!
On Mit, 2014-03-19 at 14:39 +0100, Peter Senna Tschudin wrote:
> On Wed, Mar 19, 2014 at 1:02 PM, Bernd Petrovitsch
> <bernd@petrovitsch.priv.at> wrote:
> > On Die, 2014-03-18 at 22:11 +0100, Peter Senna Tschudin wrote:
> >> The Coccinelle script scripts/coccinelle/misc/memcpy-assign.cocci look
> >> for opportunities to replace a call to memcpy by a struct assignment.
> >> This patch removes memcpy-assign.cocci as it is not clear that this
> >> convention has an impact on the generated code.
> >
> > Using struct assignment keeps the type check and is just for this reason
> > always preferable over memcpy().
> What about the assignment hiding that a potentially large memcpy is
> happening instead of just a pointer assignment?
It makes no difference if you copy 2KB with a struct assignment or with
a memcpy(). IMHO most probably each and every C compiler produces the
same code for both cases.
And - more important - I assume that people which actually read the code
(to understand the code) also know if the variables there are
pointers/ints or a (somewhat large) struct (if only one see an field
access in the struct, it should be pretty clear).
I don't think it makes actually much sense trying to read source without
that ....
Bernd
--
Bernd Petrovitsch Email : bernd@petrovitsch.priv.at
LUGA : http://www.luga.at
next prev parent reply other threads:[~2014-03-19 14:05 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-18 21:11 [Cocci] [PATCH] Coccicheck: Remove memcpy to struct assignment test Peter Senna Tschudin
2014-03-18 21:11 ` Peter Senna Tschudin
2014-03-18 21:11 ` Peter Senna Tschudin
2014-03-19 12:02 ` [Cocci] " Bernd Petrovitsch
2014-03-19 12:02 ` Bernd Petrovitsch
2014-03-19 12:02 ` Bernd Petrovitsch
2014-03-19 13:39 ` [Cocci] " Peter Senna Tschudin
2014-03-19 13:39 ` Peter Senna Tschudin
2014-03-19 13:39 ` Peter Senna Tschudin
2014-03-19 14:05 ` Bernd Petrovitsch [this message]
2014-03-19 14:05 ` Bernd Petrovitsch
2014-03-19 14:05 ` Bernd Petrovitsch
2014-03-19 16:48 ` [Cocci] " Greg Kroah-Hartman
2014-03-19 16:48 ` Greg Kroah-Hartman
2014-03-19 16:48 ` Greg Kroah-Hartman
2014-03-29 20:37 ` [Cocci] " Michal Marek
2014-03-29 20:37 ` Michal Marek
2014-03-29 20:37 ` Michal Marek
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=1395237927.12633.29.camel@thorin \
--to=bernd@petrovitsch.priv.at \
--cc=cocci@systeme.lip6.fr \
/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.