Skip to content

Commit 151c468

Browse files
mchehabJonathan Corbet
authored andcommitted
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 <[email protected]> Signed-off-by: Jonathan Corbet <[email protected]>
1 parent 1081de2 commit 151c468

File tree

1 file changed

+16
-22
lines changed

1 file changed

+16
-22
lines changed

scripts/kernel-doc

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,7 +1063,7 @@ sub dump_struct($$) {
10631063
# Ignore other nested elements, like enums
10641064
$members =~ s/({[^\{\}]*})//g;
10651065

1066-
create_parameterlist($members, ';', $file);
1066+
create_parameterlist($members, ';', $file, $declaration_name);
10671067
check_sections($file, $declaration_name, $decl_type, $sectcheck, $struct_actual);
10681068

10691069
# Adjust declaration for better display
@@ -1172,7 +1172,7 @@ sub dump_typedef($$) {
11721172
$declaration_name = $2;
11731173
my $args = $3;
11741174

1175-
create_parameterlist($args, ',', $file);
1175+
create_parameterlist($args, ',', $file, $declaration_name);
11761176

11771177
output_declaration($declaration_name,
11781178
'function',
@@ -1221,10 +1221,11 @@ sub save_struct_actual($) {
12211221
$struct_actual = $struct_actual . $actual . " ";
12221222
}
12231223

1224-
sub create_parameterlist($$$) {
1224+
sub create_parameterlist($$$$) {
12251225
my $args = shift;
12261226
my $splitter = shift;
12271227
my $file = shift;
1228+
my $declaration_name = shift;
12281229
my $type;
12291230
my $param;
12301231

@@ -1254,7 +1255,7 @@ sub create_parameterlist($$$) {
12541255
$type = $arg;
12551256
$type =~ s/([^\(]+\(\*?)\s*$param/$1/;
12561257
save_struct_actual($param);
1257-
push_parameter($param, $type, $file);
1258+
push_parameter($param, $type, $file, $declaration_name);
12581259
} elsif ($arg) {
12591260
$arg =~ s/\s*:\s*/:/g;
12601261
$arg =~ s/\s*\[/\[/g;
@@ -1279,27 +1280,28 @@ sub create_parameterlist($$$) {
12791280
foreach $param (@args) {
12801281
if ($param =~ m/^(\*+)\s*(.*)/) {
12811282
save_struct_actual($2);
1282-
push_parameter($2, "$type $1", $file);
1283+
push_parameter($2, "$type $1", $file, $declaration_name);
12831284
}
12841285
elsif ($param =~ m/(.*?):(\d+)/) {
12851286
if ($type ne "") { # skip unnamed bit-fields
12861287
save_struct_actual($1);
1287-
push_parameter($1, "$type:$2", $file)
1288+
push_parameter($1, "$type:$2", $file, $declaration_name)
12881289
}
12891290
}
12901291
else {
12911292
save_struct_actual($param);
1292-
push_parameter($param, $type, $file);
1293+
push_parameter($param, $type, $file, $declaration_name);
12931294
}
12941295
}
12951296
}
12961297
}
12971298
}
12981299

1299-
sub push_parameter($$$) {
1300+
sub push_parameter($$$$) {
13001301
my $param = shift;
13011302
my $type = shift;
13021303
my $file = shift;
1304+
my $declaration_name = shift;
13031305

13041306
if (($anon_struct_union == 1) && ($type eq "") &&
13051307
($param eq "}")) {
@@ -1336,21 +1338,13 @@ sub push_parameter($$$) {
13361338
# warn if parameter has no description
13371339
# (but ignore ones starting with # as these are not parameters
13381340
# but inline preprocessor statements);
1339-
# also ignore unnamed structs/unions;
1340-
if (!$anon_struct_union) {
1341+
# Note: It will also ignore void params and unnamed structs/unions
13411342
if (!defined $parameterdescs{$param} && $param !~ /^#/) {
1343+
$parameterdescs{$param} = $undescribed;
13421344

1343-
$parameterdescs{$param} = $undescribed;
1344-
1345-
if (($type eq 'function') || ($type eq 'enum')) {
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-
}
1345+
print STDERR
1346+
"${file}:$.: warning: Function parameter or member '$param' not described in '$declaration_name'\n";
1347+
++$warnings;
13541348
}
13551349

13561350
$param = xml_escape($param);
@@ -1507,7 +1501,7 @@ sub dump_function($$) {
15071501
$declaration_name = $2;
15081502
my $args = $3;
15091503

1510-
create_parameterlist($args, ',', $file);
1504+
create_parameterlist($args, ',', $file, $declaration_name);
15111505
} else {
15121506
print STDERR "${file}:$.: warning: cannot understand function prototype: '$prototype'\n";
15131507
return;

0 commit comments

Comments
 (0)