Re: [Cocci] [PATCH] parsing_hacks: Add bool to list of known typedefs

2020-01-20 Thread Jaskaran Singh
On Tue, 2020-01-21 at 06:23 +, Julia Lawall wrote:
> 
> On Sun, 19 Jan 2020, Jaskaran Singh wrote:
> 
> > bool is widely used in the Linux kernel. Certain cases of
> > parsing_hacks.ml would mislabel bool.
> > 
> > Add bool to the list of known typedefs.
> 
> As far as I can see, this function is only used for avoiding to print
> some
> warning messages.  So I'm not sure why it would have any impact on
> the
> parsing at all?
> 

Sorry, It should've been clear in the patch.

This patch will only make any difference if it's applied on top of 
https://www.mail-archive.com/cocci@systeme.lip6.fr/msg06706.html

Cheers,
Jaskaran.

> julia
> 
> > Stats of --parse-c on Linux v5.5-rc4 are as follows:
> > 
> > Before:
> > 
> >   nb good = 18956150,  nb passed = 134062 => 0.70% passed
> > 
> > After:
> > 
> >   nb good = 18956150,  nb passed = 134073 => 0.70% passed
> > 
> > Signed-off-by: Jaskaran Singh 
> > ---
> > The above diff has been obtained after applying
> > https://www.mail-archive.com/cocci@systeme.lip6.fr/msg06706.html
> > 
> >  parsing_c/parsing_hacks.ml | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/parsing_c/parsing_hacks.ml
> > b/parsing_c/parsing_hacks.ml
> > index 685a4908..5e3301a0 100644
> > --- a/parsing_c/parsing_hacks.ml
> > +++ b/parsing_c/parsing_hacks.ml
> > @@ -61,7 +61,7 @@ let is_known_typdef =
> >| "u_char"   | "u_short"  | "u_int"  | "u_long"
> >| "u8" | "u16" | "u32" | "u64"
> >| "s8"  | "s16" | "s32" | "s64"
> > -  | "__u8" | "__u16" | "__u32"  | "__u64"
> > +  | "__u8" | "__u16" | "__u32"  | "__u64" | "bool"
> >  -> true
> > 
> >| "acpi_handle"
> > --
> > 2.21.1
> > 
> > 

___
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci


Re: [Cocci] [PATCH] parsing_hacks: Add bool to list of known typedefs

2020-01-20 Thread Julia Lawall



On Tue, 21 Jan 2020, Jaskaran Singh wrote:

> On Tue, 2020-01-21 at 06:20 +, Julia Lawall wrote:
> >
> > On Sun, 19 Jan 2020, Jaskaran Singh wrote:
> >
> > > bool is widely used in the Linux kernel. Certain cases of
> > > parsing_hacks.ml would mislabel bool.
> > >
> > > Add bool to the list of known typedefs.
> > >
> > > Stats of --parse-c on Linux v5.5-rc4 are as follows:
> > >
> > > Before:
> > >
> > >   nb good = 18956150,  nb passed = 134062 => 0.70% passed
> > >
> > > After:
> > >
> > >   nb good = 18956150,  nb passed = 134073 => 0.70% passed
> >
> > Why did nb passed increase?  These are tokens that will not be able
> > to be
> > transformed by a semantic patch.
> >
>
> I suspect it's instances of nokprobe_inline in
> linux/kernel/trace/trace_kprobe.c. They're marked as CppMacro.

OK, that looks ok.  Could you update the log messages with that
information?

thanks,
julia


>
> Here's results from my diff:
>
> 20402,20406c20288,20294
> < passed:bool
> < passed:bool
> < passed:bool
> < passed:bool
> < passed:bool
> ---
> > passed:nokprobe_inline
> > passed:nokprobe_inline
> > passed:nokprobe_inline
> > passed:nokprobe_inline
> > passed:nokprobe_inline
> > passed:nokprobe_inline
> > passed:nokprobe_inline
> 20407a20296,20297
> > passed:nokprobe_inline
> > passed:nokprobe_inline
> 20408a20299,20300
> > passed:nokprobe_inline
> > passed:nokprobe_inline
> 20409a20302,20303
> > passed:nokprobe_inline
> > passed:nokprobe_inline
> 20410a20305,20306
> > passed:nokprobe_inline
> > passed:nokprobe_inline
>
> Cheers,
> Jaskaran.
>
> > julia
> >
> > > Signed-off-by: Jaskaran Singh 
> > > ---
> > > The above diff has been obtained after applying
> > > https://www.mail-archive.com/cocci@systeme.lip6.fr/msg06706.html
> > >
> > >  parsing_c/parsing_hacks.ml | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/parsing_c/parsing_hacks.ml
> > > b/parsing_c/parsing_hacks.ml
> > > index 685a4908..5e3301a0 100644
> > > --- a/parsing_c/parsing_hacks.ml
> > > +++ b/parsing_c/parsing_hacks.ml
> > > @@ -61,7 +61,7 @@ let is_known_typdef =
> > >| "u_char"   | "u_short"  | "u_int"  | "u_long"
> > >| "u8" | "u16" | "u32" | "u64"
> > >| "s8"  | "s16" | "s32" | "s64"
> > > -  | "__u8" | "__u16" | "__u32"  | "__u64"
> > > +  | "__u8" | "__u16" | "__u32"  | "__u64" | "bool"
> > >  -> true
> > >
> > >| "acpi_handle"
> > > --
> > > 2.21.1
> > >
> > >
>
>
___
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci


