diff options
author | Antonio Borneo <borneo.antonio@gmail.com> | 2021-04-17 22:37:12 +0200 |
---|---|---|
committer | Antonio Borneo <borneo.antonio@gmail.com> | 2022-09-18 08:20:56 +0000 |
commit | 9f25e470f90be7ad05b2685a624d372be6998df2 (patch) | |
tree | 04108e07f9544c9449a2a5d4462749908f5cd61d /tools/scripts/checkpatch.pl | |
parent | 496308701342032d54bfe04c6e2653be252ccd94 (diff) | |
download | riscv-openocd-9f25e470f90be7ad05b2685a624d372be6998df2.zip riscv-openocd-9f25e470f90be7ad05b2685a624d372be6998df2.tar.gz riscv-openocd-9f25e470f90be7ad05b2685a624d372be6998df2.tar.bz2 |
checkpatch: enable CAMELCASE test
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
Diffstat (limited to 'tools/scripts/checkpatch.pl')
-rwxr-xr-x | tools/scripts/checkpatch.pl | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tools/scripts/checkpatch.pl b/tools/scripts/checkpatch.pl index 12e7ab8..0319d43 100755 --- a/tools/scripts/checkpatch.pl +++ b/tools/scripts/checkpatch.pl @@ -988,6 +988,32 @@ sub read_words { return 0; } +# OpenOCD specific: Begin: Load list of allowed CamelCase symbols +if (show_type("CAMELCASE")) { + my $allowed_camelcase_file = "$root/tools/scripts/camelcase.txt"; + if (open(my $words, '<', $allowed_camelcase_file)) { + while (<$words>) { + my $line = $_; + + $line =~ s/\s*\n?$//g; + $line =~ s/^\s*//g; + + next if ($line =~ m/^\s*#/); + next if ($line =~ m/^\s*$/); + if ($line =~ /\s/) { + print("$allowed_camelcase_file: '$line' invalid - ignored\n"); + next; + } + + $camelcase{$line} = 1; + } + close($allowed_camelcase_file); + } else { + warn "No camelcase symbols to ignore - file '$allowed_camelcase_file': $!\n"; + } +} +# OpenOCD specific: End + my $const_structs; if (show_type("CONST_STRUCT")) { read_words(\$const_structs, $conststructsfile) @@ -5786,6 +5812,10 @@ sub process { while ($var =~ m{\b($Ident)}g) { my $word = $1; next if ($word !~ /[A-Z][a-z]|[a-z][A-Z]/); + if (!$OpenOCD) { + # This will not work for OpenOCD jenkins because it runs + # checkpatch from a tree already patched. Any new camelcase + # in include file will be ignored as it was pre-existing. if ($check) { seed_camelcase_includes(); if (!$file && !$camelcase_file_seeded) { @@ -5793,6 +5823,7 @@ sub process { $camelcase_file_seeded = 1; } } + } # !$OpenOCD if (!defined $camelcase{$word}) { $camelcase{$word} = 1; CHK("CAMELCASE", |