diff options
author | Mauro Carvalho Chehab <mchehab@s-opensource.com> | 2017-12-30 19:32:55 -0500 |
---|---|---|
committer | Jonathan Corbet <corbet@lwn.net> | 2018-01-01 14:49:07 -0500 |
commit | 85afe608f5f3c10134e94c8aa87d9f9eecd81622 (patch) | |
tree | eea515048d4cd04d21ed113de2f2062b431b7f2f | |
parent | 91581e4c60db35268ad67c550f5c551045f592f5 (diff) |
scripts: kernel_doc: better handle show warnings logic
The logic with inhibits warnings for definitions that is not
output is incomplete: it doesn't cover the cases where
OUTPUT_INTERNAL and OUTPUT_EXPORTED are used.
As the most common case is OUTPUT_ALL, place it first,
in order to optimize a litte bit the check logic.
Fixes: 2defb2729217 ("scripts: kernel-doc: apply filtering rules to warnings")
Reported-by: Randy Dunlap <rdunlap@infradead.org>
Acked-and-Tested-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
-rwxr-xr-x | scripts/kernel-doc | 56 |
1 files changed, 41 insertions, 15 deletions
diff --git a/scripts/kernel-doc b/scripts/kernel-doc index 1e2b35ce1c9d..fee8952037b1 100755 --- a/scripts/kernel-doc +++ b/scripts/kernel-doc | |||
@@ -1140,6 +1140,44 @@ sub dump_struct($$) { | |||
1140 | } | 1140 | } |
1141 | } | 1141 | } |
1142 | 1142 | ||
1143 | |||
1144 | sub show_warnings($$) { | ||
1145 | my $functype = shift; | ||
1146 | my $name = shift; | ||
1147 | |||
1148 | return 1 if ($output_selection == OUTPUT_ALL); | ||
1149 | |||
1150 | if ($output_selection == OUTPUT_EXPORTED) { | ||
1151 | if (defined($function_table{$name})) { | ||
1152 | return 1; | ||
1153 | } else { | ||
1154 | return 0; | ||
1155 | } | ||
1156 | } | ||
1157 | if ($output_selection == OUTPUT_INTERNAL) { | ||
1158 | if (!($functype eq "function" && defined($function_table{$name}))) { | ||
1159 | return 1; | ||
1160 | } else { | ||
1161 | return 0; | ||
1162 | } | ||
1163 | } | ||
1164 | if ($output_selection == OUTPUT_INCLUDE) { | ||
1165 | if (defined($function_table{$name})) { | ||
1166 | return 1; | ||
1167 | } else { | ||
1168 | return 0; | ||
1169 | } | ||
1170 | } | ||
1171 | if ($output_selection == OUTPUT_EXCLUDE) { | ||
1172 | if (!defined($function_table{$name})) { | ||
1173 | return 1; | ||
1174 | } else { | ||
1175 | return 0; | ||
1176 | } | ||
1177 | } | ||
1178 | die("Please add the new output type at show_warnings()"); | ||
1179 | } | ||
1180 | |||
1143 | sub dump_enum($$) { | 1181 | sub dump_enum($$) { |
1144 | my $x = shift; | 1182 | my $x = shift; |
1145 | my $file = shift; | 1183 | my $file = shift; |
@@ -1160,11 +1198,7 @@ sub dump_enum($$) { | |||
1160 | push @parameterlist, $arg; | 1198 | push @parameterlist, $arg; |
1161 | if (!$parameterdescs{$arg}) { | 1199 | if (!$parameterdescs{$arg}) { |
1162 | $parameterdescs{$arg} = $undescribed; | 1200 | $parameterdescs{$arg} = $undescribed; |
1163 | if (($output_selection == OUTPUT_ALL) || | 1201 | if (show_warnings("enum", $declaration_name)) { |
1164 | ($output_selection == OUTPUT_INCLUDE && | ||
1165 | defined($function_table{$declaration_name})) || | ||
1166 | ($output_selection == OUTPUT_EXCLUDE && | ||
1167 | !defined($function_table{$declaration_name}))) { | ||
1168 | print STDERR "${file}:$.: warning: Enum value '$arg' not described in enum '$declaration_name'\n"; | 1202 | print STDERR "${file}:$.: warning: Enum value '$arg' not described in enum '$declaration_name'\n"; |
1169 | } | 1203 | } |
1170 | } | 1204 | } |
@@ -1173,11 +1207,7 @@ sub dump_enum($$) { | |||
1173 | 1207 | ||
1174 | while (my ($k, $v) = each %parameterdescs) { | 1208 | while (my ($k, $v) = each %parameterdescs) { |
1175 | if (!exists($_members{$k})) { | 1209 | if (!exists($_members{$k})) { |
1176 | if (($output_selection == OUTPUT_ALL) || | 1210 | if (show_warnings("enum", $declaration_name)) { |
1177 | ($output_selection == OUTPUT_INCLUDE && | ||
1178 | defined($function_table{$declaration_name})) || | ||
1179 | ($output_selection == OUTPUT_EXCLUDE && | ||
1180 | !defined($function_table{$declaration_name}))) { | ||
1181 | print STDERR "${file}:$.: warning: Excess enum value '$k' description in '$declaration_name'\n"; | 1211 | print STDERR "${file}:$.: warning: Excess enum value '$k' description in '$declaration_name'\n"; |
1182 | } | 1212 | } |
1183 | } | 1213 | } |
@@ -1385,11 +1415,7 @@ sub push_parameter($$$$) { | |||
1385 | if (!defined $parameterdescs{$param} && $param !~ /^#/) { | 1415 | if (!defined $parameterdescs{$param} && $param !~ /^#/) { |
1386 | $parameterdescs{$param} = $undescribed; | 1416 | $parameterdescs{$param} = $undescribed; |
1387 | 1417 | ||
1388 | if (($output_selection == OUTPUT_ALL) || | 1418 | if (show_warnings($type, $declaration_name)) { |
1389 | ($output_selection == OUTPUT_INCLUDE && | ||
1390 | defined($function_table{$declaration_name})) || | ||
1391 | ($output_selection == OUTPUT_EXCLUDE && | ||
1392 | !defined($function_table{$declaration_name}))) { | ||
1393 | print STDERR | 1419 | print STDERR |
1394 | "${file}:$.: warning: Function parameter or member '$param' not described in '$declaration_name'\n"; | 1420 | "${file}:$.: warning: Function parameter or member '$param' not described in '$declaration_name'\n"; |
1395 | ++$warnings; | 1421 | ++$warnings; |