summaryrefslogtreecommitdiff
path: root/tools/patman/test_checkpatch.py
AgeCommit message (Collapse)AuthorFilesLines
2021-04-13checkpatch: Add warnings for using strn(cat|cpy)Sean Anderson1-1/+13
strn(cat|cpy) has a bad habit of not nul-terminating the destination, resulting in constructions like strncpy(foo, bar, sizeof(foo) - 1); foo[sizeof(foo) - 1] = '\0'; However, it is very easy to forget about this behavior and accidentally leave a string unterminated. This has shown up in some recent coverity scans [1, 2] (including code recently touched by yours truly). Fortunately, the guys at OpenBSD came up with strl(cat|cpy), which always nul-terminate strings. These functions are already in U-Boot, so we should encourage new code to use them instead of strn(cat|cpy). [1] https://lists.denx.de/pipermail/u-boot/2021-March/442888.html [2] https://lists.denx.de/pipermail/u-boot/2021-January/438073.html Signed-off-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2020-12-14checkpatch: Add warnings for unexpected struct namesSimon Glass1-0/+28
As a way of keeping the driver declarations more consistent, add a warning if the struct used does not end with _priv or _plat. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-11-05patman: Rename functions in patchstreamSimon Glass1-3/+3
Rename these functions to lower case as per PEP8. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-10-14checkpatch.pl: Make CONFIG_IS_ENABLED(CONFIG_*) an errorAlper Nebi Yasak1-0/+6
CONFIG_IS_ENABLED() takes the kconfig name without the CONFIG_ prefix, e.g. CONFIG_IS_ENABLED(CLK) for CONFIG_CLK. Make including the prefix an error in checkpatch.pl so calls in the wrong format aren't accidentally reintroduced. Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2020-08-04checkpatch: Don't allow common.h and dm.h in headersSimon Glass1-0/+7
These headers should not be included in other header files. Add a checkpatch rule and test for this. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-08-04patman: Fix up the test commentsSimon Glass1-5/+5
Many of the tests have the same comment and two have the same name. Fix this. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-07-10checkpatch: Don't warn about PREFER_IF in headers/DT filesSimon Glass1-0/+2
This warning should only be displayed for C files. Fix it and update the test. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-07-10patman: Add tests for the rest of the checkpatch checksSimon Glass1-4/+43
Finish off the tests for our small collection of checkpatch checks. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-07-10patman: Decode output from the '--show-types' optionSimon Glass1-2/+2
Collect the 'checkpatch type' from each error, warning and check. Provide this to patman and update the uclass test to use it. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-07-10patman: Add a test for the 'possible new uclass' checkSimon Glass1-0/+77
It is quite likely that the number of U-Boot-specific tests in checkpatch.pl will increase over time. We should have tests for these to avoid undefined behaviour and bugs being introduced, which might cause people to ignore the warnings. Add a simple new class that can generate a patch with a single-line addition in it. Use that to add a test for one of the checkpatch checks. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-07-10patman: Rename test.py to test_checkpatch.pySimon Glass1-0/+286
These tests check checkpatch.pl operation and can server as our tests for the U-Boot-specific updates to that script. Rename the file and update comments to indicate this. Signed-off-by: Simon Glass <sjg@chromium.org>