1 /// Use ARRAY_SIZE instead of dividing sizeof array with sizeof an element
3 //# This makes an effort to find cases where the argument to sizeof is wrong
4 //# in memory allocation functions by checking the type of the allocated memory
5 //# when it is a double pointer and ensuring the sizeof argument takes a pointer
6 //# to the the memory being allocated. There are false positives in cases the
7 //# sizeof argument is not used in constructing the return value. The result
8 //# may need some reformatting.
10 // Confidence: Moderate
11 // Copyright: (C) 2014 Himangi Saraogi. GPLv2.
20 //----------------------------------------------------------
22 //----------------------------------------------------------
24 @depends on context disable sizeof_type_expr@
34 //----------------------------------------------------------
36 //----------------------------------------------------------
38 @depends on patch disable sizeof_type_expr@
49 //----------------------------------------------------------
50 // For org and report mode
51 //----------------------------------------------------------
53 @r disable sizeof_type_expr@
64 @script:python depends on org@
68 coccilib.org.print_todo(p[0], "WARNING sizeof argument should be pointer type, not structure type")
70 @script:python depends on report@
74 msg="WARNING: Use correct pointer type argument for sizeof"
75 coccilib.report.print_report(p[0], msg)