/// Use WARN(1,...) rather than printk followed by WARN_ON(1)
///
// Confidence: High
// Copyright: (C) 2012 Julia Lawall, INRIA/LIP6.  GPLv2.
// Copyright: (C) 2012 Gilles Muller, INRIA/LiP6.  GPLv2.
// URL: http://coccinelle.lip6.fr/
// Comments:
// Options: --no-includes --include-headers

virtual patch
virtual context
virtual org
virtual report

@bad1@
position p;
@@

printk(...);
printk@p(...);
WARN_ON(1);

@r1 depends on context || report || org@
position p != bad1.p;
@@

 printk@p(...);
*WARN_ON(1);

@script:python depends on org@
p << r1.p;
@@

cocci.print_main("printk + WARN_ON can be just WARN",p)

@script:python depends on report@
p << r1.p;
@@

msg = "SUGGESTION: printk + WARN_ON can be just WARN"
coccilib.report.print_report(p[0],msg)

@ok1 depends on patch@
expression list es;
position p != bad1.p;
@@

-printk@p(
+WARN(1,
  es);
-WARN_ON(1);

@depends on patch@
expression list ok1.es;
@@

if (...)
- {
  WARN(1,es);
- }

// --------------------------------------------------------------------

@bad2@
position p;
@@

printk(...);
printk@p(...);
WARN_ON_ONCE(1);

@r2 depends on context || report || org@
position p != bad1.p;
@@

 printk@p(...);
*WARN_ON_ONCE(1);

@script:python depends on org@
p << r2.p;
@@

cocci.print_main("printk + WARN_ON_ONCE can be just WARN_ONCE",p)

@script:python depends on report@
p << r2.p;
@@

msg = "SUGGESTION: printk + WARN_ON_ONCE can be just WARN_ONCE"
coccilib.report.print_report(p[0],msg)

@ok2 depends on patch@
expression list es;
position p != bad2.p;
@@

-printk@p(
+WARN_ONCE(1,
  es);
-WARN_ON_ONCE(1);

@depends on patch@
expression list ok2.es;
@@

if (...)
- {
  WARN_ONCE(1,es);
- }
.git/log/net/llc/Makefile'>log</a><a href='/cgit.cgi/linux/net-next.git/tree/net/llc/Makefile?id=00300b2aac27556e2829cfd047b787af0f13b081'>tree</a><a href='/cgit.cgi/linux/net-next.git/commit/net/llc/Makefile?id=00300b2aac27556e2829cfd047b787af0f13b081'>commit</a><a href='/cgit.cgi/linux/net-next.git/diff/net/llc/Makefile?id=00300b2aac27556e2829cfd047b787af0f13b081'>diff</a></td><td class='form'><form class='right' method='get' action='/cgit.cgi/linux/net-next.git/log/net/llc/Makefile'>
<input type='hidden' name='id' value='00300b2aac27556e2829cfd047b787af0f13b081'/><select name='qt'>
<option value='grep'>log msg</option>
<option value='author'>author</option>
<option value='committer'>committer</option>
<option value='range'>range</option>
</select>
<input class='txt' type='search' size='10' name='q' value=''/>
<input type='submit' value='search'/>
</form>
</td></tr></table>
<div class='path'>path: <a href='/cgit.cgi/linux/net-next.git/log/?id=00300b2aac27556e2829cfd047b787af0f13b081'>root</a>/<a href='/cgit.cgi/linux/net-next.git/log/net?id=00300b2aac27556e2829cfd047b787af0f13b081'>net</a>/<a href='/cgit.cgi/linux/net-next.git/log/net/llc?id=00300b2aac27556e2829cfd047b787af0f13b081'>llc</a>/<a href='/cgit.cgi/linux/net-next.git/log/net/llc/Makefile?id=00300b2aac27556e2829cfd047b787af0f13b081'>Makefile</a></div><div class='content'><table class='list nowrap'><tr class='nohover'><th class='left'>Age</th><th class='left'>Commit message (<a href='/cgit.cgi/linux/net-next.git/log/net/llc/Makefile?id=00300b2aac27556e2829cfd047b787af0f13b081&amp;showmsg=1'>Expand</a>)</th><th class='left'>Author</th><th class='left'>Files</th><th class='left'>Lines</th></tr>