All of lore.kernel.org
 help / color / mirror / Atom feed
* sizeof (struct tYpO *) : it is just a typo or rather a bug ?
@ 2014-07-24 18:20 ` Toralf Förster
  0 siblings, 0 replies; 17+ messages in thread
From: Toralf Förster @ 2014-07-24 18:20 UTC (permalink / raw)
  To: linux-ia64, ceph-devel; +Cc: Linux Kernel

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.

For these 4 places I'm wondering where the appropriate struct definition is located :

arch/ia64/sn/kernel/io_acpi_init.c:         sizeof(struct pci_devdev_info *)) {
tools/perf/builtin-sched.c:     sched->tasks = realloc(sched->tasks, sched->nr_tasks * sizeof(struct task_task *));
fs/ceph/xattr.c:                xattrs = kcalloc(numattr, sizeof(struct ceph_xattr *),
fs/ceph/xattr.c:                memset(xattrs, 0, numattr*sizeof(struct ceph_xattr *));

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?

-- 
Toralf


^ permalink raw reply	[flat|nested] 17+ messages in thread

* sizeof (struct tYpO *) : it is just a typo or rather a bug ?
@ 2014-07-24 18:20 ` Toralf Förster
  0 siblings, 0 replies; 17+ messages in thread
From: Toralf Förster @ 2014-07-24 18:20 UTC (permalink / raw)
  To: linux-ia64, ceph-devel; +Cc: Linux Kernel

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.

For these 4 places I'm wondering where the appropriate struct definition is located :

