From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicholas Mc Guire Date: Mon, 11 May 2015 07:18:19 +0000 Subject: Re: type mismatch Message-Id: <20150511071819.GB25982@opentech.at> List-Id: References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: kernel-janitors@vger.kernel.org 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