From: Nicholas Mc Guire <der.herr@hofr.at>
To: kernel-janitors@vger.kernel.org
Subject: Re: type mismatch
Date: Mon, 11 May 2015 07:18:19 +0000 [thread overview]
Message-ID: <20150511071819.GB25982@opentech.at> (raw)
In-Reply-To: <alpine.DEB.2.10.1505101517100.2645@hadrien>
On Sun, 10 May 2015, Dan Carpenter wrote:
> I don't really have a strong opinion either way... It's unlikely that
> we will introduce a bug here and if we did, I think it would be caught
> immediately in testing.
>
> It's pretty common to treat the first member of a struct as special.
> What annoys me is when people do
>
> struct foo {
> int one, two, three;
> whatever;
> };
>
> memcpy(&foo.one, src, sizoef(struct foo));
>
> Argh!? These triger buffer overflows warnings in Smatch and I don't
> see the point since &foo.one is less readable than &foo! Oh well, I
> think these were common enough, I had to treat it as idiomatic and add a
> special case for them.
>
just ran a naive scanner for that pattern but only could find this one instance
./net/sctp/sm_make_chunk.c:3103 ugly memset
3102 if (af->is_any(&addr))
3103 memcpy(&addr.v4, sctp_source(asconf), sizeof(addr));
my scanner ist:
@uses_first@
identifier f;
idexpression s;
identifier e;
position p;
@@
f(...){
<+...
* memcpy@p(&s.e,...,sizeof(s));
...+>
}
@script:python@
p << uses_first.p;
@@
print "%s:%s ugly memset" % (p[0].file,p[0].line)
so is my scanner broken/incomplete or has this pattern lost its popularity ?
thx!
hofrat
next prev parent reply other threads:[~2015-05-11 7:18 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-10 13:20 type mismatch Julia Lawall
2015-05-10 19:57 ` Dan Carpenter
2015-05-10 20:03 ` Julia Lawall
2015-05-11 7:18 ` Nicholas Mc Guire [this message]
2015-05-11 7:32 ` Julia Lawall
2015-05-11 8:14 ` Dan Carpenter
2015-05-11 8:29 ` Nicholas Mc Guire
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=20150511071819.GB25982@opentech.at \
--to=der.herr@hofr.at \
--cc=kernel-janitors@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