arch/ia64/sn/kernel/io_acpi_init.c:         sizeof(struct pci_devdev_info *)) {
tools/perf/builtin-sched.c:     sched->tasks = realloc(sched->tasks, sched->nr_tasks * sizeof(struct task_task *));
fs/ceph/xattr.c:                xattrs = kcalloc(numattr, sizeof(struct ceph_xattr *),
fs/ceph/xattr.c:                memset(xattrs, 0, numattr*sizeof(struct ceph_xattr *));

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?

-- 
Toralf


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: sizeof (struct tYpO *) : it is just a typo or rather a bug ?
  2014-07-24 18:20 ` Toralf Förster
  (?)
@ 2014-07-24 18:33   ` Ilya Dryomov
  -1 siblings, 0 replies; 17+ messages in thread
From: Ilya Dryomov @ 2014-07-24 18:33 UTC (permalink / raw)
  To: Toralf Förster; +Cc: linux-ia64, Ceph Development, Linux Kernel

On Thu, Jul 24, 2014 at 10:20 PM, Toralf Förster <toralf.foerster@gmx.de> 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.
>
> For these 4 places I'm wondering where the appropriate struct definition is located :
>
> arch/ia64/sn/kernel/io_acpi_init.c:         sizeof(struct pci_devdev_info *)) {
> tools/perf/builtin-sched.c:     sched->tasks = realloc(sched->tasks, sched->nr_tasks * sizeof(struct task_task *));
> fs/ceph/xattr.c:                xattrs = kcalloc(numattr, sizeof(struct ceph_xattr *),
> fs/ceph/xattr.c:                memset(xattrs, 0, numattr*sizeof(struct ceph_xattr *));

Heh, the ceph one is a five year old typo..  Looks like it should be
struct ceph_inode_xattr, I'll fix it up.  I'm curious though, how did
you grep for these?

Thanks,

                Ilya

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: sizeof (struct tYpO *) : it is just a typo or rather a bug ?
@ 2014-07-24 18:33   ` Ilya Dryomov
  0 siblings, 0 replies; 17+ messages in thread
From: Ilya Dryomov @ 2014-07-24 18:33 UTC (permalink / raw)
  To: Toralf Förster; +Cc: linux-ia64, Ceph Development, Linux Kernel

On Thu, Jul 24, 2014 at 10:20 PM, Toralf Förster <toralf.foerster@gmx.de> 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.
>
> For these 4 places I'm wondering where the appropriate struct definition is located :
>
> arch/ia64/sn/kernel/io_acpi_init.c:         sizeof(struct pci_devdev_info *)) {
> tools/perf/builtin-sched.c:     sched->tasks = realloc(sched->tasks, sched->nr_tasks * sizeof(struct task_task *));
> fs/ceph/xattr.c:                xattrs = kcalloc(numattr, sizeof(struct ceph_xattr *),
> fs/ceph/xattr.c:                memset(xattrs, 0, numattr*sizeof(struct ceph_xattr *));

Heh, the ceph one is a five year old typo..  Looks like it should be
struct ceph_inode_xattr, I'll fix it up.  I'm curious though, how did
you grep for these?

Thanks,

                Ilya
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: sizeof (struct tYpO *) : it is just a typo or rather a bug ?
@ 2014-07-24 18:33   ` Ilya Dryomov
  0 siblings, 0 replies; 17+ messages in thread
From: Ilya Dryomov @ 2014-07-24 18:33 UTC (permalink / raw)
  To: Toralf Förster; +Cc: linux-ia64, Ceph Development, Linux Kernel

On Thu, Jul 24, 2014 at 10:20 PM, Toralf Förster <toralf.foerster@gmx.de> 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.
>
> For these 4 places I'm wondering where the appropriate struct definition is located :
>
> arch/ia64/sn/kernel/io_acpi_init.c:         sizeof(struct pci_devdev_info *)) {
> tools/perf/builtin-sched.c:     sched->tasks = realloc(sched->tasks, sched->nr_tasks * sizeof(struct task_task *));
> fs/ceph/xattr.c:                xattrs = kcalloc(numattr, sizeof(struct ceph_xattr *),
> fs/ceph/xattr.c:                memset(xattrs, 0, numattr*sizeof(struct ceph_xattr *));

Heh, the ceph one is a five year old typo..  Looks like it should be
struct ceph_inode_xattr, I'll fix it up.  I'm curious though, how did
you grep for these?

Thanks,

                Ilya

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: sizeof (struct tYpO *) : it is just a typo or rather a bug ?
  2014-07-24 18:33   ` Ilya Dryomov
  (?)
@ 2014-07-24 18:37     ` Toralf Förster
  -1 siblings, 0 replies; 17+ messages in thread
From: Toralf Förster @ 2014-07-24 18:37 UTC (permalink / raw)
  To: Ilya Dryomov; +Cc: linux-ia64, Ceph Development, Linux Kernel

On 07/24/2014 08:33 PM, Ilya Dryomov wrote:
> On Thu, Jul 24, 2014 at 10:20 PM, Toralf Förster <toralf.foerster@gmx.de> 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.
>>
>> For these 4 places I'm wondering where the appropriate struct definition is located :
>>
>> arch/ia64/sn/kernel/io_acpi_init.c:         sizeof(struct pci_devdev_info *)) {
>> tools/perf/builtin-sched.c:     sched->tasks = realloc(sched->tasks, sched->nr_tasks * sizeof(struct task_task *));
>> fs/ceph/xattr.c:                xattrs = kcalloc(numattr, sizeof(struct ceph_xattr *),
>> fs/ceph/xattr.c:                memset(xattrs, 0, numattr*sizeof(struct ceph_xattr *));
> 
> Heh, the ceph one is a five year old typo..  Looks like it should be
> struct ceph_inode_xattr, I'll fix it up.  I'm curious though, how did
> you grep for these?
> 
> Thanks,
> 
>                 Ilya
> 

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

-- 
Toralf


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: sizeof (struct tYpO *) : it is just a typo or rather a bug ?
@ 2014-07-24 18:37     ` Toralf Förster
  0 siblings, 0 replies; 17+ messages in thread
From: Toralf Förster @ 2014-07-24 18:37 UTC (permalink / raw)
  To: Ilya Dryomov; +Cc: linux-ia64, Ceph Development, Linux Kernel

On 07/24/2014 08:33 PM, Ilya Dryomov wrote:
> On Thu, Jul 24, 2014 at 10:20 PM, Toralf Förster <toralf.foerster@gmx.de> 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.
>>
>> For these 4 places I'm wondering where the appropriate struct definition is located :
>>
>> arch/ia64/sn/kernel/io_acpi_init.c:         sizeof(struct pci_devdev_info *)) {
>> tools/perf/builtin-sched.c:     sched->tasks = realloc(sched->tasks, sched->nr_tasks * sizeof(struct task_task *));
>> fs/ceph/xattr.c:                xattrs = kcalloc(numattr, sizeof(struct ceph_xattr *),
>> fs/ceph/xattr.c:                memset(xattrs, 0, numattr*sizeof(struct ceph_xattr *));
> 
> Heh, the ceph one is a five year old typo..  Looks like it should be
> struct ceph_inode_xattr, I'll fix it up.  I'm curious though, how did
> you grep for these?
> 
> Thanks,
> 
>                 Ilya
> 

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

-- 
Toralf

--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: sizeof (struct tYpO *) : it is just a typo or rather a bug ?
@ 2014-07-24 18:37     ` Toralf Förster
  0 siblings, 0 replies; 17+ messages in thread
From: Toralf Förster @ 2014-07-24 18:37 UTC (permalink / raw)
  To: Ilya Dryomov; +Cc: linux-ia64, Ceph Development, Linux Kernel

On 07/24/2014 08:33 PM, Ilya Dryomov wrote:
> On Thu, Jul 24, 2014 at 10:20 PM, Toralf Förster <toralf.foerster@gmx.de> 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.
>>
>> For these 4 places I'm wondering where the appropriate struct definition is located :
>>
>> arch/ia64/sn/kernel/io_acpi_init.c:         sizeof(struct pci_devdev_info *)) {
>> tools/perf/builtin-sched.c:     sched->tasks = realloc(sched->tasks, sched->nr_tasks * sizeof(struct task_task *));
>> fs/ceph/xattr.c:                xattrs = kcalloc(numattr, sizeof(struct ceph_xattr *),
>> fs/ceph/xattr.c:                memset(xattrs, 0, numattr*sizeof(struct ceph_xattr *));
> 
> Heh, the ceph one is a five year old typo..  Looks like it should be
> struct ceph_inode_xattr, I'll fix it up.  I'm curious though, how did
> you grep for these?
> 
> Thanks,
> 
>                 Ilya
> 

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

-- 
Toralf


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: sizeof (struct tYpO *) : it is just a typo or rather a bug ?
  2014-07-24 18:20 ` Toralf Förster
  (?)
@ 2014-07-25 11:20   ` Henrique de Moraes Holschuh
  -1 siblings, 0 replies; 17+ messages in thread
From: Henrique de Moraes Holschuh @ 2014-07-25 11:20 UTC (permalink / raw)
  To: Toralf Förster; +Cc: linux-ia64, ceph-devel, Linux Kernel

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] 17+ messages in thread

* Re: sizeof (struct tYpO *) : it is just a typo or rather a bug ?
@ 2014-07-25 11:20   ` Henrique de Moraes Holschuh
  0 siblings, 0 replies; 17+ messages in thread
From: Henrique de Moraes Holschuh @ 2014-07-25 11:20 UTC (permalink / raw)
  To: Toralf Förster; +Cc: linux-ia64, ceph-devel, Linux Kernel

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
--
To unsubscribe from this list: send the line "unsubscribe linux-ia64" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: sizeof (struct tYpO *) : it is just a typo or rather a bug ?
@ 2014-07-25 11:20   ` Henrique de Moraes Holschuh
  0 siblings, 0 replies; 17+ messages in thread
From: Henrique de Moraes Holschuh @ 2014-07-25 11:20 UTC (permalink / raw)
  To: Toralf Förster; +Cc: linux-ia64, ceph-devel, Linux Kernel

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] 17+ messages in thread

* [Cocci] Fwd: Re: sizeof (struct tYpO *) : it is just a typo or rather a bug ?
  2014-07-25 11:20   ` Henrique de Moraes Holschuh
  (?)
  (?)
@ 2014-07-28 17:21   ` Toralf Förster
  2014-07-28 20:13     ` Julia Lawall
  -1 siblings, 1 reply; 17+ 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] 17+ 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: " Toralf Förster
@ 2014-07-28 20:13     ` Julia Lawall
  2014-07-28 20:41       ` Toralf Förster
  0 siblings, 1 reply; 17+ 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] 17+ 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; 17+ 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] 17+ 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; 17+ 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] 17+ 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; 17+ 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] 17+ 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; 17+ 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] 17+ messages in thread

end of thread, other threads:[~2014-07-29  5:49 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-24 18:20 sizeof (struct tYpO *) : it is just a typo or rather a bug ? Toralf Förster
2014-07-24 18:20 ` Toralf Förster
2014-07-24 18:33 ` Ilya Dryomov
2014-07-24 18:33   ` Ilya Dryomov
2014-07-24 18:33   ` Ilya Dryomov
2014-07-24 18:37   ` Toralf Förster
2014-07-24 18:37     ` Toralf Förster
2014-07-24 18:37     ` Toralf Förster
2014-07-25 11:20 ` Henrique de Moraes Holschuh
2014-07-25 11:20   ` Henrique de Moraes Holschuh
2014-07-25 11:20   ` Henrique de Moraes Holschuh
2014-07-28 17:21   ` [Cocci] Fwd: " 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 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.