On Mon, Feb 28, 2011 at 17:03, Julia Lawall <[email protected]> wrote:
>
> I'll look into the array problem. But I'm not sure why you want to match
> an array. sizeof does the right thing on arrays. You want to match the
> pointer case. You could try just:
>
Thanks. I tried that, but it doesn't match the code I posted for some
reason. I think perhaps that coccinelle doesn't grasp that the
incoming parameter is a pointer in this case. The problem is that C is
not doing the "right thing(tm)" when the array is passed as a
parameter, but then it is not passed as a parameter it behaves like
you would expect, see for instance (You are probably way ahead of me
here, but I am just making sure I understand what you are hinting at):
++
jlouis@myrddraal:~$ cat foo.c
#include <stdlib.h>
#include <stdio.h>
void
f(char reason[1024]) {
printf("Sizeof: %lu\n", sizeof(reason));
}
int
main(int argc, char **argv) {
char reason[1024];
f(reason);
printf("Sizeof: %lu\n", sizeof(reason));
return EXIT_SUCCESS;
}
jlouis@myrddraal:~$ gcc foo.c
jlouis@myrddraal:~$ ./a.out
Sizeof: 8
Sizeof: 1024
++
>
> Like this? :)
>
> http://www.securityfocus.com/bid/46307/info
>
> (There is absolutley no useful information at this URL, but it is
> precisely the problem you are talking about).
>
Hehe, yes, like that :)
--
J.
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)