This is an automated email from Gerrit. "Antonio Borneo <borneo.anto...@gmail.com>" just uploaded a new patch set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/8188
-- gerrit commit 4fb7bd5a7c35fa452a1a8b5b1e16694f24e264a5 Author: Antonio Borneo <borneo.anto...@gmail.com> Date: Sun Mar 24 22:47:52 2024 +0100 checkpatch: allow indentation of 2 TAB in if block The coding style of OpenOCD requires indentation by one TAB and also requires TAB to be 4 characters. The indentation of 4 characters has the same length of the string "if (" and this can make hard to distinguish between the last line of a multi-line condition and the first line of the 'true' block. E.g.: if (condition_1 || condition_2) { block; } A simple way to make the code more readable consists in using two TAB indentation in this special case, e.g.: if (condition_1 || condition_2) { block; } Modify checkpatch script to allow two TAB indentation for the 'true' block of a condition. Change-Id: I56ce70f9e18ea55cb4dc2a280e7f81c4f0c7f971 Signed-off-by: Antonio Borneo <borneo.anto...@gmail.com> diff --git a/tools/scripts/checkpatch.pl b/tools/scripts/checkpatch.pl index 9dda61cde0..17cf047b26 100755 --- a/tools/scripts/checkpatch.pl +++ b/tools/scripts/checkpatch.pl @@ -4422,12 +4422,19 @@ sub process { #print "line<$line> prevline<$prevline> indent<$indent> sindent<$sindent> check<$check> continuation<$continuation> s<$s> cond_lines<$cond_lines> stat_real<$stat_real> stat<$stat>\n"; + # Openocd with tabsize==4, allow indent of 2 TABs to prevent alignment + # of the condition of 'if' statement with the true block. E.g.: + # if (cond_1 || + # cond_2) { + # block; + # } + my $OpenOCD_indent_max = $tabsize == 4 && $line =~ /\b(?:if\s*\(\b)/ ? 8 : $tabsize; if ($check && $s ne '' && (($sindent % $tabsize) != 0 || ($sindent < $indent) || ($sindent == $indent && ($s !~ /^\s*(?:\}|\{|else\b)/)) || - ($sindent > $indent + $tabsize))) { + ($sindent > $indent + $OpenOCD_indent_max))) { WARN("SUSPECT_CODE_INDENT", "suspect code indent for conditional statements ($indent, $sindent)\n" . $herecurr . "$stat_real\n"); } --