checkpatch: enable CAMELCASE test 70/6170/6
authorAntonio Borneo <borneo.antonio@gmail.com>
Sat, 17 Apr 2021 20:37:12 +0000 (22:37 +0200)
committerAntonio Borneo <borneo.antonio@gmail.com>
Sun, 18 Sep 2022 08:20:56 +0000 (08:20 +0000)
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
.checkpatch.conf
.gitignore
tools/scripts/camelcase.txt [new file with mode: 0644]
tools/scripts/checkpatch.pl

index 9d20846594af7964506e430244a3f08b04dc218f..8cb9a3729ae19bb73cd6310145d2548a769e914a 100644 (file)
@@ -9,7 +9,6 @@
 
 --ignore AVOID_EXTERNS
 --ignore BLOCK_COMMENT_STYLE
---ignore CAMELCASE
 --ignore COMPLEX_MACRO
 --ignore CONST_STRUCT
 --ignore ENOSYS
index 955ca3c2e0acc8dc7faa08d37267999d943649f7..818bb0cd3d48d1a7377ad8362c91ba20f12a415a 100644 (file)
@@ -100,3 +100,6 @@ tags
 GPATH
 GRTAGS
 GTAGS
+
+# checkpatch script files
+.checkpatch-camelcase.*
diff --git a/tools/scripts/camelcase.txt b/tools/scripts/camelcase.txt
new file mode 100644 (file)
index 0000000..59fe5ca
--- /dev/null
@@ -0,0 +1,217 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+# The OpenOCD coding-style rules forbids CamelCase names for symbols,
+# either functions, variables, macros and enums.
+# The script checkpatch detects the CamelCase symbols.
+# This file contains the exceptions to the coding-style, mainly due
+# to external dependencies and libraries.
+
+# format types from inttypes.h (only some are already used)
+PRId8
+PRId16
+PRId32
+PRId64
+PRIi8
+PRIi16
+PRIi32
+PRIi64
+PRIo8
+PRIo16
+PRIo32
+PRIo64
+PRIu8
+PRIu16
+PRIu32
+PRIu64
+PRIx8
+PRIx16
+PRIx32
+PRIx64
+PRIX8
+PRIX16
+PRIX32
+PRIX64
+SCNd8
+SCNd16
+SCNd32
+SCNd64
+SCNi8
+SCNi16
+SCNi32
+SCNi64
+SCNo8
+SCNo16
+SCNo32
+SCNo64
+SCNu8
+SCNu16
+SCNu32
+SCNu64
+SCNx8
+SCNx16
+SCNx32
+SCNx64
+SCNX8
+SCNX16
+SCNX32
+SCNX64
+
+# OpenOCD format types
+TARGET_PRIdADDR
+TARGET_PRIoADDR
+TARGET_PRIuADDR
+TARGET_PRIxADDR
+
+# from libusb.h
+bcdDevice
+bConfigurationValue
+bEndpointAddress
+bInterfaceClass
+bInterfaceNumber
+bInterfaceProtocol
+bInterfaceSubClass
+bmAttributes
+bNumConfigurations
+bNumEndpoints
+bNumInterfaces
+idProduct
+idVendor
+iInterface
+iProduct
+iSerialNumber
+wMaxPacketSize
+
+# from jimtcl/jim.h and jimtcl/jim-eventloop.h
+Jim_AppendString
+Jim_AppendStrings
+Jim_Cmd
+Jim_CmdPrivData
+Jim_CmdProc
+Jim_CompareStringImmediate
+Jim_ConcatObj
+Jim_CreateCommand
+Jim_CreateInterp
+Jim_DecrRefCount
+Jim_DelCmdProc
+Jim_DeleteAssocData
+Jim_DeleteCommand
+Jim_DictAddElement
+Jim_DictPairs
+Jim_DuplicateObj
+Jim_Eval
+Jim_EvalExpression
+Jim_EvalObj
+Jim_EvalObjPrefix
+Jim_EvalSource
+Jim_Eval_Named
+Jim_FreeInterp
+Jim_FreeObj
+Jim_GetAssocData
+Jim_GetCommand
+Jim_GetDouble
+Jim_GetEnum
+Jim_GetExitCode
+Jim_GetGlobalVariableStr
+Jim_GetIntRepPtr
+Jim_GetLong
+Jim_GetResult
+Jim_GetString
+Jim_GetVariable
+Jim_GetWide
+Jim_IncrRefCount
+Jim_InitStaticExtensions
+Jim_Interp
+Jim_ListAppendElement
+Jim_ListGetIndex
+Jim_ListLength
+Jim_MakeErrorMessage
+Jim_NewDictObj
+Jim_NewEmptyStringObj
+Jim_NewIntObj
+Jim_NewListObj
+Jim_NewStringObj
+Jim_NewWideObj
+Jim_Obj
+Jim_ProcessEvents
+Jim_RegisterCoreCommands
+Jim_SetAssocData
+Jim_SetEmptyResult
+Jim_SetResult
+Jim_SetResultBool
+Jim_SetResultFormatted
+Jim_SetResultInt
+Jim_SetResultString
+Jim_SetVariable
+Jim_String
+Jim_WrongNumArgs
+cmdProc
+currentScriptObj
+delProc
+emptyObj
+privData
+returnCode
+typePtr
+
+# from elf.h
+Elf32_Addr
+Elf32_Ehdr
+Elf32_Half
+Elf32_Off
+Elf32_Phdr
+Elf32_Size
+Elf32_Word
+Elf64_Addr
+Elf64_Ehdr
+Elf64_Half
+Elf64_Off
+Elf64_Phdr
+Elf64_Word
+Elf64_Xword
+
+# for BSD's
+__FreeBSD__
+__FreeBSD_kernel__
+
+# for Windows
+CreateFile
+CloseHandle
+CreatePipe
+CreateProcess
+FormatMessage
+GetLastError
+GetModuleFileName
+GetSystemTimeAsFileTime
+GetTickCount
+GetVersionEx
+HighPart
+LowPart
+MsgWaitForMultipleObjects
+PeekMessage
+PeekNamedPipe
+QuadPart
+ReadFile
+SetConsoleCtrlHandler
+SetHandleInformation
+Sleep
+WaitForSingleObject
+WriteFile
+WSACleanup
+WSAGetLastError
+WSAStartup
+ZeroMemory
+bInheritHandle
+dwFlags
+dwHighDateTime
+dwLowDateTime
+dwPlatformId
+dwOSVersionInfoSize
+hProcess
+hThread
+hStdError
+hStdInput
+hStdOutput
+lpSecurityDescriptor
+nLength
+
+# OpenOCD exceptions that should be removed
+KiB
index 12e7ab855d80083353423642e722e74fcb1588ff..0319d43d534b2732ec9110dae82021322e94eb6d 100755 (executable)
@@ -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",

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)