summaryrefslogtreecommitdiffstats
path: root/scripts/coccinelle
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch 'misc' of ↵Linus Torvalds2012-10-122-0/+91
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild Pull kbuild misc changes from Michal Marek: "In the non-critical part of kbuild, I have - Some make coccicheck improvements and two new tests - Support for a cleaner html output in scripts/kernel-doc, named html5 (no, it does not play videos, yet) BTW, Randy wants to route further kernel-doc patches through the kbuild tree." * 'misc' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild: Update SmPL/Coccinelle section of MAINTAINERS coccicheck: Add the rep+ctxt mode scripts/coccinelle/tests/odd_ptr_err.cocci: semantic patch for IS_ERR/PTR_ERR inconsistency scripts/tags.sh: Add magic for pci access functions scripts/coccinelle: ptr_ret: Add ternary operator version scripts/kernel-doc: drop maintainer scripts/kernel-doc: added support for html5
| * scripts/coccinelle/tests/odd_ptr_err.cocci: semantic patch for ↵Julia Lawall2012-10-111-0/+65
| | | | | | | | | | | | | | IS_ERR/PTR_ERR inconsistency Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> Signed-off-by: Michal Marek <mmarek@suse.cz>
| * scripts/coccinelle: ptr_ret: Add ternary operator versionLars-Peter Clausen2012-08-311-0/+26
| | | | | | | | | | | | | | | | Add a ternary operator version of the open-coded PTR_RET(). 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>
* | Merge branch 'for-linus' of ↵Linus Torvalds2012-10-011-2/+2
|\ \ | |/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial Pull the trivial tree from Jiri Kosina: "Tiny usual fixes all over the place" * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial: (34 commits) doc: fix old config name of kprobetrace fs/fs-writeback.c: cleanup riteback_sb_inodes kerneldoc btrfs: fix the commment for the action flags in delayed-ref.h btrfs: fix trivial typo for the comment of BTRFS_FREE_INO_OBJECTID vfs: fix kerneldoc for generic_fh_to_parent() treewide: fix comment/printk/variable typos ipr: fix small coding style issues doc: fix broken utf8 encoding nfs: comment fix platform/x86: fix asus_laptop.wled_type module parameter mfd: printk/comment fixes doc: getdelays.c: remember to close() socket on error in create_nl_socket() doc: aliasing-test: close fd on write error mmc: fix comment typos dma: fix comments spi: fix comment/printk typos in spi Coccinelle: fix typo in memdup_user.cocci tmiofb: missing NULL pointer checks tools: perf: Fix typo in tools/perf tools/testing: fix comment / output typos ...
| * Coccinelle: fix typo in memdup_user.cocciFengguang Wu2012-09-011-2/+2
| | | | | | | | | | Signed-off-by: Fengguang Wu <fengguang.wu@intel.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
* | scripts/coccinelle: list iterator variable semantic patchJulia Lawall2012-07-131-0/+147
| | | | | | | | | | | | | | | | | | | | If list_for_each_entry, etc complete a traversal of the list, the iterator variable ends up pointing to an address at an offset from the list head, and not a meaningful structure. Thus this value should not be used after the end of the iterator. 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>
* Merge branch 'misc' of ↵Linus Torvalds2012-05-282-0/+100
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild Pull misc kbuild changes from Michal Marek: "The non-critical part of kbuild for 3.5 includes - two new coccinelle checks - fix for make deb-pkg to include generated headers in arch/*/include I have more make-deb-pkg fixes in the backlog, but these will likely have to wait for 3.6." * 'misc' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild: builddeb: include autogenerated header files scripts/coccinelle: sizeof of pointer scripts/coccinelle: address test is always true
| * 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>
* | Merge branch 'akpm' (Andrew's patch-bomb)Linus Torvalds2012-04-051-0/+70
|\ \ | |/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Merge batch of fixes from Andrew Morton: "The simple_open() cleanup was held back while I wanted for laggards to merge things. I still need to send a few checkpoint/restore patches. I've been wobbly about merging them because I'm wobbly about the overall prospects for success of the project. But after speaking with Pavel at the LSF conference, it sounds like they're further toward completion than I feared - apparently davem is at the "has stopped complaining" stage regarding the net changes. So I need to go back and re-review those patchs and their (lengthy) discussion." * emailed from Andrew Morton <akpm@linux-foundation.org>: (16 patches) memcg swap: use mem_cgroup_uncharge_swap fix backlight: add driver for DA9052/53 PMIC v1 C6X: use set_current_blocked() and block_sigmask() MAINTAINERS: add entry for sparse checker MAINTAINERS: fix REMOTEPROC F: typo alpha: use set_current_blocked() and block_sigmask() simple_open: automatically convert to simple_open() scripts/coccinelle/api/simple_open.cocci: semantic patch for simple_open() libfs: add simple_open() hugetlbfs: remove unregister_filesystem() when initializing module drivers/rtc/rtc-88pm860x.c: fix rtc irq enable callback fs/xattr.c:setxattr(): improve handling of allocation failures fs/xattr.c:listxattr(): fall back to vmalloc() if kmalloc() failed fs/xattr.c: suppress page allocation failure warnings from sys_listxattr() sysrq: use SEND_SIG_FORCED instead of force_sig() proc: fix mount -t proc -o AAA
| * scripts/coccinelle/api/simple_open.cocci: semantic patch for simple_open()Julia Lawall2012-04-051-0/+70
| | | | | | | | | | | | | | | | | | | | Find instances of an open-coded simple_open() and replace them with calls to simple_open(). Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> Reported-by: Stephen Boyd <sboyd@codeaurora.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
* | scripts/coccinelle/api/ptr_ret.cocci: semantic patch for ptr_errJulia Lawall2012-03-261-0/+70
| | | | | | | | | | 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>
* | coccinelle: semantic patch converting 0 test to null testJulia Lawall2012-02-251-0/+237
| | | | | | | | | | Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> Signed-off-by: Michal Marek <mmarek@suse.cz>
* | coccinelle: semantic patch for missing iounmapJulia Lawall2012-02-251-0/+67
| | | | | | | | | | Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> Signed-off-by: Michal Marek <mmarek@suse.cz>
* | coccinelle: semantic patch for missing clk_putJulia Lawall2012-02-251-0/+67
|/ | | | | 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-1511-76/+351
| | | | | | | | | | 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>
* coccinelle: semantic patches related to devm_ functions (part 2)Julia Lawall2012-01-141-0/+71
| | | | | | | | | devm_ functions allocate memory that is to remain allocated until the device is detached. This patch checks for freeing of such memory using standard memory freeing functions. Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> Signed-off-by: Michal Marek <mmarek@suse.cz>
* coccinelle: semantic patches related to devm_ functions (part 1)Julia Lawall2012-01-141-0/+105
| | | | | | | | | devm_ functions allocate memory that is to remain allocated until the device is detached. This patch checks for opportunities for using the function devm_request_and_ioremap. 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-032-28/+17
| | | | | | | | | | | | 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: Find doubled arguments to boolean or bit operators.Julia Lawall2010-10-282-0/+94
| | | | | | Signed-off-by: Julia Lawall <julia@diku.dk> Signed-off-by: Nicolas Palix <npalix.work@gmail.com> Signed-off-by: Michal Marek <mmarek@suse.cz>
* Coccinelle: Find nested lock+irqsave functions that use the same flags ↵Julia Lawall2010-10-281-0/+80
| | | | | | | | variables. Signed-off-by: Julia Lawall <julia@diku.dk> Signed-off-by: Nicolas Palix <npalix.work@gmail.com> Signed-off-by: Michal Marek <mmarek@suse.cz>
* Coccinelle: Use new comment format to explain kfree.cocciNicolas Palix2010-10-131-4/+5
| | | | | | | | | Use new comment format to separate proposed commit message and information about generated false positives Signed-off-by: Nicolas Palix <npalix.work@gmail.com> Signed-off-by: Julia Lawall <julia@diku.dk> Signed-off-by: Michal Marek <mmarek@suse.cz>
* 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>
* Coccinelle: Move alloc directory into api directoryNicolas Palix2010-08-312-1/+5
| | | | | | | | | alloc contains various semantic patches related to the allocation APIs 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: Move resource_size.cocci to the api directoryNicolas Palix2010-08-311-0/+0
| | | | | | 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: Move err_cast.cocci to the api directoryNicolas Palix2010-08-311-0/+0
| | | | | | 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 api/memdup_userNicolas Palix2010-08-311-0/+35
| | | | | | | | | Use kmemdup_user rather than duplicating its implementation This is a little bit restricted to reduce false positives 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 api/memdup.cocciNicolas Palix2010-08-311-0/+40
| | | | | | | | Use kmemdup rather than duplicating its implementation 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 api/kstrdup.cocciNicolas Palix2010-08-311-0/+39
| | | | | | | | Use kstrdup rather than duplicating its implementation 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 free/kfree.cocciNicolas Palix2010-08-311-0/+116
| | | | | | | | | | | Find a use after free. Values of variables may imply that some execution paths are not possible, resulting in false positives. Another source of false positives are macros such as SCTP_DBG_OBJCNT_DEC that do not actually evaluate their argument 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 iterators/list_entry_update.cocciNicolas Palix2010-08-311-0/+62
| | | | | | | | | | | list_for_each_entry uses its first argument to get from one element of the list to the next, so it is usually not a good idea to reassign it. The first rule finds such a reassignment and the second rule checks that there is a path from the reassignment back to the top of the loop. 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 iterators/itnull.cocciNicolas Palix2010-08-311-0/+58
| | | | | | | | | | | | Many iterators have the property that the first argument is always bound to a real list element, never NULL. False positives arise for some iterators that do not have this property, or in cases when the loop cursor is reassigned. The latter should only happen when the matched code is on the way to a loop exit (break, goto, or return). 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 iterators/fen.cocciNicolas Palix2010-08-311-0/+64
| | | | | | | | | for_each_node iterators only exit normally when the loop cursor is NULL, so there is no point to call of_node_put on the final value. 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 locks/mini_lock.cocciNicolas Palix2010-08-311-0/+95
| | | | | | | | | | | | | Find missing unlocks. This semantic match considers the specific case where the unlock is missing from an if branch, and there is a lock before the if and an unlock after the if. False positives are due to cases where the if branch represents a case where the function is supposed to exit with the lock held, or where there is some preceding function call that releases the lock. 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 locks/double_lock.cocciNicolas Palix2010-08-311-0/+92
| | | | | | | | | | Find double locks. False positives may occur when some paths cannot occur at execution, due to the values of variables, and when there is an intervening function call that releases the lock. 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 locks/call_kern.cocciNicolas Palix2010-08-311-0/+74
| | | | | | | | | | | Find functions that refer to GFP_KERNEL but are called with locks held. The proposed change of converting the GFP_KERNEL is not necessarily the correct one. It may be desired to unlock the lock, or to not call the function under the lock in the first place. 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: Move deref_null.cocci to a more appropriate directoryNicolas Palix2010-08-311-0/+0
| | | | | | | | | deref_null.cocci is moved to the 'null' directory which contains other null related rules. 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 null/kmerr.cocciNicolas Palix2010-08-311-0/+72
| | | | | | | | | | | | This semantic patch looks for kmalloc etc that are not followed by a NULL check. It only gives a report in the case where there is some error handling code later in the function, which may be helpful in determining what the error handling code for the call to kmalloc etc should be. 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 null/eno.cocciNicolas Palix2010-08-311-0/+20
| | | | | | | | The various basic memory allocation functions don't return ERR_PTR Signed-off-by: Nicolas Palix <npalix@diku.dk> Signed-off-by: Julia Lawall <julia@diku.dk> Signed-off-by: Michal Marek <mmarek@suse.cz>
* Add scripts/coccinelle/deref_null.cocciNicolas Palix2010-06-121-0/+293
| | | | | | | | | | | Add a Coccinelle file to identify the dereferences of NULL variables This semantic patch identifies when a variable is known to be NULL after a test, but it is still dereferenced later. Signed-off-by: Nicolas Palix <npalix@diku.dk> Signed-off-by: Julia Lawall <julia@diku.dk> Signed-off-by: Michal Marek <mmarek@suse.cz>
* Add scripts/coccinelle/err_cast.cocciNicolas Palix2010-06-121-0/+56
| | | | | | | | | | | | Add a Coccinelle file to use the ERR_CAST function Before the release 2.6.25, one had to use ERR_PTR(PTR_ERR(...)) to convert the pointer type of an error. Since then, the function ERR_CAST has been available for that purpose. Signed-off-by: Nicolas Palix <npalix@diku.dk> Signed-off-by: Julia Lawall <julia@diku.dk> Signed-off-by: Michal Marek <mmarek@suse.cz>
* Add scripts/coccinelle/resource_size.cocciNicolas Palix2010-06-121-0/+93
| | | | | | | | | This semantic patch replaces explicit computations of resource size by a call to resource_size. Signed-off-by: Nicolas Palix <npalix@diku.dk> Signed-off-by: Julia Lawall <julia@diku.dk> Signed-off-by: Michal Marek <mmarek@suse.cz>
* Add scripts/coccinelle/alloc/kzalloc-simple.cocciNicolas Palix2010-06-121-0/+82
| | | | | | | | | | | This semantic patch replaces a pair of calls to kmalloc and memset by a single call to kzalloc. It only looks for simple cases to avoid false positives. Signed-off-by: Nicolas Palix <npalix@diku.dk> Signed-off-by: Julia Lawall <julia@diku.dk> Signed-off-by: Michal Marek <mmarek@suse.cz>
* Add scripts/coccinelle/alloc/drop_kmalloc_cast.cocciNicolas Palix2010-06-121-0/+67
The purpose of this semantic patch is to remove useless casts, as mentioned in the Linux documentation. See Chapter 14 in Documentation/CodingStyle for more information. Signed-off-by: Nicolas Palix <npalix@diku.dk> Signed-off-by: Julia Lawall <julia@diku.dk> Signed-off-by: Michal Marek <mmarek@suse.cz>