Skip to content

Commit 4664034

Browse files
committed
Ignore STATIC_CONST_CHAR_ARRAY in tests
It's convenient to define a char * array on stack in a test.
1 parent 9a847fe commit 4664034

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

checkpatch.pl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2142,6 +2142,7 @@ sub process {
21422142
my $has_changelog = 0;
21432143
my $has_doc = 0;
21442144
my $has_test = 0;
2145+
my $is_test = 0;
21452146

21462147
# Pre-scan the patch sanitizing the lines.
21472148

@@ -2828,6 +2829,8 @@ sub process {
28282829
# ignore C source files outside the source and test directories when checking patches
28292830
next if !$file and ($realfile !~ /^(?:src|test|perf)\// || $realfile =~ /^$skipSrcPaths/);
28302831

2832+
$is_test = ($realfile =~ /^(?:test|perf)\//);
2833+
28312834
# line length limit (with some exclusions)
28322835
#
28332836
# There are a few types of lines that may extend beyond $max_line_length:
@@ -3579,7 +3582,7 @@ sub process {
35793582
}
35803583

35813584
# check for non-global char *foo[] = {"bar", ...} declarations.
3582-
if ($line =~ /^.\s+(?:static\s+|const\s+)?char\s+\*\s*\w+\s*\[\s*\]\s*=\s*\{/) {
3585+
if (!$is_test && $line =~ /^.\s+(?:static\s+|const\s+)?char\s+\*\s*\w+\s*\[\s*\]\s*=\s*\{/) {
35833586
ERROR("STATIC_CONST_CHAR_ARRAY",
35843587
"char * array declaration might be better as static const\n" . $herecurr);
35853588
}
@@ -4648,7 +4651,7 @@ sub process {
46484651
my $check_comment = 0;
46494652
my $check_comment_line = $linenr;
46504653
my $check_comment_ident;
4651-
if ($realfile =~ /^(?:test|perf)\//) {
4654+
if ($is_test) {
46524655
# ignore tests
46534656
} elsif ($realfile =~ /\bbox\.h$/ && $line =~ /^\+\s*(?:$Declare)?\s*box_set_/) {
46544657
# ignore box_set_XXX in box.h

0 commit comments

Comments
 (0)