17f904d7eSThomas Gleixner// SPDX-License-Identifier: GPL-2.0-only 249ab7a39SNicolas Palix/// Find confusingly indented code in or after an if. An if branch should 349ab7a39SNicolas Palix/// be indented. The code following an if should not be indented. 449ab7a39SNicolas Palix/// Sometimes, code after an if that is indented is actually intended to be 549ab7a39SNicolas Palix/// part of the if branch. 649ab7a39SNicolas Palix/// 769c4907bSJulia Lawall//# This has a high rate of false positives, because Coccinelle's column 869c4907bSJulia Lawall//# calculation does not distinguish between spaces and tabs, so code that 969c4907bSJulia Lawall//# is not visually aligned may be considered to be in the same column. 1069c4907bSJulia Lawall// 1149ab7a39SNicolas Palix// Confidence: Low 127f904d7eSThomas Gleixner// Copyright: (C) 2010 Nicolas Palix, DIKU. 137f904d7eSThomas Gleixner// Copyright: (C) 2010 Julia Lawall, DIKU. 147f904d7eSThomas Gleixner// Copyright: (C) 2010 Gilles Muller, INRIA/LiP6. 15*f01701ceSJulia Lawall// URL: https://coccinelle.gitlabpages.inria.fr/website 1649ab7a39SNicolas Palix// Comments: 1793f14468SNicolas Palix// Options: --no-includes --include-headers 1849ab7a39SNicolas Palix 1949ab7a39SNicolas Palixvirtual org 2049ab7a39SNicolas Palixvirtual report 2149ab7a39SNicolas Palix 2249ab7a39SNicolas Palix@r disable braces4@ 2349ab7a39SNicolas Palixposition p1,p2; 2449ab7a39SNicolas Palixstatement S1,S2; 2549ab7a39SNicolas Palix@@ 2649ab7a39SNicolas Palix 2749ab7a39SNicolas Palix( 2849ab7a39SNicolas Palixif (...) { ... } 2949ab7a39SNicolas Palix| 3049ab7a39SNicolas Palixif (...) S1@p1 S2@p2 3149ab7a39SNicolas Palix) 3249ab7a39SNicolas Palix 3349ab7a39SNicolas Palix@script:python depends on org@ 3449ab7a39SNicolas Palixp1 << r.p1; 3549ab7a39SNicolas Palixp2 << r.p2; 3649ab7a39SNicolas Palix@@ 3749ab7a39SNicolas Palix 3849ab7a39SNicolas Palixif (p1[0].column == p2[0].column): 3949ab7a39SNicolas Palix cocci.print_main("branch",p1) 4049ab7a39SNicolas Palix cocci.print_secs("after",p2) 4149ab7a39SNicolas Palix 4249ab7a39SNicolas Palix@script:python depends on report@ 4349ab7a39SNicolas Palixp1 << r.p1; 4449ab7a39SNicolas Palixp2 << r.p2; 4549ab7a39SNicolas Palix@@ 4649ab7a39SNicolas Palix 4749ab7a39SNicolas Palixif (p1[0].column == p2[0].column): 4849ab7a39SNicolas Palix msg = "code aligned with following code on line %s" % (p2[0].line) 4949ab7a39SNicolas Palix coccilib.report.print_report(p1[0],msg) 50