Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Mauro Carvalho Chehab and committed by
Jonathan Corbet
151c468b 1081de2d

+16 -22
+16 -22
scripts/kernel-doc
··· 1063 1063 # Ignore other nested elements, like enums 1064 1064 $members =~ s/({[^\{\}]*})//g; 1065 1065 1066 - create_parameterlist($members, ';', $file); 1066 + create_parameterlist($members, ';', $file, $declaration_name); 1067 1067 check_sections($file, $declaration_name, $decl_type, $sectcheck, $struct_actual); 1068 1068 1069 1069 # Adjust declaration for better display ··· 1172 1172 $declaration_name = $2; 1173 1173 my $args = $3; 1174 1174 1175 - create_parameterlist($args, ',', $file); 1175 + create_parameterlist($args, ',', $file, $declaration_name); 1176 1176 1177 1177 output_declaration($declaration_name, 1178 1178 'function', ··· 1221 1221 $struct_actual = $struct_actual . $actual . " "; 1222 1222 } 1223 1223 1224 - sub create_parameterlist($$$) { 1224 + sub create_parameterlist($$$$) { 1225 1225 my $args = shift; 1226 1226 my $splitter = shift; 1227 1227 my $file = shift; 1228 + my $declaration_name = shift; 1228 1229 my $type; 1229 1230 my $param; 1230 1231 ··· 1255 1254 $type = $arg; 1256 1255 $type =~ s/([^\(]+\(\*?)\s*$param/$1/; 1257 1256 save_struct_actual($param); 1258 - push_parameter($param, $type, $file); 1257 + push_parameter($param, $type, $file, $declaration_name); 1259 1258 } elsif ($arg) { 1260 1259 $arg =~ s/\s*:\s*/:/g; 1261 1260 $arg =~ s/\s*\[/\[/g; ··· 1280 1279 foreach $param (@args) { 1281 1280 if ($param =~ m/^(\*+)\s*(.*)/) { 1282 1281 save_struct_actual($2); 1283 - push_parameter($2, "$type $1", $file); 1282 + push_parameter($2, "$type $1", $file, $declaration_name); 1284 1283 } 1285 1284 elsif ($param =~ m/(.*?):(\d+)/) { 1286 1285 if ($type ne "") { # skip unnamed bit-fields 1287 1286 save_struct_actual($1); 1288 - push_parameter($1, "$type:$2", $file) 1287 + push_parameter($1, "$type:$2", $file, $declaration_name) 1289 1288 } 1290 1289 } 1291 1290 else { 1292 1291 save_struct_actual($param); 1293 - push_parameter($param, $type, $file); 1292 + push_parameter($param, $type, $file, $declaration_name); 1294 1293 } 1295 1294 } 1296 1295 } 1297 1296 } 1298 1297 } 1299 1298 1300 - sub push_parameter($$$) { 1299 + sub push_parameter($$$$) { 1301 1300 my $param = shift; 1302 1301 my $type = shift; 1303 1302 my $file = shift; 1303 + my $declaration_name = shift; 1304 1304 1305 1305 if (($anon_struct_union == 1) && ($type eq "") && 1306 1306 ($param eq "}")) { ··· 1338 1336 # warn if parameter has no description 1339 1337 # (but ignore ones starting with # as these are not parameters 1340 1338 # but inline preprocessor statements); 1341 - # also ignore unnamed structs/unions; 1342 - if (!$anon_struct_union) { 1339 + # Note: It will also ignore void params and unnamed structs/unions 1343 1340 if (!defined $parameterdescs{$param} && $param !~ /^#/) { 1341 + $parameterdescs{$param} = $undescribed; 1344 1342 1345 - $parameterdescs{$param} = $undescribed; 1346 - 1347 - if (($type eq 'function') || ($type eq 'enum')) { 1348 - print STDERR "${file}:$.: warning: Function parameter ". 1349 - "or member '$param' not " . 1350 - "described in '$declaration_name'\n"; 1351 - } 1352 - print STDERR "${file}:$.: warning:" . 1353 - " No description found for parameter '$param'\n"; 1354 - ++$warnings; 1355 - } 1343 + print STDERR 1344 + "${file}:$.: warning: Function parameter or member '$param' not described in '$declaration_name'\n"; 1345 + ++$warnings; 1356 1346 } 1357 1347 1358 1348 $param = xml_escape($param); ··· 1501 1507 $declaration_name = $2; 1502 1508 my $args = $3; 1503 1509 1504 - create_parameterlist($args, ',', $file); 1510 + create_parameterlist($args, ',', $file, $declaration_name); 1505 1511 } else { 1506 1512 print STDERR "${file}:$.: warning: cannot understand function prototype: '$prototype'\n"; 1507 1513 return;