Re: [Cocci] [PATCH] parsing_c: Handle case of macro before typedef

2020-01-20 Thread Julia Lawall



On Sun, 19 Jan 2020, Jaskaran Singh wrote:

> For the following case:
>
>   
>
> A case in parsing_hacks.ml sometimes mislabels  as a
> typedef ident.
>
> If typedef is a known typedef (such as u8 or *_t), then label
>  as a CppMacro. Subsequent cases will then label 
> correctly.

OK, I see that you are now using is_known_typdef in a more interesting
way.  Could you add a test case that shows what has improved?  I would
still know to know why the number of passed tokens increases.

julia


>
> Following are results of --parse-c on the Linux Kernel v5.5-rc4:
>
> Before:
>
>   nb good = 18956150,  nb passed = 134061 => 0.70% passed
>
> After:
>
>   nb good = 18956150,  nb passed = 134062 => 0.70% passed
>
> Signed-off-by: Jaskaran Singh 
> ---
>  parsing_c/parsing_hacks.ml | 35 +++
>  1 file changed, 35 insertions(+)
>
> diff --git a/parsing_c/parsing_hacks.ml b/parsing_c/parsing_hacks.ml
> index 8374731b..23d675cf 100644
> --- a/parsing_c/parsing_hacks.ml
> +++ b/parsing_c/parsing_hacks.ml
> @@ -2184,6 +2184,41 @@ let lookahead2 ~pass next before =
>&& ok_typedef s && is_macro s2 && is_type type_
>  ->
> TIdent (s, i1)
> +
> +  (* xx yy zz : xx is a macro *)
> +  | (TIdent (s, i1)::TIdent (s2, i2)::TIdent(_,_)::_ , _)
> +when not_struct_enum before
> + && ok_typedef s2
> + && is_known_typdef s2
> +->
> +   TCommentCpp(Token_c.CppMacro, i1)
> +
> +  (* xx yy zz : xx is a typedef ident *)
> +  | (TIdent (s, i1)::TIdent (s2, i2)::TIdent(_,_)::_ , _)
> +when not_struct_enum before
> + && ok_typedef s
> +->
> +  msg_typedef s i1 2; LP.add_typedef_root s i1;
> +  TypedefIdent (s, i1)
> +
> +  (* xx yy * zz : xx is a macro *)
> +  | (TIdent (s, i1)::TIdent (s2, i2)::ptr , _)
> +when pointer ~followed_by:(function TIdent _ -> true | _ -> false) ptr
> + && not_struct_enum before
> + && ok_typedef s2
> + && is_known_typdef s2
> +->
> +   TCommentCpp(Token_c.CppMacro, i1)
> +
> +  (* xx yy * zz : xx is a typedef ident *)
> +  | (TIdent (s, i1)::TIdent (s2, i2)::ptr , _)
> +when pointer ~followed_by:(function TIdent _ -> true | _ -> false) ptr
> + && not_struct_enum before
> + && ok_typedef s
> +->
> +  msg_typedef s i1 2; LP.add_typedef_root s i1;
> +  TypedefIdent (s, i1)
> +
>(* xx yy *)
>| (TIdent (s, i1)::TIdent (s2, i2)::rest  , _) when not_struct_enum before
>   && ok_typedef s && not (is_macro_paren s2 rest)
> --
> 2.21.1
>
>
___
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci


Re: [Cocci] [PATCH] parsing_hacks: Add bool to list of known typedefs

2020-01-20 Thread Jaskaran Singh
On Tue, 2020-01-21 at 06:20 +, Julia Lawall wrote:
> 
> On Sun, 19 Jan 2020, Jaskaran Singh wrote:
> 
> > bool is widely used in the Linux kernel. Certain cases of
> > parsing_hacks.ml would mislabel bool.
> > 
> > Add bool to the list of known typedefs.
> > 
> > Stats of --parse-c on Linux v5.5-rc4 are as follows:
> > 
> > Before:
> > 
> >   nb good = 18956150,  nb passed = 134062 => 0.70% passed
> > 
> > After:
> > 
> >   nb good = 18956150,  nb passed = 134073 => 0.70% passed
> 
> Why did nb passed increase?  These are tokens that will not be able
> to be
> transformed by a semantic patch.
> 

I suspect it's instances of nokprobe_inline in
linux/kernel/trace/trace_kprobe.c. They're marked as CppMacro.

Here's results from my diff:

