Skip to content

Commit

Permalink
coccinelle: Remove unnecessary parentheses for only one possible change.
Browse files Browse the repository at this point in the history
The parentheses are only needed if there is a disjunction, ie a
set of possible changes. If there is only one pattern, we can
remove these parentheses. Just like the format:

  -  x
  +  y

not:

  (
  -  x
  +  y
  )

Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>
  • Loading branch information
Hongbo Li authored and JuliaLawall committed Sep 28, 2024
1 parent 253244c commit f584e37
Showing 1 changed file with 0 additions and 8 deletions.
8 changes: 0 additions & 8 deletions scripts/coccinelle/api/string_choices.cocci
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,14 @@ coccilib.report.print_report(p[0], "opportunity for str_plural(%s)" % e)
@str_up_down depends on patch@
expression E;
@@
(
- ((E) ? "up" : "down")
+ str_up_down(E)
)

@str_up_down_r depends on !patch exists@
expression E;
position P;
@@
(
* ((E@P) ? "up" : "down")
)

@script:python depends on report@
p << str_up_down_r.P;
Expand All @@ -66,18 +62,14 @@ coccilib.report.print_report(p[0], "opportunity for str_up_down(%s)" % e)
@str_down_up depends on patch@
expression E;
@@
(
- ((E) ? "down" : "up")
+ str_down_up(E)
)

@str_down_up_r depends on !patch exists@
expression E;
position P;
@@
(
* ((E@P) ? "down" : "up")
)

@script:python depends on report@
p << str_down_up_r.P;
Expand Down

0 comments on commit f584e37

Please sign in to comment.