Skip to content

Commit 5be78fa

Browse files
committed
HACKING: add chapter on checkpatch
Include hints on how to skip some of the tests in some really exceptional case. Note: the file includes an example of commit message with a signed off tag that triggers a checkpatch error. Let checkpatch to ignore BAD_SIGN_OFF error. Checkpatch-ignore: BAD_SIGN_OFF Change-Id: I05bf0ab8008649f3f9b38452e056dc3df83a1a4f Signed-off-by: Antonio Borneo <[email protected]> Reviewed-on: https://review.openocd.org/c/openocd/+/5609 Tested-by: jenkins
1 parent c8c9121 commit 5be78fa

File tree

1 file changed

+64
-1
lines changed

1 file changed

+64
-1
lines changed

HACKING

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,8 @@ while(!done) {
171171
@endcode
172172
\note use "git add ." before commit to add new files.
173173

174+
\note check @ref checkpatch for hint about checkpatch script
175+
174176
Commit message template, notice the short first line.
175177
The field '<c>specify touched area</c>'
176178
should identify the main part or subsystem the patch touches.
@@ -179,7 +181,9 @@ specify touched area: short comment
179181
<blank line>
180182
Longer comments over several lines, explaining (where applicable) the
181183
reason for the patch and the general idea the solution is based on,
182-
any major design decisions, etc...
184+
any major design decisions, etc. Limit each comment line's length to 75
185+
characters; since 75 it's too short for a URL, you can put the URL in a
186+
separate line preceded by 'Link: '.
183187
<blank line>
184188
Signed-off-by: ...
185189
@endcode
@@ -227,6 +231,65 @@ git push review
227231

228232
Further reading: http://www.coreboot.org/Git
229233

234+
@section checkpatch About checkpatch script
235+
236+
OpenOCD source code includes the script checkpatch to let developers to
237+
verify their patches before submitting them for review (see @ref gerrit).
238+
239+
Every patch for OpenOCD project that is submitted for review on Gerrit
240+
is tested by Jenkins. Jenkins will run the checkpatch script to analyze
241+
each patch.
242+
If the script highlights either errors or warnings, Gerrit will add the
243+
score "-1" to the patch and maintainers will probably ignore the patch,
244+
waiting for the developer to send a fixed version.
245+
246+
The script checkpatch verifies the SPDX tag for new files against a very
247+
short list of license tags.
248+
If the license of your contribution is not listed there, but compatible
249+
with OpenOCD license, please alert the maintainers or add the missing
250+
license in the first patch of your patch series.
251+
252+
The script checkpatch has been originally developed for the Linux kernel
253+
source code, thus includes specific tests and checks related to Linux
254+
coding style and to Linux code structure. While the script has been
255+
adapted for OpenOCD specificities, it still includes some Linux related
256+
test. It is then possible that it triggers sometimes some <em>false
257+
positive</em>!
258+
259+
If you think that the error identified by checkpatch is a false
260+
positive, please report it to the openocd-devel mailing list or prepare
261+
a patch for fixing checkpatch and send it to Gerrit for review.
262+
263+
\attention The procedure below is allowed only for <em>exceptional
264+
cases</em>. Do not use it to submit normal patches.
265+
266+
There are <em>exceptional cases</em> in which you need to skip some of
267+
the tests from checkpatch in order to pass the approval from Gerrit.
268+
269+
For example, a patch that modify one line inside a big comment block
270+
will not show the beginning or the end of the comment block. This can
271+
prevent checkpatch to detect the comment block. Checkpatch can wrongly
272+
consider the modified comment line as a code line, triggering a set of
273+
false errors.
274+
275+
Only for <em>exceptional cases</em>, it is allowed to submit patches
276+
to Gerrit with the special field 'Checkpatch-ignore:' in the commit
277+
message. This field will cause checkpatch to ignore the error types
278+
listed in the field, only for the patch itself.
279+
The error type is printed by checkpatch on failure.
280+
For example the names of Windows APIs mix lower and upper case chars,
281+
in violation of OpenOCD coding style, triggering a 'CAMELCASE' error:
282+
@code
283+
CHECK:CAMELCASE: Avoid CamelCase: <WSAGetLastError>
284+
#96105: FILE: src/helper/log.c:505:
285+
+ error_code = WSAGetLastError();
286+
@endcode
287+
Adding in the commit message of the patch the line:
288+
@code
289+
Checkpatch-ignore: CAMELCASE
290+
@endcode
291+
will force checkpatch to ignore the CAMELCASE error.
292+
230293
@section timeline When can I expect my contribution to be committed?
231294

232295
The code review is intended to take as long as a week or two to allow

0 commit comments

Comments
 (0)