aboutsummaryrefslogtreecommitdiff
path: root/tools/scripts/checkpatch.pl
AgeCommit message (Collapse)AuthorFilesLines
2023-09-29Copy tool files from upstream.Tim Newsome1-11/+10
Copy .travis.yml and tools/scripts/checkpatch.pl from upstream ee31f1578a333a75737bc5b183cd4ae98cdaf798. Addresses #913. Change-Id: I69ad6b734ebf2cf7110010aa0481b6676124610e Signed-off-by: Tim Newsome <tim@sifive.com>
2023-03-16Merge commit '1293ddd65713d6551775b67169387622ada477c1' into from_upstreamTim Newsome1-743/+5104
This includes https://sourceforge.net/p/openocd/mailman/message/37710818/, which should fix #814. Conflicts: .travis.yml contrib/loaders/flash/stm32/stm32f1x.S contrib/loaders/flash/stm32/stm32f2x.S doc/openocd.texi src/rtos/FreeRTOS.c src/server/gdb_server.c src/target/riscv/riscv-013.c src/target/riscv/riscv.c src/target/riscv/riscv.h src/target/riscv/riscv_semihosting.c tcl/target/esp_common.cfg tcl/target/gd32vf103.cfg tools/scripts/checkpatch.pl Change-Id: I1986c13298ca0dafbe3aecaf1b0b35626525e4eb
2022-09-23checkpatch: fix for flag --no-treeAntonio Borneo1-4/+6
When checkpatch is run with command line flag --no-tree, it cannot find local 'companion' files and has to skip loading them. This has caused issues with change https://review.openocd.org/7211 on jenkins. Skip loading 'tools/scripts/camelcase.txt' with flag --no-tree. While there, rewrite the associated error message. Change-Id: I6ede7b16f9ccd77b9118fd9be7ada07a1ac96952 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7212 Tested-by: jenkins
2022-09-18checkpatch: fix path of documentationAntonio Borneo1-0/+5
In OpenOCD documentation is in folder "doc". Fix search path of 'checkpatch.rst'. This file is used to provide verbose explanation of failing checks while using command line flag '-v'. Change-Id: Id864369d371cbd5a24e76bf90c54ff03159051c3 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7022 Tested-by: jenkins
2022-09-18checkpatch: extend check for camel[0-9_]*CASEAntonio Borneo1-0/+24
Linux has some automatically generated macros that can trigger camelCASE check. This forces checkpatch to only detect the pattern [A-Z][a-z]|[a-z][A-Z] for adjacent case transition. In OpenOCD we do not have such case, so extend the check to [A-Z][0-9_]*[a-z]|[a-z][0-9_]*[A-Z] and remove the detection of Linux special cases. Change-Id: I82cb6dc668edbb093f68991337da1f4b933f1fac Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7152 Tested-by: jenkins
2022-09-18checkpatch: enable CAMELCASE testAntonio Borneo1-0/+31
OpenOCD has to deal with CamelCase API, mainly from inttypes.h, jimtcl, libusb and Windows. Modify checkpatch script to load from a file the list of allowed CamelCase symbols. Populate the file 'camelcase.txt' with the symbols that OpenOCD has to get from external library, plus some of the symbols that should be fixed later. Enable CAMELCASE test in configuration script. Add generated files to .gitignore. Remove the check for 'known' CamelCase symbols from include folder as this will not work on OpenOCD Jenkins, as it run checkpatch on already patched code. Change-Id: I0415af673ed9f985394405ff8f1eeec81135410a Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6170 Tested-by: jenkins
2022-09-18checkpatch: add commit-message field to ignore some checkAntonio Borneo1-0/+7
The script 'checkpatch.pl' is part of the automatic tests used by Linux Maintainers and developers to test new patches. The Linux development process is e-mail base. An error reported by checkpatch is not a blocking point; the developer can explain in the e-mail why he is submitting a patch that fails at checkpatch or that is in violation of the coding style. It's up to the maintainer to decide to accept or reject the explanation and then the patch. The OpenOCD development process relies on Gerrit and Jenkins as front-end tools. Jenkins tests every new patch with checkpatch and then builds the new code. If checkpatch fails, Jenkins adds a failure label to the patch; this often causes the patch to get ignored by maintainers that considers it as 'not ready'. Checkpatch can be instrumented to ignore some test, but this has to be specified in the command line or in the configuration file. Let checkpatch extract from the patch's commit message the new field 'Checkpatch-ignore:' that lists the additional tests that has to be ignored for that patch only. The developer that detects as error or a limitation in checkpatch can add the field and the problematic test in the commit message and re-push the patch. The maintainer should check the list of tests and decide how to proceed. Change-Id: Iafc1b2893a07c7b3fc7e3ad15bd694aba9bd8519 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6169 Tested-by: jenkins
2022-09-18checkpatch: increase the max indentation levelAntonio Borneo1-1/+3
OpenOCD uses longer lines (120 char vs 100) and smaller tab size (4 char vs 8) wrt Linux kernel coding style. Clearly deep level of indentation is bad for code readability, but let's be more permissive on the indentation level. Change-Id: I16cf0b761145ec6072509dc26bb09c693e89e608 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6167 Tested-by: jenkins
2022-09-18checkpatch: check for SPDX tags of licenses in useAntonio Borneo1-2/+8
Fix the patch of the external helper spdxcheck.py accordingly to OpenOCD folder structure. List only the current LICENSES subfolders in spdxcheck.py . Enable the check for SPDX headers. Extend the check for TCL and Makefile.am files. Change-Id: I0a40da0127746217ee0ac416058d5ceb922428ff Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/5608 Tested-by: jenkins
2022-09-18checkpatch: fix check for the FSF addressPaul Fertser1-1/+1
Replace s/Linux/OpenOCD/ in the message about FSF address. This is part of the old commit a9a5c17cf5e1 ("checkpatch: fix check for the FSF address"). Change-Id: I79b79769ef723f86690862277612ea8ab7855c07 Signed-off-by: Paul Fertser <fercerpav@gmail.com> Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/5128 Tested-by: jenkins
2022-09-18checkpatch: don't spell-check the spelling fileAntonio Borneo1-0/+3
Prevent checkpatch to complain for commits that add new entries in the dictionary of misspelled words. Remove the ignore flag TYPO_SPELLING from .checkpatch.conf, now spelling is functional. Change-Id: I911dedafc243e34f753d2be687977066719ff2eb Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/5123 Tested-by: jenkins
2022-09-18checkpatch: check for OpenOCD tree, not for kernel treeAntony Pavlov1-4/+14
checkpatch.pl looks for Linux kernel specific paths and files to check source tree. As openocd misses kernel files it ends with this error message: Must be run from the top-level dir. of a kernel tree This patch also renames 'kernel' -> 'openocd' in source tree-related messages. This is the old commit c5d89883165e ("checkpatch.pl: check for openocd tree, not for kernel tree") re-applied. Also remove the flag "--no-tree" from .checkpatch.conf, not required anymore. Change-Id: I336a66558c75494b7ae339ea63559c31f23aad84 Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/5122 Tested-by: jenkins
2022-09-18checkpatch: correct false positives reporting instructionsPaul Fertser1-0/+10
This is the old commit 75b4cbe35646 ("checkpatch: correct false positives reporting instructions") re-applied. Change-Id: I348ae549e9d2587093b0fb6652aadf34724f0aab Signed-off-by: Paul Fertser <fercerpav@gmail.com> Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/5121 Tested-by: jenkins
2022-09-18checkpatch: treat jenkins as valid emailPaul Fertser1-0/+4
This is needed to avoid checkpatch barking on already committed patches. This is the old commit cadd51971535 ("checkpatch: treat jenkins as valid email") re-applied. Remove the flag BAD_SIGN_OFF, not anymore needed. Change-Id: I6744f80de982f7934f3a5197ac2df1c29962cbd0 Signed-off-by: Paul Fertser <fercerpav@gmail.com> Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/5120 Tested-by: jenkins
2022-09-18checkpatch: add logging functionsPaul Fertser1-0/+7
It's commonly considered that user-visible strings should not be split to different lines in the sources to ease grepping for them. Hence, checkpatch traditionally makes an exception for logging functions, lines having them can be of arbitrary length. OpenOCD uses different (from Linux, the kernel) names, so they need to be added to avoid false positives. This is the old commit bb3cd6ec438d ("checkpatch: add logging functions") re-applied and updated. Change-Id: Ib18e4532cf7e1f79821b74c9bb6134a8a4e8be1b Signed-off-by: Paul Fertser <fercerpav@gmail.com> Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/5119 Tested-by: jenkins
2022-09-18checkpatch: add variable $OpenOCDAntonio Borneo1-0/+13
The script checkpatch.pl require some adaptation for OpenOCD that cannot be achieved through the config file .checkpatch.conf; the script's code has to be modified. To merge new version of the script from Linux kernel it becomes relevant highlighting the changes, while minimizing the diff wrt the initial script. Add the perl variable '$OpenOCD' and suggest how to highlight changes. Change-Id: Ia8d26426850008f0465858a1d84cc774bc1146ed Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7021 Tested-by: jenkins
2022-09-18checkpatch: import new script version from kernel v6.0-rc3Antonio Borneo1-747/+4984
Replace existing checkpatch script with the one available in the latest Linux kernel. Add also from the same kernel version the spelling database and the script spdxcheck.py, even if the script cannot be found by checkpatch in the current path. Add an empty "const_structs.checkpatch" file and an initial "spdxexclude" file. The script as is doesn't work properly in OpenOCD project. Further patches in this series are required. Gerrit will use the checkpatch in this commit to test/build the commit itself. A minimal configuration file is then required to avoid a failure in the test/build process. This commit includes the OpenOCD commits: commit 164450a01576 ("Change checkpatch.pl tab expanding to 4 characters.") commit 667d510dabd5 ("checkpatch: fix false indent trigger") already merged in upstream checkpatch in kernel v6.0-rc3. Change-Id: Ic9cdecff2df0a1e23cdb01d10f14c5988480b8d6 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/5116 Tested-by: jenkins
2021-04-15Remove FSF address warning from checkpatch.Tim Newsome1-9/+10
This often bites me when I'm merging changes from mainline, and never catches a real problem in this fork. Change-Id: I07f4c275db2c0bccb413eeba9ec1759b216f31a9 Signed-off-by: Tim Newsome <tim@sifive.com>
2020-10-15Don't complain when a change fixes a complaint.Tim Newsome1-1/+1
The script was telling me: ``` WARNING: use relative pathname instead of absolute in changelog text \#20: FILE: contrib/cross-build.sh:25: -# /path/to/openocd/contrib/cross-build.sh <host-triplet> ``` In the change where I changed that line to not refer to an absolute path. Change-Id: I1a21af5c36d9aeb01d3e819bfe2b06eb00466467 Signed-off-by: Tim Newsome <tim@sifive.com>
2018-01-13checkpatch: fix more "unescaped left brace" warningsPaul Fertser1-14/+14
Unescaped left brace in string literals is deprecated since perl v5.21.1. Not a Perl programmer here so please review! Change-Id: I724d8fa616d603e032e07afb9b8933e0ec95045b Signed-off-by: Paul Fertser <fercerpav@gmail.com> Reviewed-on: http://openocd.zylin.com/3801 Tested-by: jenkins
2017-04-23tools/scripts/checkpatch.pl: fix unescaped braceChengyu Zheng1-1/+1
Change-Id: If1d0fbe95223351ea098504cf24f076784b26a9c Signed-off-by: Chengyu Zheng <chengyu.zheng@polimi.it> Reviewed-on: http://openocd.zylin.com/4102 Tested-by: jenkins Reviewed-by: Freddie Chopin <freddie.chopin@gmail.com>
2016-05-05checkpatch.pl: fix unescaped left brace warningsPaul Fertser1-3/+3
Basically, same as upstream 4e5d56bdf892e18832a6540b63ebf709966bce2a. Unescaped left brace in string literals is deprecated since perl v5.21.1. Change-Id: I0e5f23bef821d2dca6ff4909ddbb06f4992718d4 Signed-off-by: Paul Fertser <fercerpav@gmail.com> Reviewed-on: http://openocd.zylin.com/3228 Tested-by: jenkins Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
2015-01-08checkpatch: fix check for the FSF addressPaul Fertser1-2/+4
Commit 4525c0a4c4d0aaa199c37a6d2245617e8445f213 cherry-picked check for the FSF address presence from upstream. However, it has a typo resulting in this obscure error when triggered: Use of uninitialized value in concatenation (.) or string at /home/jenkins/.jenkins/jobs/openocd-gerrit/workspace/tools/scripts/checkpatch.pl line 1258. ERROR: This patch fixes it. Change-Id: Ia417ef4782d21c8b3f1d39de88c4ab850a5a6630 Signed-off-by: Paul Fertser <fercerpav@gmail.com> Reviewed-on: http://openocd.zylin.com/2414 Tested-by: jenkins Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2014-11-24checkpatch.pl: check for the FSF mailing addressAntony Pavlov1-0/+8
This check code is imported from Linux v3.17 checkpatch.pl. Change-Id: If39d834ee9b6131bccc92de38fd7c108650bd2f1 Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Reviewed-on: http://openocd.zylin.com/2341 Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk> Tested-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-11-24checkpatch.pl: check for openocd tree, not for kernel treeAntony Pavlov1-10/+9
checkpatch.pl looks for linux kernel specific paths and files to check source tree. As openocd misses kernel files it ends with this error message: Must be run from the top-level dir. of a kernel tree This patch also renames 'kernel' -> 'openocd' in source tree-related messages. Due to checkpatch checking modifications on itself, lift the restriction on having no spaces at the start of a line for Perl scripts. This can be readded back later. Change-Id: I89b7ca976bef5e13785bd3a43e597c9feb4c2df4 Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Reviewed-on: http://openocd.zylin.com/2339 Tested-by: jenkins Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2013-10-29checkpatch: correct false positives reporting instructionsPaul Fertser1-1/+2
Change-Id: Ib45d3db4436a5df5215f2c2d8b8f9a6d48d5f348 Signed-off-by: Paul Fertser <fercerpav@gmail.com> Reviewed-on: http://openocd.zylin.com/1786 Tested-by: jenkins Reviewed-by: Mathias Küster <kesmtp@freenet.de> Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2013-10-29checkpatch: treat jenkins as valid emailPaul Fertser1-0/+2
This is needed to avoid checkpatch barking on already committed patches. Change-Id: Ic2b4cfa04c8230d45c68bbf6b370841f682b32d6 Signed-off-by: Paul Fertser <fercerpav@gmail.com> Reviewed-on: http://openocd.zylin.com/1785 Tested-by: jenkins Reviewed-by: Jens Bauer <jens@gpio.dk> Reviewed-by: Mathias Küster <kesmtp@freenet.de> Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2013-10-15checkpatch: add logging functionsPaul Fertser1-1/+2
It's commonly considered that user-visible strings should not be split to different lines in the sources to ease grepping for them. Hence, checkpatch traditionally makes an exception for logging functions, lines having them can be of arbitrary length. OpenOCD uses different (from Linux, the kernel) names, so they need to be added to avoid false positives. Change-Id: I1198c1ffc62b5403d97efa41e665c81a5b6bb3a3 Signed-off-by: Paul Fertser <fercerpav@gmail.com> Reviewed-on: http://openocd.zylin.com/1696 Tested-by: jenkins Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2012-02-06checkpatch: remove __packed and __aligned checksSpencer Oliver1-8/+8
These checks are specific to linux kernel. Change-Id: Ia9b837b5609922a897822f1d55f96f04c0f1f838 Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk> Reviewed-on: http://openocd.zylin.com/424 Tested-by: jenkins
2012-02-06checkpatch: increase line length to 120Spencer Oliver1-3/+3
Change-Id: I963385d0a4880f2b1e55208c8dfe65c1870ac6e1 Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk> Reviewed-on: http://openocd.zylin.com/422 Tested-by: jenkins
2012-02-06checkpatch: remove volatile checkSpencer Oliver1-5/+5
We may enable this again - but at the moment is causing extra issues with reformatting the codebase. Change-Id: I5a2aaaa32ad784e011dff3079ff45501452c1819 Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk> Reviewed-on: http://openocd.zylin.com/414
2012-02-06checkpatch: remove typedef checkSpencer Oliver1-8/+8
We may enable this again - but at the moment is causing extra issues with reformatting the codebase. Change-Id: Ic64310a20605a0ef3206caa15c8e6c8ee655bfda Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk> Reviewed-on: http://openocd.zylin.com/413 Tested-by: jenkins
2011-12-16checkpatch: fix false indent triggerSpencer Oliver1-1/+1
we have changed the indent to 4 to match OpenOCD coding style. Change-Id: I4870a3410eb20fc2f6df6a3e5891d4d4e598131a Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk> Reviewed-on: http://openocd.zylin.com/285 Tested-by: jenkins
2011-12-16checkpatch: disable extern and switch indent checksSpencer Oliver1-48/+48
We allow extern's in c files so disable checkpatch checks. Change-Id: Ia649585cd70ec45289c4edaf26c1fd773a140db4 Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk> Reviewed-on: http://openocd.zylin.com/284 Tested-by: jenkins Reviewed-by: Øyvind Harboe <oyvindharboe@gmail.com>
2011-12-16Change checkpatch.pl tab expanding to 4 characters.Erik Ahlén1-1/+1
The C coding style guide says that tab width is 4 characters but checkpatch.pl expands tabs to 8 characters which produces false negatives. Change-Id: Ibdabbb55269b7cf6bcd38042cccb8bd235e42ce2 Signed-off-by: Erik Ahlén <erik.ahlen@avalonenterprise.com> Reviewed-on: http://openocd.zylin.com/275 Tested-by: jenkins Reviewed-by: Øyvind Harboe <oyvindharboe@gmail.com> Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2011-11-04tools: fix permissionsSpencer Oliver1-0/+0
Change-Id: I9419138dd2972304daf215594ca917ac8eb7fcda Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk>
2011-11-03checkpatch: increase line length warning to 100Spencer Oliver1-3/+3
Change-Id: Ief0445ea6581929b3ffdcf8bc644ce5f27b392c4 Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk>
2011-11-03tools: add checkpatch scriptSpencer Oliver1-0/+3337
Change-Id: I3579028fc1c6ee8bea58c82e5f0eecba7794d7cb Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk>