summaryrefslogtreecommitdiff
path: root/scripts/coccinelle/misc
AgeCommit message (Collapse)Author
2024-02-29coccinelle: semantic patch to check for potential struct_size callsJacob Keller
include/linux/overflow.h includes helper macros intended for calculating sizes of allocations. These macros prevent accidental overflow by saturating at SIZE_MAX. In general when calculating such sizes use of the macros is preferred. Add a semantic patch which can detect code patterns which can be replaced by struct_size. Note that I set the confidence to medium because this patch doesn't make an attempt to ensure that the relevant array is actually a flexible array. The struct_size macro does specifically require a flexible array. In many cases the detected code could be refactored to a flexible array, but this is not always possible (such as if there are multiple over-allocations). Signed-off-by: Jacob Keller <jacob.e.keller@intel.com> Link: https://lore.kernel.org/r/20230227202428.3657443-1-jacob.e.keller@intel.com Signed-off-by: Kees Cook <keescook@chromium.org>
2022-08-07update Coccinelle URLJulia Lawall
Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>
2022-07-16coccinelle: Remove script that checks replacing 0/1 with false/true in ↵Steven Rostedt (Google)
functions returning bool There is nothing wrong with current code that returns 0 or 1 for a function returning bool. It is perfectly acceptable by the C standard. To avoid churn of unwanted patches that are constantly sent to maintainers who do not care about this change, remove the script that flags it as an issue. This issue is not worth the burden on maintainers to accept useless patches. Link: https://lore.kernel.org/all/20220705073822.7276-1-jiapeng.chong@linux.alibaba.com/ Link: https://lore.kernel.org/all/20220429075201.68581-1-jiapeng.chong@linux.alibaba.com/ Link: https://lore.kernel.org/all/1649236467-29390-1-git-send-email-baihaowen@meizu.com/ Link: https://lore.kernel.org/all/20220317014740.3138-1-jiapeng.chong@linux.alibaba.com/ Link: https://lore.kernel.org/all/190b5c2f2f2fb9cc775fce8daed72bf893be48a4.1642065293.git.davidcomponentone@gmail.com/ Link: https://lore.kernel.org/all/20211214113845.439392-1-deng.changcheng@zte.com.cn/ Link: https://lore.kernel.org/all/20210824065735.60660-1-deng.changcheng@zte.com.cn/ Link: https://lore.kernel.org/all/20210824064305.60081-1-deng.changcheng@zte.com.cn/ Link: https://lore.kernel.org/all/20210824062359.59474-1-deng.changcheng@zte.com.cn/ Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk> Cc: Julia Lawall <Julia.Lawall@lip6.fr> Cc: Michal Marek <mmarek@suse.cz> Cc: Peter Zijlstra <peterz@infradead.org> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org> Signed-off-by: Julia Lawall <julia.lawall@inria.fr> Acked-by: Rasmus Villemoes <linux@rasmusvillemoes.dk> Acked-by: Paul Gortmaker <paul.gortmaker@windriver.com>
2022-07-03coccinelle: Extend address test from ifaddr semantic patch to test expressionsJérémy LEFAURE
The test of an expression's address does not necessarily represent the whole condition, it may only be a part of it. Also, an expression's address is likely to be non-zero in every test expression, not only in if statements. This change aims at detecting an address test in more complex conditions and not only in if statements. Signed-off-by: Jérémy Lefaure <jeremy.lefaure@netatmo.com> Signed-off-by: Julia Lawall <julia.lawall@inria.fr>
2022-01-15scripts/coccinelle: drop bugon.cocciJulia Lawall
The BUG_ON script was never safe, in that it was not able to check whether the condition was side-effecting. At this point, BUG_ON should be well known, so it has probably outlived its usefuless. Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr> Suggested-by: Matthew Wilcox <willy@infradead.org>
2021-09-11coccinelle: semantic patch to check for inappropriate do_div() callsWen Yang
do_div() does a 64-by-32 division. When the divisor is unsigned long, u64, or s64, do_div() truncates it to 32 bits, this means it can test non-zero and be truncated to zero for division. This semantic patch is inspired by Mateusz Guzik's patch: commit b0ab99e7736a ("sched: Fix possible divide by zero in avg_atom() calculation") Signed-off-by: Wen Yang <wenyang@linux.alibaba.com> Signed-off-by: Julia Lawall <julia.lawall@inria.fr> Cc: Gilles Muller <Gilles.Muller@lip6.fr> Cc: Nicolas Palix <nicolas.palix@imag.fr> Cc: Michal Marek <michal.lkml@markovi.net> Cc: Matthias Maennich <maennich@google.com> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Masahiro Yamada <yamada.masahiro@socionext.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: cocci@systeme.lip6.fr Cc: linux-kernel@vger.kernel.org
2021-05-01coccinelle: misc: minmax: suppress patch generation for err returnsDenis Efremov
There is a standard idiom for "if 'ret' holds an error, return it": return ret < 0 ? ret : 0; Developers prefer to keep the things as they are because stylistic change to "return min(ret, 0);" breaks readability. Let's suppress automatic generation for this type of patches. Signed-off-by: Denis Efremov <efremov@linux.com>
2021-05-01coccinelle: irqf_oneshot: reduce the severity due to false positivesKrzysztof Kozlowski
The IRQF_ONESHOT should be present for threaded IRQ using default primary handler. However intetrupt of many child devices, e.g. children of MFD, is nested thus the IRQF_ONESHOT is not needed. The coccinelle message about error misleads submitters and reviewers about the severity of the issue, so make it a warning and mention possible false positive. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com> Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>
2021-05-01coccinelle: misc: add swap scriptDenis Efremov
Check for opencoded swap() implementation. Signed-off-by: Denis Efremov <efremov@linux.com> Signed-off-by: Julia Lawall <julia.lawall@inria.fr>
2021-05-01coccinelle: misc: update uninitialized_var.cocci documentationDenis Efremov
Remove the documentation link from the warning message because commit 3942ea7a10c9 ("deprecated.rst: Remove now removed uninitialized_var") removed the section from documentation. Update the rule documentation accordingly. Signed-off-by: Denis Efremov <efremov@linux.com> Signed-off-by: Julia Lawall <julia.lawall@inria.fr>
2021-05-01coccinelle: misc: restrict patch mode in flexible_array.cocciDenis Efremov
Skip patches generation for structs with a single field. Changing a zero-length array to a flexible array member in a struct with no named members breaks the compilation. However, reporting such cases is still valuable, e.g. commit 637464c59e0b ("ACPI: NFIT: Fix flexible_array.cocci warnings"). Signed-off-by: Denis Efremov <efremov@linux.com> Signed-off-by: Julia Lawall <julia.lawall@inria.fr>
2021-05-01coccinelle: misc: add minmax scriptDenis Efremov
Check for opencoded min(), max() implementations. Signed-off-by: Denis Efremov <efremov@linux.com> Signed-off-by: Julia Lawall <julia.lawall@inria.fr>
2020-11-09remove boolinit.cocciPeter Zijlstra
0/1 for booleans is perfectly valid C. Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>
2020-10-03coccinelle: misc: add flexible_array.cocci scriptDenis Efremov
One-element and zero-length arrays are deprecated [1]. Kernel code should always use "flexible array members" instead, except for existing uapi definitions. The script warns about one-element and zero-length arrays in structs. [1] commit 68e4cd17e218 ("docs: deprecated.rst: Add zero-length and one-element arrays") Cc: Kees Cook <keescook@chromium.org> Cc: Gustavo A. R. Silva <gustavoars@kernel.org> Signed-off-by: Denis Efremov <efremov@linux.com> Signed-off-by: Julia Lawall <julia.lawall@inria.fr>
2020-09-21coccinelle: misc: add excluded_middle.cocci scriptDenis Efremov
Check for !A || A && B condition. It's equivalent to !A || B. Signed-off-by: Denis Efremov <efremov@linux.com> Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>
2020-09-05coccinelle: misc: add uninitialized_var.cocci scriptDenis Efremov
uninitialized_var() macro was removed from the sources [1] and other warning-silencing tricks were deprecated [2]. The purpose of this cocci script is to prevent new occurrences of uninitialized_var() open-coded variants. [1] commit 63a0895d960a ("compiler: Remove uninitialized_var() macro") [2] commit 4b19bec97c88 ("docs: deprecated.rst: Add uninitialized_var()") Cc: Kees Cook <keescook@chromium.org> Cc: Gustavo A. R. Silva <gustavoars@kernel.org> Signed-off-by: Denis Efremov <efremov@linux.com> Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>
2020-08-06Merge branch 'for-5.9' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/jlawall/linux Pull coccinelle updates from Julia Lawall: "New semantic patches and semantic patch improvements from Denis Efremov" * 'for-5.9' of git://git.kernel.org/pub/scm/linux/kernel/git/jlawall/linux: coccinelle: api: filter out memdup_user definitions coccinelle: api: extend memdup_user rule with vmemdup_user() coccinelle: api: extend memdup_user transformation with GFP_USER coccinelle: api: add kzfree script coccinelle: misc: add array_size_dup script to detect missed overflow checks coccinelle: api/kstrdup: fix coccinelle position coccinelle: api: add device_attr_show script
2020-08-04coccinelle: misc: add array_size_dup script to detect missed overflow checksDenis Efremov
Detect an opencoded expression that is used before or after array_size()/array3_size()/struct_size() to compute the same size. Signed-off-by: Denis Efremov <efremov@linux.com> Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>
2020-07-10scripts: add dummy report mode to add_namespace.cocciMatthias Maennich
When running `make coccicheck` in report mode using the add_namespace.cocci file, it will fail for files that contain MODULE_LICENSE. Those match the replacement precondition, but spatch errors out as virtual.ns is not set. In order to fix that, add the virtual rule nsdeps and only do search and replace if that rule has been explicitly requested. In order to make spatch happy in report mode, we also need a dummy rule, as otherwise it errors out with "No rules apply". Using a script:python rule appears unrelated and odd, but this is the shortest I could come up with. Adjust scripts/nsdeps accordingly to set the nsdeps rule when run trough `make nsdeps`. Suggested-by: Julia Lawall <julia.lawall@inria.fr> Fixes: c7c4e29fb5a4 ("scripts: add_namespace: Fix coccicheck failed") Cc: YueHaibing <yuehaibing@huawei.com> Cc: jeyu@kernel.org Cc: cocci@systeme.lip6.fr Cc: stable@vger.kernel.org Signed-off-by: Matthias Maennich <maennich@google.com> Reported-by: Shuah Khan <skhan@linuxfoundation.org> Acked-by: Julia Lawall <julia.lawall@inria.fr> Link: https://lore.kernel.org/r/20200604164145.173925-1-maennich@google.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-05-07net: remove newlines in NL_SET_ERR_MSG_MODJacob Keller
The NL_SET_ERR_MSG_MOD macro is used to report a string describing an error message to userspace via the netlink extended ACK structure. It should not have a trailing newline. Add a cocci script which catches cases where the newline marker is present. Using this script, fix the handful of cases which accidentally included a trailing new line. I couldn't figure out a way to get a patch mode working, so this script only implements context, report, and org. Signed-off-by: Jacob Keller <jacob.e.keller@intel.com> Cc: Jakub Kicinski <kuba@kernel.org> Cc: Andy Whitcroft <apw@canonical.com> Cc: Joe Perches <joe@perches.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2019-10-07scripts: add_namespace: Fix coccicheck failedYueHaibing
Now all scripts in scripts/coccinelle to be automatically called by coccicheck. However new adding add_namespace.cocci does not support report mode, which make coccicheck failed. This add "virtual report" to make the coccicheck go ahead smoothly. Fixes: eb8305aecb95 ("scripts: Coccinelle script for namespace dependencies.") Acked-by: Julia Lawall <julia.lawall@lip6.fr> Acked-by: Matthias Maennich <maennich@google.com> Signed-off-by: YueHaibing <yuehaibing@huawei.com> Signed-off-by: Jessica Yu <jeyu@kernel.org>
2019-09-10scripts: Coccinelle script for namespace dependencies.Matthias Maennich
A script that uses the '<module>.ns_deps' files generated by modpost to automatically add the required symbol namespace dependencies to each module. Usage: 1) Move some symbols to a namespace with EXPORT_SYMBOL_NS() or define DEFAULT_SYMBOL_NAMESPACE 2) Run 'make' (or 'make modules') and get warnings about modules not importing that namespace. 3) Run 'make nsdeps' to automatically add required import statements to said modules. This makes it easer for subsystem maintainers to introduce and maintain symbol namespaces into their codebase. Co-developed-by: Martijn Coenen <maco@android.com> Signed-off-by: Martijn Coenen <maco@android.com> Acked-by: Julia Lawall <julia.lawall@lip6.fr> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Matthias Maennich <maennich@google.com> Signed-off-by: Jessica Yu <jeyu@kernel.org>
2019-06-19treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 505Thomas Gleixner
Based on 1 normalized pattern(s): gplv2 extracted by the scancode license scanner the SPDX license identifier GPL-2.0-only has been chosen to replace the boilerplate/reference in 58 file(s). Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Enrico Weigelt <info@metux.net> Reviewed-by: Allison Randal <allison@lohutok.net> Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org> Cc: linux-spdx@vger.kernel.org Link: https://lkml.kernel.org/r/20190604081207.556988620@linutronix.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-03-28scripts: coccinelle: Fix description of badty.cocciMichael Stefaniuc
Summary was copy and pasted from array_size.cocci. Signed-off-by: Michael Stefaniuc <mstefani@mykolab.com> Acked-by: Julia Lawall <julia.lawall@lip6.fr> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2019-01-06scripts: coccinelle: boolinit: drop warnings on named constantsJulia Lawall
Coccinelle doesn't always have access to the values of named (#define) constants, and they may likely often be bound to true and false values anyway, resulting in false positives. So stop warning about them. Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-12-17scripts: coccinelle: Correct warning messageJulia Lawall
"Assignment" requires the assigned value before the place that value is stored into. Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-12-17scripts: coccinelle: only suggest true/false in files that already use themJulia Lawall
Some code may overall use 0 and 1, so don't introduce occasional uses of true and false in these cases. Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-01-16Coccinelle: array_size: report even if include is missingJérémy Lefaure
Rule r does not depend on rule i (which is the include of linux/kernel.h) so the output should not depend on i in org and report mode. Signed-off-by: Jérémy Lefaure <jeremy.lefaure@lse.epita.fr> Acked-by: Julia Lawall <julia.lawall@lip6.fr> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2017-11-17Merge tag 'kbuild-misc-v4.15' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild Pull Kbuild misc updates from Masahiro Yamada: - Clean up and fix RPM package build - Fix a warning in DEB package build - Improve coccicheck script - Improve some semantic patches * tag 'kbuild-misc-v4.15' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild: docs: dev-tools: coccinelle: delete out of date wiki reference coccinelle: orplus: reorganize to improve performance coccinelle: use exists to improve efficiency builddeb: Pass the kernel:debarch substvar to dpkg-genchanges Coccinelle: use false positive annotation coccinelle: fix verbose message about .cocci file being run coccinelle: grep Options and Requires fields more precisely Coccinelle: make DEBUG_FILE option more useful coccinelle: api: detect identical chip data arrays coccinelle: Improve setup_timer.cocci matching Coccinelle: setup_timer: improve messages from setup_timer kbuild: rpm-pkg: do not force -jN in submake kbuild: rpm-pkg: keep spec file until make mrproper kbuild: rpm-pkg: fix jobserver unavailable warning kbuild: rpm-pkg: replace $RPM_BUILD_ROOT with %{buildroot} kbuild: rpm-pkg: fix build error when CONFIG_MODULES is disabled kbuild: rpm-pkg: refactor mkspec with here doc kbuild: rpm-pkg: clean up mkspec kbuild: rpm-pkg: install vmlinux.bz2 unconditionally kbuild: rpm-pkg: remove ppc64 specific image handling
2017-11-16coccinelle: orplus: reorganize to improve performanceJulia Lawall
Adding two #define constants is less common than performing & and | operations on them, so put the addition first to reduce the set of cases that have to be considered in detail. At the same time, add & and | patterns for both arguments of +, to account for commutativity and obtain more results. Running time is divided by 3 when applying this to the whole kernel on my laptop with an Intel i5-6200U CPU. Signed-off-by: Julia Lawall <julia.lawall@lip6.fr> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2017-11-14Coccinelle: use false positive annotationJulia Lawall
/// is to describe the semantic patch, while //# indicates reasons for false positives. Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2017-11-02License cleanup: add SPDX GPL-2.0 license identifier to files with no licenseGreg Kroah-Hartman
Many source files in the tree are missing licensing information, which makes it harder for compliance tools to determine the correct license. By default all files without license information are under the default license of the kernel, which is GPL version 2. Update the files which contain no license information with the 'GPL-2.0' SPDX license identifier. The SPDX identifier is a legally binding shorthand, which can be used instead of the full boiler plate text. This patch is based on work done by Thomas Gleixner and Kate Stewart and Philippe Ombredanne. How this work was done: Patches were generated and checked against linux-4.14-rc6 for a subset of the use cases: - file had no licensing information it it. - file was a */uapi/* one with no licensing information in it, - file was a */uapi/* one with existing licensing information, Further patches will be generated in subsequent months to fix up cases where non-standard license headers were used, and references to license had to be inferred by heuristics based on keywords. The analysis to determine which SPDX License Identifier to be applied to a file was done in a spreadsheet of side by side results from of the output of two independent scanners (ScanCode & Windriver) producing SPDX tag:value files created by Philippe Ombredanne. Philippe prepared the base worksheet, and did an initial spot review of a few 1000 files. The 4.13 kernel was the starting point of the analysis with 60,537 files assessed. Kate Stewart did a file by file comparison of the scanner results in the spreadsheet to determine which SPDX license identifier(s) to be applied to the file. She confirmed any determination that was not immediately clear with lawyers working with the Linux Foundation. Criteria used to select files for SPDX license identifier tagging was: - Files considered eligible had to be source code files. - Make and config files were included as candidates if they contained >5 lines of source - File already had some variant of a license header in it (even if <5 lines). All documentation files were explicitly excluded. The following heuristics were used to determine which SPDX license identifiers to apply. - when both scanners couldn't find any license traces, file was considered to have no license information in it, and the top level COPYING file license applied. For non */uapi/* files that summary was: SPDX license identifier # files ---------------------------------------------------|------- GPL-2.0 11139 and resulted in the first patch in this series. If that file was a */uapi/* path one, it was "GPL-2.0 WITH Linux-syscall-note" otherwise it was "GPL-2.0". Results of that was: SPDX license identifier # files ---------------------------------------------------|------- GPL-2.0 WITH Linux-syscall-note 930 and resulted in the second patch in this series. - if a file had some form of licensing information in it, and was one of the */uapi/* ones, it was denoted with the Linux-syscall-note if any GPL family license was found in the file or had no licensing in it (per prior point). Results summary: SPDX license identifier # files ---------------------------------------------------|------ GPL-2.0 WITH Linux-syscall-note 270 GPL-2.0+ WITH Linux-syscall-note 169 ((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) 21 ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) 17 LGPL-2.1+ WITH Linux-syscall-note 15 GPL-1.0+ WITH Linux-syscall-note 14 ((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) 5 LGPL-2.0+ WITH Linux-syscall-note 4 LGPL-2.1 WITH Linux-syscall-note 3 ((GPL-2.0 WITH Linux-syscall-note) OR MIT) 3 ((GPL-2.0 WITH Linux-syscall-note) AND MIT) 1 and that resulted in the third patch in this series. - when the two scanners agreed on the detected license(s), that became the concluded license(s). - when there was disagreement between the two scanners (one detected a license but the other didn't, or they both detected different licenses) a manual inspection of the file occurred. - In most cases a manual inspection of the information in the file resulted in a clear resolution of the license that should apply (and which scanner probably needed to revisit its heuristics). - When it was not immediately clear, the license identifier was confirmed with lawyers working with the Linux Foundation. - If there was any question as to the appropriate license identifier, the file was flagged for further research and to be revisited later in time. In total, over 70 hours of logged manual review was done on the spreadsheet to determine the SPDX license identifiers to apply to the source files by Kate, Philippe, Thomas and, in some cases, confirmation by lawyers working with the Linux Foundation. Kate also obtained a third independent scan of the 4.13 code base from FOSSology, and compared selected files where the other two scanners disagreed against that SPDX file, to see if there was new insights. The Windriver scanner is based on an older version of FOSSology in part, so they are related. Thomas did random spot checks in about 500 files from the spreadsheets for the uapi headers and agreed with SPDX license identifier in the files he inspected. For the non-uapi files Thomas did random spot checks in about 15000 files. In initial set of patches against 4.14-rc6, 3 files were found to have copy/paste license identifier errors, and have been fixed to reflect the correct identifier. Additionally Philippe spent 10 hours this week doing a detailed manual inspection and review of the 12,461 patched files from the initial patch version early this week with: - a full scancode scan run, collecting the matched texts, detected license ids and scores - reviewing anything where there was a license detected (about 500+ files) to ensure that the applied SPDX license was correct - reviewing anything where there was no detection but the patch license was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied SPDX license was correct This produced a worksheet with 20 files needing minor correction. This worksheet was then exported into 3 different .csv files for the different types of files to be modified. These .csv files were then reviewed by Greg. Thomas wrote a script to parse the csv files and add the proper SPDX tag to the file, in the format that the file expected. This script was further refined by Greg based on the output to detect more types of files automatically and to distinguish between header and source .c files (which need different comment types.) Finally Greg ran the script using the .csv files to generate the patches. Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org> Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com> Reviewed-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-12-11Coccinelle: misc: Add support for devm variant in all modesVaishali Thakkar
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>
2016-12-11Coccinelle: misc: Improve the result given by context modeVaishali Thakkar
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>
2016-12-11Coccinelle: misc: Improve the matching of rulesVaishali Thakkar
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>
2016-12-11Coccinelle: Add misc/boolconv.cocciAndrew F. Davis
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>
2016-10-11Coccinelle: flag conditions with no effectNicholas Mc Guire
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>
2016-06-20Coccinelle: noderef: Add new rules and correct the old ruleVaishali Thakkar
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>
2016-04-20scripts: coccinelle: remove check to move constants to rightWolfram Sang
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>
2016-02-18coccinelle: bugon: reduce rule applicabilityJulia Lawall
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>
2016-02-18Coccinelle: array_size: reduce rule applicabilityJulia Lawall
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>
2016-02-18Coccinelle: reduce rule applicabilityJulia Lawall
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>
2015-10-26coccinelle: Improve checking for missing NULL terminatorsDaniel Granat
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>
2015-10-26coccinelle: misc: remove "complex return code" warningsJohan Hovold
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>
2015-10-26coccinelle: misc: move constants to the rightJulia Lawall
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>
2015-06-03coccinelle: simple_return: Add a blank lineFabio Estevam
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>
2015-05-25coccinelle: irqf_oneshot.cocci: Improve the generated commit logFabio Estevam
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>
2015-05-21scripts/coccinelle/misc/irqf_oneshot.cocci: Fix grammarFabio Estevam
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>
2015-05-21scripts/coccinelle/misc/semicolon.cocci: Use imperative moodFabio Estevam
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>
2015-05-20coccinelle: ifaddr: Fix the sentenceFabio Estevam
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>