Elyes Haouas has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/76869?usp=email )
Change subject: lint/checkpatch.pl: Check for 0-length and 1-element arrays ......................................................................
lint/checkpatch.pl: Check for 0-length and 1-element arrays
Use C99 flexible arrays instead of deprecated fake flexible arrays. This reduce difference with upstream.
Change-Id: I24016493280e22f34ae5cce49fe7c1f520270f9a Signed-off-by: Elyes Haouas ehaouas@noos.fr --- M util/lint/checkpatch.pl 1 file changed, 10 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/69/76869/1
diff --git a/util/lint/checkpatch.pl b/util/lint/checkpatch.pl index c2efdbc..ab36f14 100755 --- a/util/lint/checkpatch.pl +++ b/util/lint/checkpatch.pl @@ -6820,6 +6820,16 @@ "Using $1 should generally have parentheses around the comparison\n" . $herecurr); }
+# check for array definition/declarations that should use flexible arrays instead + if ($sline =~ /^[+ ]\s*}(?:\s*__packed)?\s*;\s*$/ && + $prevline =~ /^+\s*(?:}(?:\s*__packed\s*)?|$Type)\s*$Ident\s*[\s*(0|1)\s*]\s*;\s*$/) { + if (ERROR("FLEXIBLE_ARRAY", + "Use C99 flexible arrays - see https://docs.kernel.org/process/deprecated.html#zero-length-and-one-element-..." . $hereprev) && + $1 == '0' && $fix) { + $fixed[$fixlinenr - 1] =~ s/[\s*0\s*]/[]/; + } + } + # whine mightly about in_atomic if ($line =~ /\bin_atomic\s*(/) { if ($realfile =~ m@^drivers/@) {