summaryrefslogtreecommitdiffstats
path: root/scripts/coccinelle/misc
Commit message (Collapse)AuthorAgeFilesLines
* Coccinelle: misc: Add support for devm variant in all modesVaishali Thakkar2016-12-111-3/+12
| | | | | | | | | | | | | | Add missing support for the devm_request_threaded_irq in the rules of context, report and org modes. Misc: ---- To be consistent with other scripts, change confidence level of the script to 'Moderate'. Signed-off-by: Vaishali Thakkar <vaishali.thakkar@oracle.com> Acked-by: Julia Lawall <julia.lawall@lip6.fr> Signed-off-by: Michal Marek <mmarek@suse.com>
* Coccinelle: misc: Improve the result given by context modeVaishali Thakkar2016-12-111-1/+2
| | | | | | | | | To eliminate false positives given by the context mode, add necessary arguments for the function request_threaded_irq. Signed-off-by: Vaishali Thakkar <vaishali.thakkar@oracle.com> Acked-by: Julia Lawall <julia.lawall@lip6.fr> Signed-off-by: Michal Marek <mmarek@suse.com>
* Coccinelle: misc: Improve the matching of rulesVaishali Thakkar2016-12-111-13/+23
| | | | | | | | | | | Currently because of the left associativity of the operators, pattern IRQF_ONESHOT | flags does not match with the pattern when we have more than one flag after the disjunction. This eventually results in giving false positives by the script. This patch eliminates these FPs by improving the rule. Signed-off-by: Vaishali Thakkar <vaishali.thakkar@oracle.com> Signed-off-by: Michal Marek <mmarek@suse.com>
* Coccinelle: Add misc/boolconv.cocciAndrew F. Davis2016-12-111-0/+90
| | | | | | | | Add a script to check for unneeded conversions to bool. Signed-off-by: Andrew F. Davis <afd@ti.com> Acked-by: Julia Lawall <julia.lawall@lip6.fr> Signed-off-by: Michal Marek <mmarek@suse.com>
* Coccinelle: flag conditions with no effectNicholas Mc Guire2016-10-111-0/+64
| | | | | | | | | Report code constructs where the if and else branch are functionally identical. In cases where this is intended it really should be documented - most reported cases probably are bugs. Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org> Signed-off-by: Michal Marek <mmarek@suse.com>
* Coccinelle: noderef: Add new rules and correct the old ruleVaishali Thakkar2016-06-201-1/+17
| | | | | | | | | | | | Add new rules to detect the cases where sizeof is used in function calls as a argument. Also, for the patch mode third rule should behave same as second rule with arguments reversed. So, change that as well. Signed-off-by: Vaishali Thakkar <vaishali.thakkar@oracle.com> Acked-by: Julia Lawall <julia.lawall@lip6.fr> Signed-off-by: Michal Marek <mmarek@suse.com>
* scripts: coccinelle: remove check to move constants to rightWolfram Sang2016-04-201-171/+0
| | | | | | | | | | The header mentions this check depends on personal taste. I agree. Running coccicheck on patches before I apply them, this SmPL produced enough false positives for me that I'd rather see it removed. Signed-off-by: Wolfram Sang <wsa@the-dreams.de> Acked-by: Julia Lawall <julia.lawall@lip6.fr> Signed-off-by: Michal Marek <mmarek@suse.com>
* coccinelle: bugon: reduce rule applicabilityJulia Lawall2016-02-181-1/+1
| | | | | | | | Rule r is only use in org or report mode, so only execute it in those cases. Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> Signed-off-by: Michal Marek <mmarek@suse.com>
* Coccinelle: array_size: reduce rule applicabilityJulia Lawall2016-02-181-1/+1
| | | | | | | | Rule r is only use in org or report mode, so only execute it in those cases. Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> Signed-off-by: Michal Marek <mmarek@suse.com>
* Coccinelle: reduce rule applicabilityJulia Lawall2016-02-181-1/+1
| | | | | | | | Rule r is only use in org or report mode, so only execute it in those cases. Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> Signed-off-by: Michal Marek <mmarek@suse.com>
* coccinelle: Improve checking for missing NULL terminatorsDaniel Granat2015-10-261-5/+28
| | | | | | | | | | Extend checking on tables containing structures which are initialized without specifying member name. Added new tables for checking: i2c_device_id and platform_device_id. Signed-off-by: Daniel Granat <d.granat@samsung.com> Acked-by: Julia Lawall <julia.lawall@lip6.fr> Signed-off-by: Michal Marek <mmarek@suse.cz>
* coccinelle: misc: remove "complex return code" warningsJohan Hovold2015-10-261-180/+0
| | | | | | | | | | | | | | | | | This effectively reverts 932058a5d5f9 ("coccinelle: misc: semantic patch to delete overly complex return code processing"). There can be both symmetry and readability reasons for not wanting to do the final function call as part of the return statement and to maintain a clear separation of success and error paths. Since this is in no way mandated by the coding standard, let's just remove this semantic patch to avoid having "clean up" patches being posted over and over in response to these Coccinelle warnings. Signed-off-by: Johan Hovold <johan@kernel.org> Acked-by: Julia Lawall <julia.lawall@lip6.fr> Signed-off-by: Michal Marek <mmarek@suse.cz>
* coccinelle: misc: move constants to the rightJulia Lawall2015-10-261-0/+171
| | | | | | | Move constants to the right in binary operators. Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> Signed-off-by: Michal Marek <mmarek@suse.com>
* coccinelle: simple_return: Add a blank lineFabio Estevam2015-06-031-1/+1
| | | | | | | | | | Insert a blank line in order to improve the readability of the generated patch and also make it consistent with the other .cocci files. Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com> Acked-by: Julia Lawall <julia.lawall@lip6.fr> Signed-off-by: Michal Marek <mmarek@suse.cz>
* coccinelle: irqf_oneshot.cocci: Improve the generated commit logFabio Estevam2015-05-251-2/+5
| | | | | | | | | | Improve the commit log of the generated patch by mentioning the commit log that makes threaded IRQs without a primary handler to be requested with the IRQF_ONESHOT flag. Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com> Acked- by: Valentin Rothberg <valentinrothberg@gmail.com> Signed-off-by: Michal Marek <mmarek@suse.cz>
* scripts/coccinelle/misc/irqf_oneshot.cocci: Fix grammarFabio Estevam2015-05-211-1/+1
| | | | | | | | Correct form is 'always requested'. Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com> Acked-by: Julia Lawall <julia.lawall@lip6.fr> Signed-off-by: Michal Marek <mmarek@suse.cz>
* scripts/coccinelle/misc/semicolon.cocci: Use imperative moodFabio Estevam2015-05-211-1/+1
| | | | | | | | | | | | | | | According to Documentation/SubmittingPatches: "Describe your changes in imperative mood, e.g. "make xyzzy do frotz" instead of "[This patch] makes xyzzy do frotz" or "[I] changed xyzzy to do frotz", as if you are giving orders to the codebase to change its behaviour. So do as recommended. Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com> Acked-by: Julia Lawall <julia.lawall@lip6.fr> Signed-off-by: Michal Marek <mmarek@suse.cz>
* coccinelle: ifaddr: Fix the sentenceFabio Estevam2015-05-201-2/+1
| | | | | | | | Make the sentence sensible. Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com> Acked-by: Julia Lawall <julia.lawall@lip6.fr> Signed-off-by: Michal Marek <mmarek@suse.cz>
* coccinelle: returnvar: Use imperative moodFabio Estevam2015-05-201-1/+1
| | | | | | | | | | | | | | | According to Documentation/SubmittingPatches: "Describe your changes in imperative mood, e.g. "make xyzzy do frotz" instead of "[This patch] makes xyzzy do frotz" or "[I] changed xyzzy to do frotz", as if you are giving orders to the codebase to change its behaviour." So do as recommended. Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com> Acked-by: Julia Lawall <julia.lawall@lip6.fr> Signed-off-by: Michal Marek <mmarek@suse.cz>
* scripts/coccinelle/misc/bugon.cocci: update bug_on conversion warningFabian Frederick2015-04-151-1/+1
| | | | | | | | | | | | if()/BUG conversion to BUG_ON must be avoided when there's side effect in condition. The reason being BUG_ON won't execute the condition when CONFIG_BUG is not defined. Inspired-by: J. Bruce Fields <bfields@fieldses.org> Suggested-by: Julia Lawall <Julia.Lawall@lip6.fr> Acked-by: Julia Lawall <Julia.Lawall@lip6.fr> Signed-off-by: Fabian Frederick <fabf@skynet.be> Signed-off-by: Michal Marek <mmarek@suse.cz>
* irqf_oneshot.cocci: add check of devm_request_threaded_irq()Valentin Rothberg2015-03-251-0/+24
| | | | | | | | | | | | | | | Since commit 1c6c69525b40eb76de8adf039409722015927dc3 ("genirq: Reject bogus threaded irq requests") threaded IRQs without a primary handler need to be requested with IRQF_ONESHOT, otherwise the request will fail. Until now, this coccinelle script only checked request_threaded_irq(). However, the counterpart devm function (see kernel/irq/devres.c) is also affected by the missing flag which can be detected with this patch. Signed-off-by: Valentin Rothberg <valentinrothberg@gmail.com> Signed-off-by: Peter Senna Tschudin <peter.senna@gmail.com> Acked-by: Julia Lawall <julia.lawall@lip6.fr> Signed-off-by: Michal Marek <mmarek@suse.cz>
* bugon.cocci: fix Options at the macroMauro Carvalho Chehab2014-11-241-1/+1
| | | | | | | | | | | | | | | | | | | | | | | The comma after --no-includes makes coccinelle to not run the script: /usr/bin/spatch -D report --very-quiet --no-show-diff --cocci-file ./scripts/coccinelle/misc/bugon.cocci --no-includes, --include-headers --patch . --dir drivers/media/platform/coda/ -I ./arch/x86/include -I arch/x86/include/generated -I include -I ./arch/x86/include/uapi -I arch/x86/include/generated/uapi -I ./include/uapi -I include/generated/uapi -I ./include/linux/kconfig.h Usage: spatch.opt --sp-file <SP> <infile> [-o <outfile>] [--iso-file <iso>] [options] Options are: --sp-file <file> the semantic patch file -o <file> the output file --in-place do the modification on the file directly --backup-suffix suffix to use when making a backup for inplace ... At least with Fedora 20 coccinelle package: coccinelle-1.0.0-0.rc20.1.fc21.x86_64 Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com> Acked-by: Julia Lawall <julia.lawall@lip6.fr> Tested-by: Wolfram Sang <wsa@the-dreams.de> Fixes: 5be1df66 (Coccinelle: Script to replace if and BUG with BUG_ON) Cc: stable@vger.kernel.org Signed-off-by: Michal Marek <mmarek@suse.cz>
* coccinelle: misc: semantic patch to delete overly complex return code processingJulia Lawall2014-09-261-0/+180
| | | | | | | | | | | | This semantic patch simplifies cases where the effect of the processing of a function call's return code is just to return the result of the function directly. It may also delete a local return flag variable, if this is no longer used. This was proposed by Uwe Kleine-König. Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> Signed-off-by: Michal Marek <mmarek@suse.cz>
* Coccinelle: Script to replace if and BUG with BUG_ONHimangi Saraogi2014-08-061-0/+62
| | | | | | | | | | This script detects cases where BUG() follows an if condition on an expression and replaces the if condition and BUG() with a BUG_ON having the conditional expression of the if statement as argument. Signed-off-by: Himangi Saraogi <himangi774@gmail.com> Acked-by: Julia Lawall <julia.lawall@lip6.fr> Signed-off-by: Michal Marek <mmarek@suse.cz>
* Coccinelle: Script to detect incorrect argument to sizeofHimangi Saraogi2014-08-061-0/+76
| | | | | | | | | | | | This makes an effort to find cases where the argument to sizeof is wrong in memory allocation functions by checking the type of the allocated memory when it is a double pointer and ensuring the sizeof argument takes a pointer to the the memory being allocated. There are false positives in cases the sizeof argument is not used in constructing the return value. Signed-off-by: Himangi Saraogi <himangi774@gmail.com> Acked-by: Julia Lawall <julia.lawall@lip6.fr> Signed-off-by: Michal Marek <mmarek@suse.cz>
* Coccinelle: Script to use ARRAY_SIZE instead of division of two sizeofsHimangi Saraogi2014-08-061-0/+87
| | | | | | | | | | | This script detects cases where ARRAY_SIZE can be used such as where there is a division of sizeof the array by the sizeof its first element or by any indexed element or the element type. It replaces the division of the two sizeofs by ARRAY_SIZE. Signed-off-by: Himangi Saraogi <himangi774@gmail.com> Acked-by: Julia Lawall <julia.lawall@lip6.fr> Signed-off-by: Michal Marek <mmarek@suse.cz>
* coccicheck: Add unneeded return variable testPeter Senna Tschudin2014-06-101-0/+66
| | | | | | | | | This semantic patch looks for variables that are initialized with a constant, are never updated, and are only used as parameter of return. Return the constant instead of using a variable. Signed-off-by: Peter Senna Tschudin <peter.senna@gmail.com> Signed-off-by: Michal Marek <mmarek@suse.cz>
* coccinelle: Check for missing NULL terminators in of_device_id tablesStephen Boyd2014-06-091-0/+62
| | | | | | | | | | | | | | | | | Failure to terminate an of_device_id table can lead to confusing failures depending on where the compiler places the array. Add a check to make sure these tables are terminated. Thanks to Mitchel Humpherys for coming up with the pattern initially. Cc: Mitchel Humpherys <mitchelh@codeaurora.org> Cc: Gilles Muller <Gilles.Muller@lip6.fr> Cc: Nicolas Palix <nicolas.palix@imag.fr> Cc: Rob Herring <robh+dt@kernel.org> Cc: devicetree@vger.kernel.org Signed-off-by: Stephen Boyd <sboyd@codeaurora.org> Acked-by: Grant Likely <grant.likely@linaro.org> Signed-off-by: Julia Lawall <julia.lawall@lip6.fr> Signed-off-by: Michal Marek <mmarek@suse.cz>
* Coccicheck: Remove memcpy to struct assignment testPeter Senna Tschudin2014-03-291-103/+0
| | | | | | | | | | The Coccinelle script scripts/coccinelle/misc/memcpy-assign.cocci look for opportunities to replace a call to memcpy by a struct assignment. This patch removes memcpy-assign.cocci as it is not clear that this convention has an impact on the generated code. Signed-off-by: Peter Senna Tschudin <peter.senna@gmail.com> Signed-off-by: Michal Marek <mmarek@suse.cz>
* coccinelle: replace 0/1 with false/true in functions returning boolRasmus Villemoes2013-08-131-0/+58
| | | | | | | | | This semantic patch replaces "return {0,1};" with "return {false,true};" in functions returning bool. Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk> Acked-by: Julia Lawall <Julia.Lawall@lip6.fr> Signed-off-by: Michal Marek <mmarek@suse.cz>
* Coccinelle: Update the options used to the new option schemeNicolas Palix2013-07-038-8/+8
| | | | | | | | | | | | spatch has changed its option scheme. E.g., --no_show_diff is now --no-show-diff This patch updates: - scripts/coccicheck - Semantic patches under scripts/coccinelle/ Signed-off-by: Nicolas Palix <nicolas.palix@imag.fr> Signed-off-by: Michal Marek <mmarek@suse.cz>
* scripts/coccinelle: find constant additions that could be bit orsJulia Lawall2013-02-221-0/+55
| | | | | | | | Semantic patch (http://coccinelle.lip6.fr/) to check for constants that are added but are used elsewhere as bitmasks. Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> Signed-off-by: Michal Marek <mmarek@suse.cz>
* scripts/coccinelle/misc/memcpy-assign.cocci: Replace memcpy with struct ↵Peter Senna Tschudin2013-02-221-0/+103
| | | | | | | | | | | | | assignment There are error-prone memcpy() that can be replaced by struct assignment that are type-safe and much easier to read. This semantic patch looks for memcpy() that can be replaced by struct assignment. Inspired by patches sent by Ezequiel Garcia <elezegarcia@gmail.com> Signed-off-by: Peter Senna Tschudin <peter.senna@gmail.com> Signed-off-by: Michal Marek <mmarek@suse.cz>
* scripts/coccinelle/misc/semicolon.cocci: Add unneeded semicolon testPeter Senna Tschudin2013-01-241-0/+83
| | | | | | | | | | | | | | | | | | | This semantic patch looks for semicolons that can be removed without changing the semantics of the code. The confidence is moderate because there are some false positives on cases like: b/drivers/mmc/host/cb710-mmc.c:589 break; case MMC_POWER_UP: default: - /* ignore */; } There are 37 patches accepted reported by this semantic patch and more than 300 fixes to be applied. Signed-off-by: Peter Senna Tschudin <peter.senna@gmail.com> Signed-off-by: Michal Marek <mmarek@suse.cz>
* scripts/coccinelle/misc/warn.cocci: use WARNJulia Lawall2012-12-091-0/+109
| | | | | | | Use WARN(1,...) rather than printk followed by WARN(1). Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> Signed-off-by: Michal Marek <mmarek@suse.cz>
* scripts/coccinelle: Find threaded IRQs requests which are missing IRQF_ONESHOTLars-Peter Clausen2012-07-131-0/+65
| | | | | | | | | | | Since commit 1c6c69525b ("genirq: Reject bogus threaded irq requests") threaded IRQs without a primary handler need to be requested with IRQF_ONESHOT, otherwise the request will fail. This semantic patch will help to statically identify (and fix) such cases. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> Signed-off-by: Michal Marek <mmarek@suse.cz>
* scripts/coccinelle: sizeof of pointerJulia Lawall2012-05-251-0/+65
| | | | | Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> Signed-off-by: Michal Marek <mmarek@suse.cz>
* scripts/coccinelle: address test is always trueJulia Lawall2012-05-251-0/+35
| | | | | Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> Signed-off-by: Michal Marek <mmarek@suse.cz>
* coccinelle: semantic patch for bool issuesJulia Lawall2012-02-251-0/+178
| | | | | | Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> Reviewed-by: Rusty Russell <rusty@rustcorp.com.au> Signed-off-by: Michal Marek <mmarek@suse.cz>
* coccinelle: semantic patch to check for PTR_ERR after reassignmentJulia Lawall2012-02-251-0/+41
| | | | | Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> Signed-off-by: Michal Marek <mmarek@suse.cz>
* scripts/coccinelle: improve the coverage of some semantic patchesJulia Lawall2012-01-151-4/+4
| | | | | | | | | | This patch ensures that all semantic patches in the scripts/coccinelle directory provide the report option. Report messages that include line numbers now have the line number preceded by "line" for easier subsequent processing. Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> Signed-off-by: Michal Marek <mmarek@suse.cz>
* scripts/coccinelle: update for compatability with Coccinelle 0.2.4Julia Lawall2010-12-031-3/+3
| | | | | | | | | | | | For doubleinit.cocci, Coccinelle 0.2.4 requires a comma after ... in a field list. Coccinelle also now behaves gracefully when a definition is provided for a virtual that doesn't exist, so there is no need for the semantic patch code to check for this case. Updated the documentation to reflect the fact that the best results will now be obtained with Coccinelle version 0.2.4 or later. Signed-off-by: Julia Lawall <julia@diku.dk>
* Coccinelle: Add misc/ifcol.cocciNicolas Palix2010-08-311-0/+48
| | | | | | | | | | | | | | | Find confusingly indented code in or after an if. An if branch should be indented. The code following an if should not be indented. Sometimes, code after an if that is indented is actually intended to be part of the if branch. This has a high rate of false positives, because Coccinelle's column calculation does not distinguish between spaces and tabs, so code that is not visually aligned may be considered to be in the same column. Signed-off-by: Nicolas Palix <npalix@diku.dk> Signed-off-by: Julia Lawall <julia@diku.dk> Signed-off-by: Michal Marek <mmarek@suse.cz>
* Coccinelle: Add misc/doubleinit.cocciNicolas Palix2010-08-311-0/+53
Find duplicate field initializations. This has a high rate of false positives due to #ifdefs, which Coccinelle is not aware of in a structure initialization. Signed-off-by: Nicolas Palix <npalix@diku.dk> Signed-off-by: Julia Lawall <julia@diku.dk> Signed-off-by: Michal Marek <mmarek@suse.cz>
OpenPOWER on IntegriCloud