20402,20406c20288,20294
< passed:bool 
< passed:bool 
< passed:bool 
< passed:bool 
< passed:bool 
---
> passed:nokprobe_inline 
> passed:nokprobe_inline 
> passed:nokprobe_inline 
> passed:nokprobe_inline 
> passed:nokprobe_inline 
> passed:nokprobe_inline 
> passed:nokprobe_inline 
20407a20296,20297
> passed:nokprobe_inline 
> passed:nokprobe_inline 
20408a20299,20300
> passed:nokprobe_inline 
> passed:nokprobe_inline 
20409a20302,20303
> passed:nokprobe_inline 
> passed:nokprobe_inline 
20410a20305,20306
> passed:nokprobe_inline 
> passed:nokprobe_inline 

Cheers,
Jaskaran.

> julia
> 
> > Signed-off-by: Jaskaran Singh 
> > ---
> > The above diff has been obtained after applying
> > https://www.mail-archive.com/cocci@systeme.lip6.fr/msg06706.html
> > 
> >  parsing_c/parsing_hacks.ml | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/parsing_c/parsing_hacks.ml
> > b/parsing_c/parsing_hacks.ml
> > index 685a4908..5e3301a0 100644
> > --- a/parsing_c/parsing_hacks.ml
> > +++ b/parsing_c/parsing_hacks.ml
> > @@ -61,7 +61,7 @@ let is_known_typdef =
> >| "u_char"   | "u_short"  | "u_int"  | "u_long"
> >| "u8" | "u16" | "u32" | "u64"
> >| "s8"  | "s16" | "s32" | "s64"
> > -  | "__u8" | "__u16" | "__u32"  | "__u64"
> > +  | "__u8" | "__u16" | "__u32"  | "__u64" | "bool"
> >  -> true
> > 
> >| "acpi_handle"
> > --
> > 2.21.1
> > 
> > 

___
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci


Re: [Cocci] [PATCH] parsing_hacks: Add bool to list of known typedefs

2020-01-20 Thread Julia Lawall



On Sun, 19 Jan 2020, Jaskaran Singh wrote:

> bool is widely used in the Linux kernel. Certain cases of
> parsing_hacks.ml would mislabel bool.
>
> Add bool to the list of known typedefs.

As far as I can see, this function is only used for avoiding to print some
warning messages.  So I'm not sure why it would have any impact on the
parsing at all?

julia

> Stats of --parse-c on Linux v5.5-rc4 are as follows:
>
> Before:
>
>   nb good = 18956150,  nb passed = 134062 => 0.70% passed
>
> After:
>
>   nb good = 18956150,  nb passed = 134073 => 0.70% passed
>
> Signed-off-by: Jaskaran Singh 
> ---
> The above diff has been obtained after applying
> https://www.mail-archive.com/cocci@systeme.lip6.fr/msg06706.html
>
>  parsing_c/parsing_hacks.ml | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/parsing_c/parsing_hacks.ml b/parsing_c/parsing_hacks.ml
> index 685a4908..5e3301a0 100644
> --- a/parsing_c/parsing_hacks.ml
> +++ b/parsing_c/parsing_hacks.ml
> @@ -61,7 +61,7 @@ let is_known_typdef =
>| "u_char"   | "u_short"  | "u_int"  | "u_long"
>| "u8" | "u16" | "u32" | "u64"
>| "s8"  | "s16" | "s32" | "s64"
> -  | "__u8" | "__u16" | "__u32"  | "__u64"
> +  | "__u8" | "__u16" | "__u32"  | "__u64" | "bool"
>  -> true
>
>| "acpi_handle"
> --
> 2.21.1
>
>
___
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci


Re: [Cocci] [PATCH] parsing_hacks: Add bool to list of known typedefs

2020-01-20 Thread Julia Lawall



On Sun, 19 Jan 2020, Jaskaran Singh wrote:

> bool is widely used in the Linux kernel. Certain cases of
> parsing_hacks.ml would mislabel bool.
>
> Add bool to the list of known typedefs.
>
> Stats of --parse-c on Linux v5.5-rc4 are as follows:
>
> Before:
>
>   nb good = 18956150,  nb passed = 134062 => 0.70% passed
>
> After:
>
>   nb good = 18956150,  nb passed = 134073 => 0.70% passed

Why did nb passed increase?  These are tokens that will not be able to be
transformed by a semantic patch.

julia

>
> Signed-off-by: Jaskaran Singh 
> ---
> The above diff has been obtained after applying
> https://www.mail-archive.com/cocci@systeme.lip6.fr/msg06706.html
>
>  parsing_c/parsing_hacks.ml | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/parsing_c/parsing_hacks.ml b/parsing_c/parsing_hacks.ml
> index 685a4908..5e3301a0 100644
> --- a/parsing_c/parsing_hacks.ml
> +++ b/parsing_c/parsing_hacks.ml
> @@ -61,7 +61,7 @@ let is_known_typdef =
>| "u_char"   | "u_short"  | "u_int"  | "u_long"
>| "u8" | "u16" | "u32" | "u64"
>| "s8"  | "s16" | "s32" | "s64"
> -  | "__u8" | "__u16" | "__u32"  | "__u64"
> +  | "__u8" | "__u16" | "__u32"  | "__u64" | "bool"
>  -> true
>
>| "acpi_handle"
> --
> 2.21.1
>
>
___
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci