* [Cocci] Fwd: Re: sizeof (struct tYpO *) : it is just a typo or rather a bug ?
[not found] <20140725112038.GA401@khazad-dum.debian.net>
@ 2014-07-28 17:21 ` Toralf Förster
2014-07-28 20:13 ` Julia Lawall
0 siblings, 1 reply; 6+ messages in thread
From: Toralf Förster @ 2014-07-28 17:21 UTC (permalink / raw)
To: cocci
Hi Dear cocci,
may I forward to you this email from the LKML, Henrique thinks, that that issue worth a coccinelle patch
:-D
-------- Original Message --------
Subject: Re: sizeof (struct tYpO *) : it is just a typo or rather a bug ?
Date: Fri, 25 Jul 2014 08:20:39 -0300
From: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
To: Toralf F?rster <toralf.foerster@gmx.de>
CC: linux-ia64 at vger.kernel.org, ceph-devel at vger.kernel.org, Linux Kernel <linux-kernel@vger.kernel.org>
On Thu, 24 Jul 2014, Toralf F?rster wrote:
> Inspired by this "typo" fix
> http://article.gmane.org/gmane.linux.kernel/1754640
> I grep'ed the current git tree of linus for similar issues.
I wonder if we couldn't use Coccinelle to do that? I would say it would be
not as cool as deep grep magick, but Coccinelle is cool by definition and
therefore immune from any such comparisons :-)
> Nevertheless I was told, that gcc doesn't complain about such things due
> to eventually evaluating it to "sizeof(null)". I'm however curious if at
> least a warning should be emitted in such a case, or?
Well, it cannot become a real bug because the moment the code changes to
actually access/derreference such a typo, it will cause the compiler to
abort with an error. If gcc will have to waste a measurable amount of time
to issue such a warning, it is not worth it.
OTOH, such typos could confuse someone reading the code into thinking
they're dealing with a different structure or something, and it _is_
incorrect code no matter how harmless, so it makes sense to fix all such
typos eventually.
--
"One disk to rule them all, One disk to find them. One disk to bring
them all and in the darkness grind them. In the Land of Redmond
where the shadows lie." -- The Silicon Valley Tarot
Henrique Holschuh
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Cocci] Fwd: Re: sizeof (struct tYpO *) : it is just a typo or rather a bug ?
2014-07-28 17:21 ` [Cocci] Fwd: Re: sizeof (struct tYpO *) : it is just a typo or rather a bug ? Toralf Förster
@ 2014-07-28 20:13 ` Julia Lawall
2014-07-28 20:41 ` Toralf Förster
0 siblings, 1 reply; 6+ messages in thread
From: Julia Lawall @ 2014-07-28 20:13 UTC (permalink / raw)
To: cocci
Thanks for the forward. It should be possible to do something with
Coccinelle.
How did you use grep, though?
julia
On Mon, 28 Jul 2014, Toralf F?rster wrote:
> Hi Dear cocci,
>
> may I forward to you this email from the LKML, Henrique thinks, that that issue worth a coccinelle patch
> :-D
>
>
> -------- Original Message --------
> Subject: Re: sizeof (struct tYpO *) : it is just a typo or rather a bug ?
> Date: Fri, 25 Jul 2014 08:20:39 -0300
> From: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
> To: Toralf F?rster <toralf.foerster@gmx.de>
> CC: linux-ia64 at vger.kernel.org, ceph-devel at vger.kernel.org, Linux Kernel <linux-kernel@vger.kernel.org>
>
> On Thu, 24 Jul 2014, Toralf F?rster wrote:
> > Inspired by this "typo" fix
> > http://article.gmane.org/gmane.linux.kernel/1754640
> > I grep'ed the current git tree of linus for similar issues.
>
> I wonder if we couldn't use Coccinelle to do that? I would say it would be
> not as cool as deep grep magick, but Coccinelle is cool by definition and
> therefore immune from any such comparisons :-)
>
> > Nevertheless I was told, that gcc doesn't complain about such things due
> > to eventually evaluating it to "sizeof(null)". I'm however curious if at
> > least a warning should be emitted in such a case, or?
>
> Well, it cannot become a real bug because the moment the code changes to
> actually access/derreference such a typo, it will cause the compiler to
> abort with an error. If gcc will have to waste a measurable amount of time
> to issue such a warning, it is not worth it.
>
> OTOH, such typos could confuse someone reading the code into thinking
> they're dealing with a different structure or something, and it _is_
> incorrect code no matter how harmless, so it makes sense to fix all such
> typos eventually.
>
> --
> "One disk to rule them all, One disk to find them. One disk to bring
> them all and in the darkness grind them. In the Land of Redmond
> where the shadows lie." -- The Silicon Valley Tarot
> Henrique Holschuh
>
>
>
> _______________________________________________
> Cocci mailing list
> Cocci at systeme.lip6.fr
> https://systeme.lip6.fr/mailman/listinfo/cocci
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Cocci] Fwd: Re: sizeof (struct tYpO *) : it is just a typo or rather a bug ?
2014-07-28 20:13 ` Julia Lawall
@ 2014-07-28 20:41 ` Toralf Förster
2014-07-28 20:50 ` Julia Lawall
0 siblings, 1 reply; 6+ messages in thread
From: Toralf Förster @ 2014-07-28 20:41 UTC (permalink / raw)
To: cocci
On 07/28/2014 10:13 PM, Julia Lawall wrote:
> Thanks for the forward. It should be possible to do something with
> Coccinelle.
>
> How did you use grep, though?
>
> julia
>
1:
grep -Hr "sizeof[ *(]struct .* \*.)" | cut -f2- -d':' | tee ~/tmp/out
2:
cat ~/tmp/out | perl -wane 'chomp(); my ($left, $right) = split (/sizeof\(/); print $right, "\n";' | cut -f2 -d' ' | sort -u | cut -f1 -d')' | grep -v '^+' | while read i; do echo $i; git grep -q "struct $i {" || echo error; echo; done
3:
ignore false positives
> On Mon, 28 Jul 2014, Toralf F?rster wrote:
>
>> Hi Dear cocci,
>>
>> may I forward to you this email from the LKML, Henrique thinks, that that issue worth a coccinelle patch
>> :-D
>>
>>
>> -------- Original Message --------
>> Subject: Re: sizeof (struct tYpO *) : it is just a typo or rather a bug ?
>> Date: Fri, 25 Jul 2014 08:20:39 -0300
>> From: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
>> To: Toralf F?rster <toralf.foerster@gmx.de>
>> CC: linux-ia64 at vger.kernel.org, ceph-devel at vger.kernel.org, Linux Kernel <linux-kernel@vger.kernel.org>
>>
>> On Thu, 24 Jul 2014, Toralf F?rster wrote:
>>> Inspired by this "typo" fix
>>> http://article.gmane.org/gmane.linux.kernel/1754640
>>> I grep'ed the current git tree of linus for similar issues.
>>
>> I wonder if we couldn't use Coccinelle to do that? I would say it would be
>> not as cool as deep grep magick, but Coccinelle is cool by definition and
>> therefore immune from any such comparisons :-)
>>
>>> Nevertheless I was told, that gcc doesn't complain about such things due
>>> to eventually evaluating it to "sizeof(null)". I'm however curious if at
>>> least a warning should be emitted in such a case, or?
>>
>> Well, it cannot become a real bug because the moment the code changes to
>> actually access/derreference such a typo, it will cause the compiler to
>> abort with an error. If gcc will have to waste a measurable amount of time
>> to issue such a warning, it is not worth it.
>>
>> OTOH, such typos could confuse someone reading the code into thinking
>> they're dealing with a different structure or something, and it _is_
>> incorrect code no matter how harmless, so it makes sense to fix all such
>> typos eventually.
>>
>> --
>> "One disk to rule them all, One disk to find them. One disk to bring
>> them all and in the darkness grind them. In the Land of Redmond
>> where the shadows lie." -- The Silicon Valley Tarot
>> Henrique Holschuh
>>
>>
>>
>> _______________________________________________
>> Cocci mailing list
>> Cocci at systeme.lip6.fr
>> https://systeme.lip6.fr/mailman/listinfo/cocci
--
Toralf
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Cocci] Fwd: Re: sizeof (struct tYpO *) : it is just a typo or rather a bug ?
2014-07-28 20:41 ` Toralf Förster
@ 2014-07-28 20:50 ` Julia Lawall
2014-07-28 21:20 ` Toralf Förster
0 siblings, 1 reply; 6+ messages in thread
From: Julia Lawall @ 2014-07-28 20:50 UTC (permalink / raw)
To: cocci
On Mon, 28 Jul 2014, Toralf F?rster wrote:
> On 07/28/2014 10:13 PM, Julia Lawall wrote:
> > Thanks for the forward. It should be possible to do something with
> > Coccinelle.
> >
> > How did you use grep, though?
> >
> > julia
> >
> 1:
> grep -Hr "sizeof[ *(]struct .* \*.)" | cut -f2- -d':' | tee ~/tmp/out
>
> 2:
> cat ~/tmp/out | perl -wane 'chomp(); my ($left, $right) = split (/sizeof\(/); print $right, "\n";' | cut -f2 -d' ' | sort -u | cut -f1 -d')' | grep -v '^+' | while read i; do echo $i; git grep -q "struct $i {" || echo error; echo; done
>
> 3:
> ignore false positives
OK :)
julia
>
>
> > On Mon, 28 Jul 2014, Toralf F?rster wrote:
> >
> >> Hi Dear cocci,
> >>
> >> may I forward to you this email from the LKML, Henrique thinks, that that issue worth a coccinelle patch
> >> :-D
> >>
> >>
> >> -------- Original Message --------
> >> Subject: Re: sizeof (struct tYpO *) : it is just a typo or rather a bug ?
> >> Date: Fri, 25 Jul 2014 08:20:39 -0300
> >> From: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
> >> To: Toralf F?rster <toralf.foerster@gmx.de>
> >> CC: linux-ia64 at vger.kernel.org, ceph-devel at vger.kernel.org, Linux Kernel <linux-kernel@vger.kernel.org>
> >>
> >> On Thu, 24 Jul 2014, Toralf F?rster wrote:
> >>> Inspired by this "typo" fix
> >>> http://article.gmane.org/gmane.linux.kernel/1754640
> >>> I grep'ed the current git tree of linus for similar issues.
> >>
> >> I wonder if we couldn't use Coccinelle to do that? I would say it would be
> >> not as cool as deep grep magick, but Coccinelle is cool by definition and
> >> therefore immune from any such comparisons :-)
> >>
> >>> Nevertheless I was told, that gcc doesn't complain about such things due
> >>> to eventually evaluating it to "sizeof(null)". I'm however curious if at
> >>> least a warning should be emitted in such a case, or?
> >>
> >> Well, it cannot become a real bug because the moment the code changes to
> >> actually access/derreference such a typo, it will cause the compiler to
> >> abort with an error. If gcc will have to waste a measurable amount of time
> >> to issue such a warning, it is not worth it.
> >>
> >> OTOH, such typos could confuse someone reading the code into thinking
> >> they're dealing with a different structure or something, and it _is_
> >> incorrect code no matter how harmless, so it makes sense to fix all such
> >> typos eventually.
> >>
> >> --
> >> "One disk to rule them all, One disk to find them. One disk to bring
> >> them all and in the darkness grind them. In the Land of Redmond
> >> where the shadows lie." -- The Silicon Valley Tarot
> >> Henrique Holschuh
> >>
> >>
> >>
> >> _______________________________________________
> >> Cocci mailing list
> >> Cocci at systeme.lip6.fr
> >> https://systeme.lip6.fr/mailman/listinfo/cocci
>
>
> --
> Toralf
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Cocci] Fwd: Re: sizeof (struct tYpO *) : it is just a typo or rather a bug ?
2014-07-28 20:50 ` Julia Lawall
@ 2014-07-28 21:20 ` Toralf Förster
2014-07-29 5:49 ` Julia Lawall
0 siblings, 1 reply; 6+ messages in thread
From: Toralf Förster @ 2014-07-28 21:20 UTC (permalink / raw)
To: cocci
On 07/28/2014 10:50 PM, Julia Lawall wrote:
> OK :)
>
> julia
Hi
;)
BTW, 3 of the 4 mentioned places I found in the kernel sources with that procedure were confirmed to be real errors - 1 feedback is still awaiting.
--
Toralf
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Cocci] Fwd: Re: sizeof (struct tYpO *) : it is just a typo or rather a bug ?
2014-07-28 21:20 ` Toralf Förster
@ 2014-07-29 5:49 ` Julia Lawall
0 siblings, 0 replies; 6+ messages in thread
From: Julia Lawall @ 2014-07-29 5:49 UTC (permalink / raw)
To: cocci
This is clearly a typo:
drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c
vpfe_dev->clks = kzalloc(vpfe_cfg->num_clocks *
sizeof(struct clock *), GFP_KERNEL);
I also found:
fs/reiserfs/resize.c
copy_size =
copy_size * sizeof(struct reiserfs_list_bitmap_node *);
and
drivers/net/ethernet/intel/i40e/i40e_main.c
size = sizeof(struct i40e_q_vectors *) * vsi->num_q_vectors;
but I'm not sure about them. Also some other results that I haven't had a
chance to look at yet.
julia
On Mon, 28 Jul 2014, Toralf F?rster wrote:
> On 07/28/2014 10:50 PM, Julia Lawall wrote:
> > OK :)
> >
> > julia
>
> Hi
> ;)
>
> BTW, 3 of the 4 mentioned places I found in the kernel sources with that procedure were confirmed to be real errors - 1 feedback is still awaiting.
>
>
> --
> Toralf
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-07-29 5:49 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20140725112038.GA401@khazad-dum.debian.net>
2014-07-28 17:21 ` [Cocci] Fwd: Re: sizeof (struct tYpO *) : it is just a typo or rather a bug ? Toralf Förster
2014-07-28 20:13 ` Julia Lawall
2014-07-28 20:41 ` Toralf Förster
2014-07-28 20:50 ` Julia Lawall
2014-07-28 21:20 ` Toralf Förster
2014-07-29 5:49 ` Julia Lawall
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox