Re: [Cocci] Using a macro for variable attributes

2020-04-28 Thread Paul Chaignon
On Tue, Apr 28, 2020 at 08:41:08PM +0200, Julia Lawall wrote: > > > On Tue, 28 Apr 2020, Paul Chaignon wrote: > > > Thanks for the quick answer! > > > > On Tue, Apr 28, 2020 at 07:44:15PM +0200, Julia Lawall wrote: > > > > > > > > > On Tue, 28 Apr 2020, Paul Chaignon wrote: > > > > > > > Hi

Re: [Cocci] Using a macro for variable attributes

2020-04-28 Thread Julia Lawall
On Tue, 28 Apr 2020, Paul Chaignon wrote: > Thanks for the quick answer! > > On Tue, Apr 28, 2020 at 07:44:15PM +0200, Julia Lawall wrote: > > > > > > On Tue, 28 Apr 2020, Paul Chaignon wrote: > > > > > Hi all, > > > > > > I am working on a small semantic patch to annotate specific variables

Re: [Cocci] Using a macro for variable attributes

2020-04-28 Thread Paul Chaignon
Thanks for the quick answer! On Tue, Apr 28, 2020 at 07:44:15PM +0200, Julia Lawall wrote: > > > On Tue, 28 Apr 2020, Paul Chaignon wrote: > > > Hi all, > > > > I am working on a small semantic patch to annotate specific variables in > > our codebase with __attribute__((aligned(8))). The

Re: [Cocci] Using a macro for variable attributes

2020-04-28 Thread Julia Lawall
On Tue, 28 Apr 2020, Paul Chaignon wrote: > Hi all, > > I am working on a small semantic patch to annotate specific variables in > our codebase with __attribute__((aligned(8))). The following program works > fine. > > @r@ > expression e1, e2; > identifier x; > @@ > ( > struct

Re: [Cocci] console: Complete exception handling in newport_probe()

2020-04-28 Thread Dejin Zheng
On Thu, Apr 23, 2020 at 05:23:29PM +0200, Markus Elfring wrote: > >> https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/log/scripts/coccinelle/free/iounmap.cocci > >> > >> How do you think about to extend presented software analysis approaches? > >> > > Sorry, I am not familiar

Re: [Cocci] [PATCH v1] console: fix an issue about ioremap leak.

2020-04-28 Thread Dejin Zheng
On Thu, Apr 23, 2020 at 01:10:14PM +0200, Markus Elfring wrote: > > if do_take_over_console() return an error in the newport_probe(), > > due to the io virtual address is not released, it will cause a leak. > > How do you think about a wording variant like the following? > >Subject: >

[Cocci] Using a macro for variable attributes

2020-04-28 Thread Paul Chaignon
Hi all, I am working on a small semantic patch to annotate specific variables in our codebase with __attribute__((aligned(8))). The following program works fine. @r@ expression e1, e2; identifier x; @@ ( struct \(icmphdr\|icmp6hdr\) x + __attribute__((aligned(8))) ; |

[Cocci] [PATCH 02/32] parsing_cocci: ast0_cocci: Add cast attributes

2020-04-28 Thread Jaskaran Singh
Add cast attributes to AST0 of SmPL. This is a list of attributes in the Cast type of AST0. Signed-off-by: Jaskaran Singh --- parsing_cocci/ast0_cocci.ml | 4 ++-- parsing_cocci/ast0_cocci.mli | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/parsing_cocci/ast0_cocci.ml

[Cocci] [PATCH 26/32] engine: check_exhaustive_pattern: Reflect Cast attributes

2020-04-28 Thread Jaskaran Singh
Cast attributes are added to the SmPL AST. Reflect these changes in check_exhaustive_pattern.ml. Signed-off-by: Jaskaran Singh --- engine/check_exhaustive_pattern.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engine/check_exhaustive_pattern.ml

[Cocci] [PATCH 30/32] tests: Add test case to check cast attribute allminus

2020-04-28 Thread Jaskaran Singh
Add a test case to check allminus for cast attributes. The test case replaces all the cast types in the C program. Cases covered are for when the attribute is: - Before the cast type. - After the cast type. - After the cast type and before the *. - After the cast type and *. Signed-off-by:

[Cocci] [PATCH 32/32] tests: Add test case to detect cast attributes

2020-04-28 Thread Jaskaran Singh
Add a test case to detect a cast attribute. The following cases are covered for when a attribute is: - Before the cast type. - After the cast type. - After the cast type and before the *. - After the cast type and *. Signed-off-by: Jaskaran Singh --- tests/detect_cast_attr.c | 10

[Cocci] [PATCH 31/32] tests: Add test case to remove cast attributes

2020-04-28 Thread Jaskaran Singh
Add a test case to remove a cast attribute. The following cases are covered for when a attribute is: - Before the cast type. - After the cast type. - After the cast type and before the *. - After the cast type and *. Signed-off-by: Jaskaran Singh --- tests/remove_cast_attr.c | 10

[Cocci] [PATCH 28/32] ocaml: coccilib: Reflect Cast attributes

2020-04-28 Thread Jaskaran Singh
Cast attributes are added to the C and SmPL ASTs. Reflect these changes in coccilib.mli. Signed-off-by: Jaskaran Singh --- ocaml/coccilib.mli | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ocaml/coccilib.mli b/ocaml/coccilib.mli index a305d616..0c379547 100644 ---

[Cocci] [PATCH 05/32] parsing_cocci: unparse_ast0: Reflect cast attributes

2020-04-28 Thread Jaskaran Singh
Cast attributes are added to the SmPL AST. Reflect these changes in unparse_ast0.ml. Signed-off-by: Jaskaran Singh --- parsing_cocci/unparse_ast0.ml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/parsing_cocci/unparse_ast0.ml b/parsing_cocci/unparse_ast0.ml index

[Cocci] [PATCH 27/32] engine: cocci_vs_c: Match Cast attributes

2020-04-28 Thread Jaskaran Singh
Cast attributes are added to the C and SmPL ASTs. Match these attributes in cocci_vs_c.ml. Signed-off-by: Jaskaran Singh --- engine/cocci_vs_c.ml | 24 +--- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/engine/cocci_vs_c.ml b/engine/cocci_vs_c.ml index

[Cocci] [PATCH 24/32] parsing_c: unparse_cocci: Reflect Cast attributes

2020-04-28 Thread Jaskaran Singh
Cast attributes are added to the SmPL AST. Reflect these changes in unparse_cocci.ml. Signed-off-by: Jaskaran Singh --- parsing_c/unparse_cocci.ml | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/parsing_c/unparse_cocci.ml b/parsing_c/unparse_cocci.ml index

[Cocci] [PATCH 25/32] parsing_c: visitor_c: Visit Cast attributes

2020-04-28 Thread Jaskaran Singh
Cast attributes are added to the C AST. Visit these attributes in the C AST visitor. Signed-off-by: Jaskaran Singh --- parsing_c/visitor_c.ml | 10 -- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/parsing_c/visitor_c.ml b/parsing_c/visitor_c.ml index 57b5f32b..1a522413

[Cocci] [PATCH 29/32] tools: spgen: Reflect Cast attrs

2020-04-28 Thread Jaskaran Singh
Cast attributes are added to the SmPL AST. Reflect these changes in position_generator.ml. Signed-off-by: Jaskaran Singh --- tools/spgen/source/position_generator.ml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/spgen/source/position_generator.ml

[Cocci] [PATCH 23/32] parsing_c: type_annoter_c: Reflect Cast attributes

2020-04-28 Thread Jaskaran Singh
Cast attributes are added to the SmPL AST. Reflect these changes in type_annoter_c.ml. Signed-off-by: Jaskaran Singh --- parsing_c/type_annoter_c.ml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/parsing_c/type_annoter_c.ml b/parsing_c/type_annoter_c.ml index

[Cocci] [PATCH 14/32] parsing_cocci: ast_cocci: Add cast attributes

2020-04-28 Thread Jaskaran Singh
Add cast attributes to the SmPL AST. This is a list of attributes in the Cast type of the SmPL AST. Signed-off-by: Jaskaran Singh --- parsing_cocci/ast_cocci.ml | 4 ++-- parsing_cocci/ast_cocci.mli | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git

[Cocci] [PATCH 15/32] parsing_cocci: visitor_ast: Visit cast attributes

2020-04-28 Thread Jaskaran Singh
Cast attributes are added to AST0 of SmPL. Visit these attributes in the SmPL AST visitor. Signed-off-by: Jaskaran Singh --- parsing_cocci/visitor_ast.ml | 10 ++ 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/parsing_cocci/visitor_ast.ml b/parsing_cocci/visitor_ast.ml

[Cocci] [PATCH 18/32] parsing_cocci: disjdistr: Reflect Cast attributes

2020-04-28 Thread Jaskaran Singh
Cast attributes are added to the SmPL AST. Reflect these changes in disjdistr.ml. Signed-off-by: Jaskaran Singh --- parsing_cocci/disjdistr.ml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/parsing_cocci/disjdistr.ml b/parsing_cocci/disjdistr.ml index

[Cocci] [PATCH 13/32] parsing_cocci: single_statement: Reflect Cast attributes

2020-04-28 Thread Jaskaran Singh
Cast attributes are added to the SmPL AST. Reflect these changes in single_statement.ml. Signed-off-by: Jaskaran Singh --- parsing_cocci/single_statement.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parsing_cocci/single_statement.ml b/parsing_cocci/single_statement.ml

[Cocci] [PATCH 22/32] parsing_c: pretty_print_c: Reflect Cast attributes

2020-04-28 Thread Jaskaran Singh
Cast attributes are added to the SmPL AST. Print these attributes in pretty_print_c.ml. Signed-off-by: Jaskaran Singh --- parsing_c/pretty_print_c.ml | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/parsing_c/pretty_print_c.ml b/parsing_c/pretty_print_c.ml index

[Cocci] [PATCH 19/32] parsing_cocci: unify_ast: Reflect Cast attributes

2020-04-28 Thread Jaskaran Singh
Cast attributes are added to the SmPL AST. Reflect these changes in unify_ast.ml. Signed-off-by: Jaskaran Singh --- parsing_cocci/unify_ast.ml | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/parsing_cocci/unify_ast.ml b/parsing_cocci/unify_ast.ml index

[Cocci] [PATCH 16/32] parsing_cocci: pretty_print_cocci: Print cast attributes

2020-04-28 Thread Jaskaran Singh
Cast attributes are added to the SmPL AST. Reflect these changes in pretty_print_cocci.ml by printing these attributes. Signed-off-by: Jaskaran Singh --- parsing_cocci/pretty_print_cocci.ml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git

[Cocci] [PATCH 21/32] parsing_c: parser: Parse Cast attributes

2020-04-28 Thread Jaskaran Singh
Cast attributes are added to the C AST. Parse cast attributes in the C parser and place them in the C AST. The attributes are taken from the type_name rule of the C parser. Signed-off-by: Jaskaran Singh --- parsing_c/parser_c.mly | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff

[Cocci] [PATCH 20/32] parsing_c: ast_c: Add Cast attributes

2020-04-28 Thread Jaskaran Singh
Add cast attributes to the C AST. This is a list of attributes in the Cast type of the C AST. Signed-off-by: Jaskaran Singh --- parsing_c/ast_c.ml | 2 +- parsing_c/ast_c.mli | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/parsing_c/ast_c.ml b/parsing_c/ast_c.ml index

[Cocci] [PATCH 17/32] parsing_cocci: ast0toast: Reflect Cast attributes

2020-04-28 Thread Jaskaran Singh
Cast attributes are added to the SmPL AST. Reflect these changes in ast0toast.ml. Signed-off-by: Jaskaran Singh --- parsing_cocci/ast0toast.ml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/parsing_cocci/ast0toast.ml b/parsing_cocci/ast0toast.ml index

[Cocci] [PATCH 06/32] parsing_cocci: index: Reflect Cast attributes

2020-04-28 Thread Jaskaran Singh
Cast attributes are added to the SmPL AST. Reflect these changes in index.ml. Signed-off-by: Jaskaran Singh --- parsing_cocci/index.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parsing_cocci/index.ml b/parsing_cocci/index.ml index f7ae48b4..a3b92c12 100644 ---

[Cocci] [PATCH 00/32] cocci: Add cast attributes to C and SmPL ASTs

2020-04-28 Thread Jaskaran Singh
This patch series aims to add cast attributes to the C and SmPL ASTs, and match them in C source code. This is a continuation of the series "cocci: Improve C parsing of attributes"[1]. Three test cases are included: - detect_cast_attr: Test case to detect a parameter attribute. -

[Cocci] [PATCH 09/32] parsing_cocci: arity: Reflect Cast attributes

2020-04-28 Thread Jaskaran Singh
Cast attributes are added to the SmPL AST. Reflect these changes in arity.ml. Signed-off-by: Jaskaran Singh --- parsing_cocci/arity.ml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/parsing_cocci/arity.ml b/parsing_cocci/arity.ml index 8ee6d33f..880cd7a3 100644 ---

[Cocci] [PATCH 01/32] parsing_c: parser: Pass attribute list from type_name

2020-04-28 Thread Jaskaran Singh
To add Cast attributes to the C AST, pass attributes from the type_name rule of the C parser. Signed-off-by: Jaskaran Singh --- ocaml/coccilib.mli | 3 ++- parsing_c/parse_c.ml | 4 +++- parsing_c/parser_c.mly | 16 3 files changed, 13 insertions(+), 10 deletions(-)

[Cocci] [PATCH 03/32] parsing_cocci: parser: Parse cast attributes

2020-04-28 Thread Jaskaran Singh
Cast attributes are added to the SmPL ASTs. Parse these attributes in the SmPL parser and place them in the SmPL AST. The added production only supports attributes after the type and before the expression. Signed-off-by: Jaskaran Singh --- parsing_cocci/parser_cocci_menhir.mly | 9 + 1

[Cocci] [PATCH 10/32] parsing_cocci: check_meta: Reflect Cast attributes

2020-04-28 Thread Jaskaran Singh
Cast attributes are added to the SmPL AST. Reflect these changes in check_meta.ml. Signed-off-by: Jaskaran Singh --- parsing_cocci/check_meta.ml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/parsing_cocci/check_meta.ml b/parsing_cocci/check_meta.ml index

[Cocci] [PATCH 12/32] parsing_cocci: context_neg: Reflect Cast attributes

2020-04-28 Thread Jaskaran Singh
Cast attributes are added to the SmPL AST. Reflect these changes in context_neg.ml. Signed-off-by: Jaskaran Singh --- parsing_cocci/context_neg.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parsing_cocci/context_neg.ml b/parsing_cocci/context_neg.ml index

[Cocci] [PATCH 11/32] parsing_cocci: compute_lines: Reflect Cast attributes

2020-04-28 Thread Jaskaran Singh
Cast attributes are added to the SmPL AST. Reflect these changes in compute_lines.ml. Signed-off-by: Jaskaran Singh --- parsing_cocci/compute_lines.ml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/parsing_cocci/compute_lines.ml b/parsing_cocci/compute_lines.ml index

[Cocci] [PATCH 04/32] parsing_cocci: visitor_ast0: Visit cast attributes

2020-04-28 Thread Jaskaran Singh
Cast attributes are added to AST0 of SmPL. Visit these attributes in the AST0 visitor of SmPL. Signed-off-by: Jaskaran Singh --- parsing_cocci/visitor_ast0.ml | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/parsing_cocci/visitor_ast0.ml b/parsing_cocci/visitor_ast0.ml

[Cocci] [PATCH 07/32] parsing_cocci: iso_pattern: Reflect Cast attributes

2020-04-28 Thread Jaskaran Singh
Cast attributes are added to the SmPL AST. Reflect these changes in iso_pattern.ml. Signed-off-by: Jaskaran Singh --- parsing_cocci/iso_pattern.ml | 12 +--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/parsing_cocci/iso_pattern.ml b/parsing_cocci/iso_pattern.ml index

[Cocci] [PATCH 08/32] parsing_cocci: type_infer: Reflect Cast attributes

2020-04-28 Thread Jaskaran Singh
Cast attributes are added to the SmPL AST. Reflect these changes in type_infer.ml. Signed-off-by: Jaskaran Singh --- parsing_cocci/type_infer.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parsing_cocci/type_infer.ml b/parsing_cocci/type_infer.ml index e8aad810..2c1cc73b

Re: [Cocci] [PATCH 22/23] tests: Add test case for removing parameter attributes

2020-04-28 Thread Jaskaran Singh
On Mon, 2020-04-27 at 19:31 +0200, Julia Lawall wrote: > > On Mon, 27 Apr 2020, Jaskaran Singh wrote: > > > Add a test case for removing Parameter attributes. The test case > > checks > > correct removal of the attribute when it is: > > > > - before the parameter type. > > - after the parameter