Thanks for the report.  I'll fix it.  Your patch looks fine.

julia

On Sun, 15 Apr 2012, Mansour Moufid wrote:

Hello,

If I try to use the size_t type for array indices in a cocci script, I get an 
error. For example:

foo.cocci:
@@
type T;
identifier x, y;
@@
- T y;
+ size_t y;
 ...
 x[y]

foo.c:
int main(void) {
   int i = 2;
   int x[] = {1,2,3};
   x[i] = 4;
   return 0;
}

$ spatch --sp-file foo.cocci foo.c
size_t
Fatal error: exception Failure("line 8: bad type for an array index")

But size_t is perfectly valid, and even recommended.[1] I'm not familiar with 
the Coccinelle code but may I suggest the attached patch?

Thanks for your time.

[1] 
https://www.securecoding.cert.org/confluence/display/seccode/INT01-C.+Use+rsize_t+or+size_t+for+all+integer+values+representing+the+size+of+an+object


_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)

Reply via email to