[Linux-kernel-mentees] [PATCH 2/3] parsing_cocci: context_neg: Apply equal_mcode on cast/param attrs

Jaskaran Singh jaskaransingh7654321 at gmail.com
Fri Jun 12 06:45:43 UTC 2020


The following commits introduced some poor management of attributes in
context_neg.ml:
	2b7e99a5b86d41e05980c8a9d98eb931e42bb4d8
	08f1cd9fb83ec400435e0ad8fdf579ec8f9c0f21
Apply equal_mcode on cast and parameter attributes in context_neg.ml.

Signed-off-by: Jaskaran Singh <jaskaransingh7654321 at gmail.com>
---
 parsing_cocci/context_neg.ml | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/parsing_cocci/context_neg.ml b/parsing_cocci/context_neg.ml
index 41bc621f..6e992245 100644
--- a/parsing_cocci/context_neg.ml
+++ b/parsing_cocci/context_neg.ml
@@ -630,8 +630,10 @@ let rec equal_expression e1 e2 =
       equal_mcode pt1 pt2
   | (Ast0.RecordPtAccess(_,ar1,_),Ast0.RecordPtAccess(_,ar2,_)) ->
       equal_mcode ar1 ar2
-  | (Ast0.Cast(lp1,_,_,rp1,_),Ast0.Cast(lp2,_,_,rp2,_)) ->
-      equal_mcode lp1 lp2 && equal_mcode rp1 rp2
+  | (Ast0.Cast(lp1,_,ar1,rp1,_),Ast0.Cast(lp2,_,ar2,rp2,_)) ->
+      equal_mcode lp1 lp2 &&
+      List.for_all2 equal_mcode ar1 ar2 &&
+      equal_mcode rp1 rp2
   | (Ast0.SizeOfExpr(szf1,_),Ast0.SizeOfExpr(szf2,_)) ->
       equal_mcode szf1 szf2
   | (Ast0.SizeOfType(szf1,lp1,_,rp1),Ast0.SizeOfType(szf2,lp2,_,rp2)) ->
@@ -842,8 +844,10 @@ let equal_initialiser i1 i2 =
 
 let equal_parameterTypeDef p1 p2 =
   match (Ast0.unwrap p1,Ast0.unwrap p2) with
-    (Ast0.VoidParam(_,_),Ast0.VoidParam(_,_)) -> true
-  | (Ast0.Param(_,_,_),Ast0.Param(_,_,_)) -> true
+    (Ast0.VoidParam(_,ar1),Ast0.VoidParam(_,ar2)) ->
+      List.for_all2 equal_mcode ar1 ar2
+  | (Ast0.Param(_,_,ar1),Ast0.Param(_,_,ar2)) ->
+      List.for_all2 equal_mcode ar1 ar2
   | (Ast0.MetaParam(name1,_,_),Ast0.MetaParam(name2,_,_))
   | (Ast0.MetaParamList(name1,_,_,_),Ast0.MetaParamList(name2,_,_,_)) ->
       equal_mcode name1 name2
-- 
2.21.1



More information about the Linux-kernel-mentees mailing list