aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOliver Smith <osmith@sysmocom.de>2021-12-08 11:32:24 +0100
committerOliver Smith <osmith@sysmocom.de>2021-12-08 11:32:24 +0100
commit73b33a4e9e42da3d61f14940a15e145c9b178da0 (patch)
tree35547a2f9f6768517415552cddfd1cdd2c8844a4
parent425cbb5e28b207a27bea2ed476d8b687107254ec (diff)
lint: checkpatch_osmo: ignore BRACES_NOT_NECESSARY
Don't complain about using braces when they could be omitted, for example: if (condition) { single_statement(); } Another example: if (condition) { single_statement(); } else { another_single_statement(); } This is not something we would care about in code review either from what I've seen and so it's probably just annoying for patch authors to fix up. Related: OS#5087 Change-Id: Ice08d5b88c683a59bacff999a1d6c07754663d39
-rwxr-xr-xlint/checkpatch/checkpatch.pl4
-rwxr-xr-xlint/checkpatch/checkpatch_osmo.sh2
2 files changed, 4 insertions, 2 deletions
diff --git a/lint/checkpatch/checkpatch.pl b/lint/checkpatch/checkpatch.pl
index e31a61f..a4d229c 100755
--- a/lint/checkpatch/checkpatch.pl
+++ b/lint/checkpatch/checkpatch.pl
@@ -6008,7 +6008,7 @@ sub process {
$sum_allowed += $_;
}
if ($sum_allowed == 0) {
- WARN("BRACES",
+ WARN("BRACES_NOT_NECESSARY", # Osmocom specific: renamed from BRACES
"braces {} are not necessary for any arm of this statement\n" . $herectx);
} elsif ($sum_allowed != $allow &&
$seen != $allow) {
@@ -6064,7 +6064,7 @@ sub process {
my $cnt = statement_rawlines($block);
my $herectx = get_stat_here($linenr, $cnt, $here);
- WARN("BRACES",
+ WARN("BRACES_NOT_NECESSARY", # Osmocom specific: renamed from BRACES
"braces {} are not necessary for single statement blocks\n" . $herectx);
}
}
diff --git a/lint/checkpatch/checkpatch_osmo.sh b/lint/checkpatch/checkpatch_osmo.sh
index ae66e71..d1ce63a 100755
--- a/lint/checkpatch/checkpatch_osmo.sh
+++ b/lint/checkpatch/checkpatch_osmo.sh
@@ -49,6 +49,7 @@ exclude_paths_project() {
# * ASSIGN_IN_IF: not followed (e.g. 'if ((u8 = gsup_msg->cause))')
# * AVOID_EXTERNS: we do use externs
# * BLOCK_COMMENT_STYLE: we don't use a trailing */ on a separate line
+# * BRACES_NOT_NECESSARY: not followed
# * COMPLEX_MACRO: we don't use parentheses when building macros of strings across multiple lines
# * CONSTANT_COMPARISON: not followed: "Comparisons should place the constant on the right side"
# * DEEP_INDENTATION: warns about many leading tabs, not useful if changing existing code without refactoring
@@ -84,6 +85,7 @@ $SCRIPT_DIR/checkpatch.pl \
--ignore ASSIGN_IN_IF \
--ignore AVOID_EXTERNS \
--ignore BLOCK_COMMENT_STYLE \
+ --ignore BRACES_NOT_NECESSARY \
--ignore COMPLEX_MACRO \
--ignore CONSTANT_COMPARISON \
--ignore DEEP_INDENTATION \