141167d07SJulia Lawall/// Device node iterators put the previous value of the index variable, so an 241167d07SJulia Lawall/// explicit put causes a double put. 341167d07SJulia Lawall/// 441167d07SJulia Lawall// Confidence: High 541167d07SJulia Lawall// Copyright: (C) 2015 Julia Lawall, Inria. GPLv2. 641167d07SJulia Lawall// URL: http://coccinelle.lip6.fr/ 741167d07SJulia Lawall// Options: --no-includes --include-headers 8*cc65e823SLuis R. Rodriguez// Requires: 1.0.4 941167d07SJulia Lawall// Keywords: for_each_child_of_node, etc. 1041167d07SJulia Lawall 11*cc65e823SLuis R. Rodriguez// This uses a conjunction, which requires at least coccinelle >= 1.0.4 12*cc65e823SLuis R. Rodriguez 1341167d07SJulia Lawallvirtual patch 1441167d07SJulia Lawallvirtual context 1541167d07SJulia Lawallvirtual org 1641167d07SJulia Lawallvirtual report 1741167d07SJulia Lawall 1841167d07SJulia Lawall@r exists@ 1941167d07SJulia Lawallexpression e1,e2; 2041167d07SJulia Lawalllocal idexpression n; 2141167d07SJulia Lawalliterator name for_each_node_by_name, for_each_node_by_type, 2241167d07SJulia Lawallfor_each_compatible_node, for_each_matching_node, 2341167d07SJulia Lawallfor_each_matching_node_and_match, for_each_child_of_node, 2441167d07SJulia Lawallfor_each_available_child_of_node, for_each_node_with_property; 2541167d07SJulia Lawalliterator i; 2641167d07SJulia Lawallposition p1,p2; 2741167d07SJulia Lawallstatement S; 2841167d07SJulia Lawall@@ 2941167d07SJulia Lawall 3041167d07SJulia Lawall( 3141167d07SJulia Lawall( 3241167d07SJulia Lawallfor_each_node_by_name(n,e1) S 3341167d07SJulia Lawall| 3441167d07SJulia Lawallfor_each_node_by_type(n,e1) S 3541167d07SJulia Lawall| 3641167d07SJulia Lawallfor_each_compatible_node(n,e1,e2) S 3741167d07SJulia Lawall| 3841167d07SJulia Lawallfor_each_matching_node(n,e1) S 3941167d07SJulia Lawall| 4041167d07SJulia Lawallfor_each_matching_node_and_match(n,e1,e2) S 4141167d07SJulia Lawall| 4241167d07SJulia Lawallfor_each_child_of_node(e1,n) S 4341167d07SJulia Lawall| 4441167d07SJulia Lawallfor_each_available_child_of_node(e1,n) S 4541167d07SJulia Lawall| 4641167d07SJulia Lawallfor_each_node_with_property(n,e1) S 4741167d07SJulia Lawall) 4841167d07SJulia Lawall& 4941167d07SJulia Lawalli@p1(...) { 5041167d07SJulia Lawall ... when != of_node_get(n) 5141167d07SJulia Lawall when any 5241167d07SJulia Lawall of_node_put@p2(n); 5341167d07SJulia Lawall ... when any 5441167d07SJulia Lawall} 5541167d07SJulia Lawall) 5641167d07SJulia Lawall 5741167d07SJulia Lawall@s exists@ 5841167d07SJulia Lawalllocal idexpression r.n; 5941167d07SJulia Lawallstatement S; 6041167d07SJulia Lawallposition r.p1,r.p2; 6141167d07SJulia Lawalliterator i; 6241167d07SJulia Lawall@@ 6341167d07SJulia Lawall 6441167d07SJulia Lawall of_node_put@p2(n); 6541167d07SJulia Lawall ... when any 6641167d07SJulia Lawall i@p1(..., n, ...) 6741167d07SJulia Lawall S 6841167d07SJulia Lawall 6941167d07SJulia Lawall@t depends on s && patch && !context && !org && !report@ 7041167d07SJulia Lawalllocal idexpression n; 7141167d07SJulia Lawallposition r.p2; 7241167d07SJulia Lawall@@ 7341167d07SJulia Lawall 7441167d07SJulia Lawall- of_node_put@p2(n); 7541167d07SJulia Lawall 7641167d07SJulia Lawall// ---------------------------------------------------------------------------- 7741167d07SJulia Lawall 7841167d07SJulia Lawall@t_context depends on s && !patch && (context || org || report)@ 7941167d07SJulia Lawalllocal idexpression n; 8041167d07SJulia Lawallposition r.p2; 8141167d07SJulia Lawallposition j0; 8241167d07SJulia Lawall@@ 8341167d07SJulia Lawall 8441167d07SJulia Lawall* of_node_put@j0@p2(n); 8541167d07SJulia Lawall 8641167d07SJulia Lawall// ---------------------------------------------------------------------------- 8741167d07SJulia Lawall 8841167d07SJulia Lawall@script:python t_org depends on org@ 8941167d07SJulia Lawallj0 << t_context.j0; 9041167d07SJulia Lawall@@ 9141167d07SJulia Lawall 9241167d07SJulia Lawallmsg = "ERROR: probable double put." 9341167d07SJulia Lawallcoccilib.org.print_todo(j0[0], msg) 9441167d07SJulia Lawall 9541167d07SJulia Lawall// ---------------------------------------------------------------------------- 9641167d07SJulia Lawall 9741167d07SJulia Lawall@script:python t_report depends on report@ 9841167d07SJulia Lawallj0 << t_context.j0; 9941167d07SJulia Lawall@@ 10041167d07SJulia Lawall 10141167d07SJulia Lawallmsg = "ERROR: probable double put." 10241167d07SJulia Lawallcoccilib.report.print_report(j0[0], msg) 10341167d07SJulia Lawall 104