Skip to contentSkip to conversation

Ignore Code in Macro Def

Cocci Mitchell Cuddie 2 participants 2 messages Nov 20, 2014 – Nov 21, 2014

lore
Share & tools
lore
#0 lore raw

I am working on a patch that manipulates null pointer usage. However the second rule matches code inside macros which causes issues. Is there a way to have rule 2 skip macros or rule 1 match against them and thereby deactivate rule 2?

Cheers

Mitchell

@p_null disable is_null, isnt_null1, is_zero, isnt_zero@ expression *E;
type T;
position p;
T *f;
@@
(

    \(E\|f(...)\) == @p NULL
|
    \(E\|f(...)\) != @p NULL

|
E =@p NULL
)

@np_null depends on !p_null && !ptr_zero disable is_null, isnt_null1, is_zero, isnt_zero@
position p;
T g;
expression F;
@@
(

    \(F\|g(...)\)  == @p
-   NULL
+   0   
|
    \(F\|g(...)\)  != @p
-   NULL
+   0
|
    F  = @p

- NULL
+ 0
)

#1 lore raw
Quoted 4 lines · Mitchell Cuddie

I am working on a patch that manipulates null pointer usage. However the second rule matches code inside macros which causes issues. Is there a way to have rule 2 skip macros or rule 1 match against them and thereby deactivate rule 2?

Could you send an example of a macro where you don't want a match?

thanks,
julia

Quoted 44 lines

Cheers

Mitchell

@p_null disable is_null, isnt_null1, is_zero, isnt_zero@ expression *E;
type T;
position p;
T *f;
@@
(

    \(E\|f(...)\) == @p NULL
|
    \(E\|f(...)\) != @p NULL

|
E =@p NULL
)

@np_null depends on !p_null && !ptr_zero disable is_null, isnt_null1, is_zero, isnt_zero@
position p;
T g;
expression F;
@@
(

    \(F\|g(...)\)  == @p
(quoted diff) +1 -1
-   NULL
+   0   

|

    \(F\|g(...)\)  != @p
(quoted diff) +1 -1
-   NULL
+   0

|

    F  = @p
(quoted diff) +1 -1
-   NULL
+   0

)

_______________________________________________
Cocci mailing list
Cocci at systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci