Skip to contentSkip to conversation

Incorrect skipping on custom types in type list

Cocci Michael Stefaniuc 2 participants 4 messages Nov 27, 2013 – Nov 28, 2013

lore
Share & tools
lore
#0 lore raw

Hello,

@@
typedef VOID;
typedef LPVOID;
typedef PVOID;
{void *, VOID *, LPVOID, PVOID} ppv;
identifier QI =~ "_QueryInterface$";
@@
* QI(..., ppv)

executed on

int IFoo_QueryInterface(int *iface, long *riid, void **ppv)

{
    return IBar_QueryInterface(iface, riid, *ppv);
}

gives:

$ spatch QI.cocci /tmp/qi.c
HANDLING: /tmp/qi.c
No matches found for PVOID
Skipping:/tmp/qi.c

Putting LPVOID or VOID* last in the type list gives:
No matches found for LPVOID
respectively
No matches found for VOID

With void* in there I wouldn't have expected it to skip any files at all.

bye
michael

#1 lore raw
Quoted 24 lines · Michael Stefaniuc

Hello,

@@
typedef VOID;
typedef LPVOID;
typedef PVOID;
{void *, VOID *, LPVOID, PVOID} ppv;
identifier QI =~ "_QueryInterface$";
@@
* QI(..., ppv)

executed on

int IFoo_QueryInterface(int *iface, long *riid, void **ppv)

{
    return IBar_QueryInterface(iface, riid, *ppv);
}

gives:

$ spatch QI.cocci /tmp/qi.c
HANDLING: /tmp/qi.c
No matches found for PVOID
Skipping:/tmp/qi.c
Quoted 6 lines

Putting LPVOID or VOID* last in the type list gives:
No matches found for LPVOID
respectively
No matches found for VOID

With void* in there I wouldn't have expected it to skip any files at all.

Thanks for the report. I will look into it. I expect to make a new release soon.

julia

#2 lore raw
In reply to Michael Stefaniuc

A patch is below. Thanks for the report!

julia

parsing_cocci/get_constants2.ml +5 -5
index 80a512c..ed6e038 100644
@@ -309,12 +309,12 @@ let do_get_constants constants keywords env neg_pos =
   let rec type_collect res = function
       TC.ConstVol(_,ty) | TC.Pointer(ty) | TC.FunctionPointer(ty)
     | TC.Array(ty) -> type_collect res ty
-    | TC.Decimal _ -> keywords "decimal"
+    | TC.Decimal _ -> build_or res (keywords "decimal")
     | TC.MetaType(tyname,_,_) ->
-	inherited tyname
-    | TC.TypeName(s) -> constants s
-    | TC.EnumName(TC.Name s) -> constants s
-    | TC.StructUnionName(_,TC.Name s) -> constants s
+	build_or res (inherited tyname)
+    | TC.TypeName(s) -> build_or res (constants s)
+    | TC.EnumName(TC.Name s) -> build_or res (constants s)
+    | TC.StructUnionName(_,TC.Name s) -> build_or res (constants s)
     | ty -> res in
 
   (* no point to do anything special for records because glimpse is
#3 lore raw
Quoted 17 lines · Julia Lawall

A patch is below. Thanks for the report!

julia

parsing_cocci/get_constants2.ml +1 -2
index 80a512c..ed6e038 100644
@@ -309,12 +309,12 @@ let do_get_constants constants keywords env neg_pos =
   let rec type_collect res = function
       TC.ConstVol(_,ty) | TC.Pointer(ty) | TC.FunctionPointer(ty)
     | TC.Array(ty) -> type_collect res ty
-    | TC.Decimal _ -> keywords "decimal"
+    | TC.Decimal _ -> build_or res (keywords "decimal")
     | TC.MetaType(tyname,_,_) ->
-	inherited tyname

parsing_cocci/get_constants2.ml let do_get_constants constants keywords env neg_pos = · line 320

Quoted 10 lines
parsing_cocci/get_constants2.ml +4 -3
-    | TC.TypeName(s) -> constants s
-    | TC.EnumName(TC.Name s) -> constants s
-    | TC.StructUnionName(_,TC.Name s) -> constants s
+	build_or res (inherited tyname)
+    | TC.TypeName(s) -> build_or res (constants s)
+    | TC.EnumName(TC.Name s) -> build_or res (constants s)
+    | TC.StructUnionName(_,TC.Name s) -> build_or res (constants s)
     | ty -> res in
 
   (* no point to do anything special for records because glimpse is

Thanks Julia, that fixed it.

bye
michael