1 /// Simplify a trivial if-return sequence. Possibly combine with a
2 /// preceding function call.
5 // Copyright: (C) 2014 Julia Lawall, INRIA/LIP6. GPLv2.
6 // Copyright: (C) 2014 Gilles Muller, INRIA/LiP6. GPLv2.
7 // URL: http://coccinelle.lip6.fr/
9 // Options: --no-includes --include-headers
25 -if (i != 0) return i;
45 // -----------------------------------------------------------------------
47 @s1 depends on context || org || report@
55 if (\(i@p1 != 0\|i@p2 < 0\))
60 @s2 depends on context || org || report forall@
71 @s3 depends on context || org || report@
77 *if (\(e@p1 != 0\|e@p2 < 0\))
81 // -----------------------------------------------------------------------
83 @script:python depends on org@
89 cocci.print_main("decl",q)
90 cocci.print_secs("use",p)
91 cocci.include_match(False)
93 @script:python depends on org@
99 cocci.print_main("decl",q)
100 cocci.print_secs("use with questionable test",p)
101 cocci.include_match(False)
103 @script:python depends on org@
108 cocci.print_main("use",p)
110 @script:python depends on org@
115 cocci.print_main("use with questionable test",p)
117 @script:python depends on org@
121 cocci.print_main("test",p)
123 @script:python depends on org@
127 cocci.print_main("questionable test",p)
129 // -----------------------------------------------------------------------
131 @script:python depends on report@
137 msg = "WARNING: end returns can be simpified and declaration on line %s can be dropped" % (q[0].line)
138 coccilib.report.print_report(p[0],msg)
139 cocci.include_match(False)
141 @script:python depends on report@
148 msg = "WARNING: end returns may be simpified if negative or 0 value and declaration on line %s can be dropped" % (q[0].line)
149 coccilib.report.print_report(p[0],msg)
150 cocci.include_match(False)
152 @script:python depends on report@
157 msg = "WARNING: end returns can be simpified"
158 coccilib.report.print_report(p[0],msg)
160 @script:python depends on report@
165 msg = "WARNING: end returns can be simpified if negative or 0 value"
166 coccilib.report.print_report(p[0],msg)
168 @script:python depends on report@
172 msg = "WARNING: end returns can be simpified"
173 coccilib.report.print_report(p[0],msg)
175 @script:python depends on report@
179 msg = "WARNING: end returns can be simpified if tested value is negative or 0"
180 coccilib.report.print_report(p[0],msg)