diff options
| author | Mauro Carvalho Chehab <mchehab@s-opensource.com> | 2017-12-18 07:30:15 -0500 |
|---|---|---|
| committer | Jonathan Corbet <corbet@lwn.net> | 2017-12-21 15:41:47 -0500 |
| commit | 151c468b44a89a9f3173ab8575690014b7249893 (patch) | |
| tree | e615ca966937e9d2759ed20a3704359e1be4adda /scripts/kernel-doc | |
| parent | 1081de2d2f9179d7280926e37b7b22b4f2fb32e6 (diff) | |
scripts: kernel-doc: print the declaration name on warnings
The logic at create_parameterlist()'s ancillary push_parameter()
function has already a way to output the declaration name, with
would help to discover what declaration is missing.
However, currently, the logic is utterly broken, as it uses
the var $type with a wrong meaning. With the current code,
it will never print anything. I suspect that originally
it was using the second argument of output_declaration().
I opted to not rely on a globally defined $declaration_name,
but, instead, to pass it explicitly as a parameter.
While here, I removed a unaligned check for !$anon_struct_union.
This is not needed, as, if $anon_struct_union is not zero,
$parameterdescs{$param} will be defined.
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Diffstat (limited to 'scripts/kernel-doc')
| -rwxr-xr-x | scripts/kernel-doc | 38 |
1 files changed, 16 insertions, 22 deletions
diff --git a/scripts/kernel-doc b/scripts/kernel-doc index fadb832733d9..c97b89f47795 100755 --- a/scripts/kernel-doc +++ b/scripts/kernel-doc | |||
| @@ -1063,7 +1063,7 @@ sub dump_struct($$) { | |||
| 1063 | # Ignore other nested elements, like enums | 1063 | # Ignore other nested elements, like enums |
| 1064 | $members =~ s/({[^\{\}]*})//g; | 1064 | $members =~ s/({[^\{\}]*})//g; |
| 1065 | 1065 | ||
| 1066 | create_parameterlist($members, ';', $file); | 1066 | create_parameterlist($members, ';', $file, $declaration_name); |
| 1067 | check_sections($file, $declaration_name, $decl_type, $sectcheck, $struct_actual); | 1067 | check_sections($file, $declaration_name, $decl_type, $sectcheck, $struct_actual); |
| 1068 | 1068 | ||
| 1069 | # Adjust declaration for better display | 1069 | # Adjust declaration for better display |
| @@ -1172,7 +1172,7 @@ sub dump_typedef($$) { | |||
| 1172 | $declaration_name = $2; | 1172 | $declaration_name = $2; |
| 1173 | my $args = $3; | 1173 | my $args = $3; |
| 1174 | 1174 | ||
| 1175 | create_parameterlist($args, ',', $file); | 1175 | create_parameterlist($args, ',', $file, $declaration_name); |
| 1176 | 1176 | ||
| 1177 | output_declaration($declaration_name, | 1177 | output_declaration($declaration_name, |
| 1178 | 'function', | 1178 | 'function', |
| @@ -1221,10 +1221,11 @@ sub save_struct_actual($) { | |||
| 1221 | $struct_actual = $struct_actual . $actual . " "; | 1221 | $struct_actual = $struct_actual . $actual . " "; |
| 1222 | } | 1222 | } |
| 1223 | 1223 | ||
| 1224 | sub create_parameterlist($$$) { | 1224 | sub create_parameterlist($$$$) { |
| 1225 | my $args = shift; | 1225 | my $args = shift; |
| 1226 | my $splitter = shift; | 1226 | my $splitter = shift; |
| 1227 | my $file = shift; | 1227 | my $file = shift; |
| 1228 | my $declaration_name = shift; | ||
| 1228 | my $type; | 1229 | my $type; |
| 1229 | my $param; | 1230 | my $param; |
| 1230 | 1231 | ||
| @@ -1254,7 +1255,7 @@ sub create_parameterlist($$$) { | |||
| 1254 | $type = $arg; | 1255 | $type = $arg; |
| 1255 | $type =~ s/([^\(]+\(\*?)\s*$param/$1/; | 1256 | $type =~ s/([^\(]+\(\*?)\s*$param/$1/; |
| 1256 | save_struct_actual($param); | 1257 | save_struct_actual($param); |
| 1257 | push_parameter($param, $type, $file); | 1258 | push_parameter($param, $type, $file, $declaration_name); |
| 1258 | } elsif ($arg) { | 1259 | } elsif ($arg) { |
| 1259 | $arg =~ s/\s*:\s*/:/g; | 1260 | $arg =~ s/\s*:\s*/:/g; |
| 1260 | $arg =~ s/\s*\[/\[/g; | 1261 | $arg =~ s/\s*\[/\[/g; |
| @@ -1279,27 +1280,28 @@ sub create_parameterlist($$$) { | |||
| 1279 | foreach $param (@args) { | 1280 | foreach $param (@args) { |
| 1280 | if ($param =~ m/^(\*+)\s*(.*)/) { | 1281 | if ($param =~ m/^(\*+)\s*(.*)/) { |
| 1281 | save_struct_actual($2); | 1282 | save_struct_actual($2); |
| 1282 | push_parameter($2, "$type $1", $file); | 1283 | push_parameter($2, "$type $1", $file, $declaration_name); |
| 1283 | } | 1284 | } |
| 1284 | elsif ($param =~ m/(.*?):(\d+)/) { | 1285 | elsif ($param =~ m/(.*?):(\d+)/) { |
| 1285 | if ($type ne "") { # skip unnamed bit-fields | 1286 | if ($type ne "") { # skip unnamed bit-fields |
| 1286 | save_struct_actual($1); | 1287 | save_struct_actual($1); |
| 1287 | push_parameter($1, "$type:$2", $file) | 1288 | push_parameter($1, "$type:$2", $file, $declaration_name) |
| 1288 | } | 1289 | } |
| 1289 | } | 1290 | } |
| 1290 | else { | 1291 | else { |
| 1291 | save_struct_actual($param); | 1292 | save_struct_actual($param); |
| 1292 | push_parameter($param, $type, $file); | 1293 | push_parameter($param, $type, $file, $declaration_name); |
| 1293 | } | 1294 | } |
| 1294 | } | 1295 | } |
| 1295 | } | 1296 | } |
| 1296 | } | 1297 | } |
| 1297 | } | 1298 | } |
| 1298 | 1299 | ||
| 1299 | sub push_parameter($$$) { | 1300 | sub push_parameter($$$$) { |
| 1300 | my $param = shift; | 1301 | my $param = shift; |
| 1301 | my $type = shift; | 1302 | my $type = shift; |
| 1302 | my $file = shift; | 1303 | my $file = shift; |
| 1304 | my $declaration_name = shift; | ||
| 1303 | 1305 | ||
| 1304 | if (($anon_struct_union == 1) && ($type eq "") && | 1306 | if (($anon_struct_union == 1) && ($type eq "") && |
| 1305 | ($param eq "}")) { | 1307 | ($param eq "}")) { |
| @@ -1336,21 +1338,13 @@ sub push_parameter($$$) { | |||
| 1336 | # warn if parameter has no description | 1338 | # warn if parameter has no description |
| 1337 | # (but ignore ones starting with # as these are not parameters | 1339 | # (but ignore ones starting with # as these are not parameters |
| 1338 | # but inline preprocessor statements); | 1340 | # but inline preprocessor statements); |
| 1339 | # also ignore unnamed structs/unions; | 1341 | # Note: It will also ignore void params and unnamed structs/unions |
| 1340 | if (!$anon_struct_union) { | ||
| 1341 | if (!defined $parameterdescs{$param} && $param !~ /^#/) { | 1342 | if (!defined $parameterdescs{$param} && $param !~ /^#/) { |
| 1343 | $parameterdescs{$param} = $undescribed; | ||
| 1342 | 1344 | ||
| 1343 | $parameterdescs{$param} = $undescribed; | 1345 | print STDERR |
| 1344 | 1346 | "${file}:$.: warning: Function parameter or member '$param' not described in '$declaration_name'\n"; | |
| 1345 | if (($type eq 'function') || ($type eq 'enum')) { | 1347 | ++$warnings; |
| 1346 | print STDERR "${file}:$.: warning: Function parameter ". | ||
| 1347 | "or member '$param' not " . | ||
| 1348 | "described in '$declaration_name'\n"; | ||
| 1349 | } | ||
| 1350 | print STDERR "${file}:$.: warning:" . | ||
| 1351 | " No description found for parameter '$param'\n"; | ||
| 1352 | ++$warnings; | ||
| 1353 | } | ||
| 1354 | } | 1348 | } |
| 1355 | 1349 | ||
| 1356 | $param = xml_escape($param); | 1350 | $param = xml_escape($param); |
| @@ -1507,7 +1501,7 @@ sub dump_function($$) { | |||
| 1507 | $declaration_name = $2; | 1501 | $declaration_name = $2; |
| 1508 | my $args = $3; | 1502 | my $args = $3; |
| 1509 | 1503 | ||
| 1510 | create_parameterlist($args, ',', $file); | 1504 | create_parameterlist($args, ',', $file, $declaration_name); |
| 1511 | } else { | 1505 | } else { |
| 1512 | print STDERR "${file}:$.: warning: cannot understand function prototype: '$prototype'\n"; | 1506 | print STDERR "${file}:$.: warning: cannot understand function prototype: '$prototype'\n"; |
| 1513 | return; | 1507 | return; |
