aboutsummaryrefslogtreecommitdiff
path: root/scripts/coccinelle
AgeCommit message (Collapse)AuthorFilesLines
2016-02-18Coccinelle: Add api/setup_timer.cocciVaishali Thakkar1-0/+199
Use the timer API function setup_timer instead of structure field assignments to initialize a timer. Signed-off-by: Vaishali Thakkar <[email protected]> Acked-by: Julia Lawall <[email protected]> Signed-off-by: Michal Marek <[email protected]>
2016-02-18coccinelle: bugon: reduce rule applicabilityJulia Lawall1-1/+1
Rule r is only use in org or report mode, so only execute it in those cases. Signed-off-by: Julia Lawall <[email protected]> Signed-off-by: Michal Marek <[email protected]>
2016-02-18Coccinelle: pm_runtime: reduce rule applicabilityJulia Lawall1-1/+1
Rule r is only used in org or report mode, so only execute it in those cases. Signed-off-by: Julia Lawall <[email protected]> Signed-off-by: Michal Marek <[email protected]>
2016-02-18Coccinelle: array_size: reduce rule applicabilityJulia Lawall1-1/+1
Rule r is only use in org or report mode, so only execute it in those cases. Signed-off-by: Julia Lawall <[email protected]> Signed-off-by: Michal Marek <[email protected]>
2016-02-18Coccinelle: reduce rule applicabilityJulia Lawall1-1/+1
Rule r is only use in org or report mode, so only execute it in those cases. Signed-off-by: Julia Lawall <[email protected]> Signed-off-by: Michal Marek <[email protected]>
2016-02-18scripts/coccinelle: modernize &Julia Lawall1-1/+1
& is no longer allowed in column 0, since Coccinelle 1.0.4. Signed-off-by: Julia Lawall <[email protected]> Tested-by: Nishanth Menon <[email protected]> Cc: [email protected] Signed-off-by: Michal Marek <[email protected]>
2016-01-12coccinelle: tests: unsigned value cannot be lesser than zeroAndrzej Hajda1-0/+75
Unsigned expressions cannot be lesser than zero. Presence of comparisons 'unsigned (<|<=|>|>=) 0' often indicates a bug, usually wrong type of variable. The patch beside finding such comparisons tries to eliminate false positives, mainly by bypassing range checks. gcc can detect such comparisons also using -Wtype-limits switch, but it warns also in correct cases, making too much noise. Signed-off-by: Andrzej Hajda <[email protected]> Acked-by: Julia Lawall <[email protected]> Signed-off-by: Michal Marek <[email protected]>
2015-10-26coccinelle: Improve checking for missing NULL terminatorsDaniel Granat1-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 <[email protected]> Acked-by: Julia Lawall <[email protected]> Signed-off-by: Michal Marek <[email protected]>
2015-10-26coccinelle: ifnullfree: handle various destroy functionsJulia Lawall1-1/+9
Extend ifnullfree to the various destroy functions that were recently extended to tolerate NULL arguments. Signed-off-by: Julia Lawall <[email protected]> Signed-off-by: Michal Marek <[email protected]>
2015-10-26coccinelle: ifnullfree: various cleanupsJulia Lawall1-11/+7
Adjust tests to compare against NULL, to match cases that explicitly make that comparison. Remove removal and re-addition of freeing functions. Add position variable on usb_free_urb in the non-patch case. Signed-off-by: Julia Lawall <[email protected]> Signed-off-by: Michal Marek <[email protected]>
2015-10-26cocinelle: iterators: semantic patch to delete unneeded of_node_putJulia Lawall1-0/+100
Device node iterators perform an of_node_put on each iteration, so putting an of_node_put before a continue results in a double put. Signed-off-by: Julia Lawall <[email protected]> Signed-off-by: Michal Marek <[email protected]>
2015-10-26scripts/coccinelle: fix typosJulia Lawall1-2/+2
Fix a couple spelling mistakes. Signed-off-by: Julia Lawall <[email protected]> Signed-off-by: Michal Marek <[email protected]>
2015-10-26coccinelle: misc: remove "complex return code" warningsJohan Hovold1-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 <[email protected]> Acked-by: Julia Lawall <[email protected]> Signed-off-by: Michal Marek <[email protected]>
2015-10-26coccinelle: tests: improve odd_ptr_err.cocciJulia Lawall1-34/+86
The original version only considered the case where the then branch contains only one call to PTR_ERR. Reimplement the whole thing to allow multiple calls, with potentially different arguments. Signed-off-by: Julia Lawall <[email protected]> Signed-off-by: Michal Marek <[email protected]>
2015-10-26coccinelle: misc: move constants to the rightJulia Lawall1-0/+171
Move constants to the right in binary operators. Signed-off-by: Julia Lawall <[email protected]> Signed-off-by: Michal Marek <[email protected]>
2015-09-08Merge branch 'akpm' (patches from Andrew)Linus Torvalds1-0/+84
Merge second patch-bomb from Andrew Morton: "Almost all of the rest of MM. There was an unusually large amount of MM material this time" * emailed patches from Andrew Morton <[email protected]>: (141 commits) zpool: remove no-op module init/exit mm: zbud: constify the zbud_ops mm: zpool: constify the zpool_ops mm: swap: zswap: maybe_preload & refactoring zram: unify error reporting zsmalloc: remove null check from destroy_handle_cache() zsmalloc: do not take class lock in zs_shrinker_count() zsmalloc: use class->pages_per_zspage zsmalloc: consider ZS_ALMOST_FULL as migrate source zsmalloc: partial page ordering within a fullness_list zsmalloc: use shrinker to trigger auto-compaction zsmalloc: account the number of compacted pages zsmalloc/zram: introduce zs_pool_stats api zsmalloc: cosmetic compaction code adjustments zsmalloc: introduce zs_can_compact() function zsmalloc: always keep per-class stats zsmalloc: drop unused variable `nr_to_migrate' mm/memblock.c: fix comment in __next_mem_range() mm/page_alloc.c: fix type information of memoryless node memory-hotplug: fix comments in zone_spanned_pages_in_node() and zone_spanned_pages_in_node() ...
2015-09-08coccinelle: mm: scripts/coccinelle/api/alloc/pool_zalloc-simple.cocciSean O. Stalley1-0/+84
add [pci|dma]_pool_zalloc coccinelle check. replaces instances of [pci|dma]_pool_alloc() followed by memset(0) with [pci|dma]_pool_zalloc(). Signed-off-by: Sean O. Stalley <[email protected]> Acked-by: Julia Lawall <[email protected]> Cc: Vinod Koul <[email protected]> Cc: Bjorn Helgaas <[email protected]> Cc: Gilles Muller <[email protected]> Cc: Nicolas Palix <[email protected]> Cc: Michal Marek <[email protected]> Cc: Sebastian Andrzej Siewior <[email protected]> Cc: Jonathan Corbet <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2015-08-19coccinelle: api: extend spatch for dropping unnecessary ownerKrzysztof Kozlowski1-0/+73
i2c_add_driver (through i2c_register_driver) sets the owner field so we can drop it also from i2c drivers, just like from platform drivers. Signed-off-by: Krzysztof Kozlowski <[email protected]> Acked-by: Julia Lawall <[email protected]> Signed-off-by: Michal Marek <[email protected]>
2015-06-03coccinelle: simple_return: Add a blank lineFabio Estevam1-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 <[email protected]> Acked-by: Julia Lawall <[email protected]> Signed-off-by: Michal Marek <[email protected]>
2015-05-25coccinelle: irqf_oneshot.cocci: Improve the generated commit logFabio Estevam1-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 <[email protected]> Acked- by: Valentin Rothberg <[email protected]> Signed-off-by: Michal Marek <[email protected]>
2015-05-21coccinelle: api: add vma_pages.cocciDmitry Kalinkin1-0/+60
This semantic patch replaces explicit computations of vma page count with explicit function call. Signed-off-by: Dmitry Kalinkin <[email protected]> Acked-by: Julia Lawall <[email protected]> Signed-off-by: Michal Marek <[email protected]>
2015-05-21scripts/coccinelle/misc/irqf_oneshot.cocci: Fix grammarFabio Estevam1-1/+1
Correct form is 'always requested'. Signed-off-by: Fabio Estevam <[email protected]> Acked-by: Julia Lawall <[email protected]> Signed-off-by: Michal Marek <[email protected]>
2015-05-21scripts/coccinelle/misc/semicolon.cocci: Use imperative moodFabio Estevam1-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 <[email protected]> Acked-by: Julia Lawall <[email protected]> Signed-off-by: Michal Marek <[email protected]>
2015-05-20coccinelle: simple_open: Use imperative moodFabio Estevam1-2/+2
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 <[email protected]> Acked-by: Julia Lawall <[email protected]> Signed-off-by: Michal Marek <[email protected]>
2015-05-20coccinelle: ifaddr: Fix the sentenceFabio Estevam1-2/+1
Make the sentence sensible. Signed-off-by: Fabio Estevam <[email protected]> Acked-by: Julia Lawall <[email protected]> Signed-off-by: Michal Marek <[email protected]>
2015-05-20coccinelle: returnvar: Use imperative moodFabio Estevam1-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 <[email protected]> Acked-by: Julia Lawall <[email protected]> Signed-off-by: Michal Marek <[email protected]>
2015-05-20coccinelle: pm_runtime: Insert blank lineFabio Estevam1-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 <[email protected]> Acked-by: Julia Lawall <[email protected]> Signed-off-by: Michal Marek <[email protected]>
2015-04-15scripts/coccinelle/misc/bugon.cocci: update bug_on conversion warningFabian Frederick1-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 <[email protected]> Suggested-by: Julia Lawall <[email protected]> Acked-by: Julia Lawall <[email protected]> Signed-off-by: Fabian Frederick <[email protected]> Signed-off-by: Michal Marek <[email protected]>
2015-03-25irqf_oneshot.cocci: add check of devm_request_threaded_irq()Valentin Rothberg1-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 <[email protected]> Signed-off-by: Peter Senna Tschudin <[email protected]> Acked-by: Julia Lawall <[email protected]> Signed-off-by: Michal Marek <[email protected]>
2014-12-20Merge branch 'misc' of ↵Linus Torvalds1-1/+1
git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild Pull misc kbuild changes from Michal Marek: "There are only a few things in the misc branch: - Fix for bugon.cocci semantic patch - Kdevelop4 files are .gitignored - Put make binrpm-pkg on diet" * 'misc' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild: scripts/package: binrpm-pkg do not create source and devel package .gitignore: Add Kdevelop4 project files bugon.cocci: fix Options at the macro
2014-11-24bugon.cocci: fix Options at the macroMauro Carvalho Chehab1-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 <[email protected]> Acked-by: Julia Lawall <[email protected]> Tested-by: Wolfram Sang <[email protected]> Fixes: 5be1df66 (Coccinelle: Script to replace if and BUG with BUG_ON) Cc: [email protected] Signed-off-by: Michal Marek <[email protected]>
2014-11-06coccinelle: api: add spatch to prevent unnecessary .ownerWolfram Sang1-0/+106
There are calls which silently set the owner of a module. This is the preferred way [1], so avoid setting it manually. Currently, we only care about platform drivers, but there might be more calls to be added later. [1] https://lkml.org/lkml/2014/10/12/87 Signed-off-by: Wolfram Sang <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2014-09-26coccinelle: misc: semantic patch to delete overly complex return code processingJulia Lawall1-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 <[email protected]> Signed-off-by: Michal Marek <[email protected]>
2014-08-14Merge branch 'misc' of ↵Linus Torvalds5-27/+258
git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild Pull misc kbuild updates from Michal Marek: "This is the non-critical part of kbuild for 3.17-rc1: - make help hint to use make -s with make kernelrelease et al. - moved a kbuild document to Documentation/kbuild where it belongs - four new Coccinelle scripts, one dropped and one fixed - new make kselftest target to run various tests on the kernel" * 'misc' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild: kbuild: kselftest - new make target to build and run kernel selftests Coccinelle: Script to replace if and BUG with BUG_ON Coccinelle: Script to detect incorrect argument to sizeof Coccinelle: Script to use ARRAY_SIZE instead of division of two sizeofs Coccinelle: Script to detect cast after memory allocation coccinelle/null: solve parse error Documentation: headers_install.txt is part of kbuild kbuild: make -s should be used with kernelrelease/kernelversion/image_name
2014-08-08scripts/coccinelle/free/ifnullfree.cocci: add copyright informationFabian Frederick1-2/+3
All coccinelle scripts have a copyright in the header. Signed-off-by: Fabian Frederick <[email protected]> Suggested-by: Julia Lawall <[email protected]> Acked-by: Julia Lawall <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2014-08-08scripts/coccinelle/free: add NULL test before freeing functionsFabian Frederick1-0/+52
Warns or generates patch for NULL check before the following functions: kfree usb_free_urb debugfs_remove debugfs_remove_recursive Signed-off-by: Fabian Frederick <[email protected]> Acked-by: Julia Lawall <[email protected]> Cc: Gilles Muller <[email protected]> Cc: Joe Perches <[email protected]> Cc: Markus Elfring <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2014-08-06Coccinelle: Script to replace if and BUG with BUG_ONHimangi Saraogi1-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 <[email protected]> Acked-by: Julia Lawall <[email protected]> Signed-off-by: Michal Marek <[email protected]>
2014-08-06Coccinelle: Script to detect incorrect argument to sizeofHimangi Saraogi1-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 <[email protected]> Acked-by: Julia Lawall <[email protected]> Signed-off-by: Michal Marek <[email protected]>
2014-08-06Coccinelle: Script to use ARRAY_SIZE instead of division of two sizeofsHimangi Saraogi1-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 <[email protected]> Acked-by: Julia Lawall <[email protected]> Signed-off-by: Michal Marek <[email protected]>
2014-08-06Coccinelle: Script to detect cast after memory allocationHimangi Saraogi2-67/+72
This script detects cases of use of cast for the value returned by kmalloc, kzalloc, kcalloc, kmem_cache_alloc, kmem_cache_zalloc, kmem_cache_alloc_node, kmalloc_node and kzalloc_node and removes the cast as it is not useful. This Coccinelle script replaces drop_kmalloc_cast.cocci as it removes the casting in more limited cases of kmalloc, kzalloc and kcalloc. Signed-off-by: Himangi Saraogi <[email protected]> Acked-by: Julia Lawall <[email protected]> Signed-off-by: Michal Marek <[email protected]>
2014-08-06coccinelle/null: solve parse errorHimangi Saraogi1-1/+2
This patch solves the parse-error by adding @@ . This is necessary since Coccinelle version 1.0.0-rc20. Also, the comment is added to use a recent version of Coccinelle. Signed-off-by: Himangi Saraogi <[email protected]> Acked-by: Julia Lawall <[email protected]> Signed-off-by: Michal Marek <[email protected]>
2014-06-19devres: remove devm_request_and_ioremap()Jingoo Han1-90/+0
devm_request_and_ioremap() was obsoleted by the commit 7509657 ("lib: devres: Introduce devm_ioremap_resource()") and has been deprecated for a long time. So, let's remove this function. In addition, all usages of devm_request_and_ioremap() are also removed. Signed-off-by: Jingoo Han <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2014-06-10coccicheck: Add unneeded return variable testPeter Senna Tschudin1-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 <[email protected]> Signed-off-by: Michal Marek <[email protected]>
2014-06-09coccinelle: Check for missing NULL terminators in of_device_id tablesStephen Boyd1-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 <[email protected]> Cc: Gilles Muller <[email protected]> Cc: Nicolas Palix <[email protected]> Cc: Rob Herring <[email protected]> Cc: [email protected] Signed-off-by: Stephen Boyd <[email protected]> Acked-by: Grant Likely <[email protected]> Signed-off-by: Julia Lawall <[email protected]> Signed-off-by: Michal Marek <[email protected]>
2014-04-08scripts/coccinelle: Use PTR_ERR_OR_ZEROSachin Kamat1-7/+7
PTR_RET is deprecated. Do not recommend its usage anymore. Use PTR_ERR_OR_ZERO instead. Signed-off-by: Sachin Kamat <[email protected]> Signed-off-by: Michal Marek <[email protected]>
2014-03-29Coccicheck: Remove memcpy to struct assignment testPeter Senna Tschudin1-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 <[email protected]> Signed-off-by: Michal Marek <[email protected]>
2014-01-03scripts: Coccinelle script for pm_runtime_* return checks with IS_ERR_VALUENishanth Menon1-0/+109
As indicated by Sekhar in [1], there seems to be a tendency to use IS_ERR_VALUE to check the error result for pm_runtime_* functions which make no sense considering commit c48cd65 (ARM: OMAP: use consistent error checking) - the error values can either be < 0 for error OR 0, 1 in cases where we have success. So, setup a coccinelle script to help identify the same. [1] http://marc.info/?t=138472678100003&r=1&w=2 Cc: Russell King <[email protected]> Reported-by: Sekhar Nori <[email protected]> Signed-off-by: Nishanth Menon <[email protected]> Acked-by: Julia Lawall <[email protected]> Signed-off-by: Michal Marek <[email protected]>
2013-10-23scripts/coccinelle/api: remove devm_request_and_ioremap.cocciWolfram Sang1-105/+0
Use of this function is discouraged in favour of devm_ioremap_resource(). Don't advertise it. Signed-off-by: Wolfram Sang <[email protected]> Acked-by: Julia Lawall <[email protected]> Signed-off-by: Michal Marek <[email protected]>
2013-09-07Merge branch 'misc' of ↵Linus Torvalds1-0/+58
git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild Pull misc kbuild updates from Michal Marek: "In the kbuild misc branch, I have: - make rpm-pkg updates, most importantly the rpm package now calls /sbin/installkernel - make deb-pkg: debuginfo split, correct kernel image path for parisc, mips and powerpc and a couple more minor fixes - New coccinelle check" * 'misc' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild: scripts/checkkconfigsymbols.sh: replace echo -e with printf Provide version number for Debian firmware package coccinelle: replace 0/1 with false/true in functions returning bool deb-pkg: add a hook argument to match debian hooks parameters deb-pkg: fix installed image path on parisc, mips and powerpc deb-pkg: split debug symbols in their own package deb-pkg: use KCONFIG_CONFIG instead of .config file directly rpm-pkg: add generation of kernel-devel rpm-pkg: install firmware files in kernel relative directory rpm-pkg: add %post section to create initramfs and grub hooks
2013-08-13coccinelle: replace 0/1 with false/true in functions returning boolRasmus Villemoes1-0/+58
This semantic patch replaces "return {0,1};" with "return {false,true};" in functions returning bool. Signed-off-by: Rasmus Villemoes <[email protected]> Acked-by: Julia Lawall <[email protected]> Signed-off-by: Michal Marek <[email protected]>