Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Coccinelle: noderef: Add new rules and correct the old rule

Add new rules to detect the cases where sizeof is used in
function calls as a argument.

Also, for the patch mode third rule should behave same as
second rule with arguments reversed. So, change that as well.

Signed-off-by: Vaishali Thakkar <vaishali.thakkar@oracle.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Michal Marek <mmarek@suse.com>

authored by

Vaishali Thakkar and committed by
Michal Marek
bf56cc04 1a695a90

+17 -1
+17 -1
scripts/coccinelle/misc/noderef.cocci
··· 16 16 @depends on patch@ 17 17 expression *x; 18 18 expression f; 19 + expression i; 19 20 type T; 20 21 @@ 21 22 ··· 31 30 + *x 32 31 ),...) 33 32 | 34 - f(...,sizeof(x),...,(T)( 33 + f(...,sizeof( 34 + - x 35 + + *x 36 + ),...,(T)(x),...) 37 + | 38 + f(...,(T)(x),...,i*sizeof( 35 39 - x 36 40 + *x 37 41 ),...) 42 + | 43 + f(...,i*sizeof( 44 + - x 45 + + *x 46 + ),...,(T)(x),...) 38 47 ) 39 48 40 49 @r depends on !patch@ 41 50 expression *x; 42 51 expression f; 52 + expression i; 43 53 position p; 44 54 type T; 45 55 @@ ··· 61 49 *f(...,(T)(x),...,sizeof@p(x),...) 62 50 | 63 51 *f(...,sizeof@p(x),...,(T)(x),...) 52 + | 53 + *f(...,(T)(x),...,i*sizeof@p(x),...) 54 + | 55 + *f(...,i*sizeof@p(x),...,(T)(x),...) 64 56 ) 65 57 66 58 @script:python depends on org@