Skip to content

Commit

Permalink
kernel-doc parser mishandles declarations split into lines
Browse files Browse the repository at this point in the history
Reported by Johannes Berg [1].  Problem here: function
process_proto_type() concatenates the striped lines of declaration
without any whitespace. A one-liner of::

 struct something {
       struct foo
       bar;
       };

has to be::

 struct something {struct foo bar;};

Without the patching process_proto_type(), the result missed the space
between 'foo' and 'bar'::

 struct something {struct foobar;};

Bugfix of process_proto_type() brings next error when blank lines
between enum declaration::

 warning: Enum value ' ' not described in enum 'foo'

Problem here: dump_enum() does not strip leading whitespaces from
the concatenated string (with the new additional space from
process_proto_type).

[1] https://www.mail-archive.com/[email protected]/msg12410.html

Signed-off-by: Markus Heiser <[email protected]>
Signed-off-by: Jonathan Corbet <[email protected]>
  • Loading branch information
return42 authored and Jonathan Corbet committed Aug 30, 2017
1 parent 33c2f4e commit 463a0fd
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions scripts/kernel-doc
Original file line number Diff line number Diff line change
Expand Up @@ -2226,6 +2226,7 @@ sub dump_enum($$) {
if ($x =~ /enum\s+(\w+)\s*{(.*)}/) {
$declaration_name = $1;
my $members = $2;
$members =~ s/\s+$//;

foreach my $arg (split ',', $members) {
$arg =~ s/^\s*(\w+).*/$1/;
Expand Down Expand Up @@ -2766,6 +2767,9 @@ sub process_proto_type($$) {

while (1) {
if ( $x =~ /([^{};]*)([{};])(.*)/ ) {
if( length $prototype ) {
$prototype .= " "
}
$prototype .= $1 . $2;
($2 eq '{') && $brcount++;
($2 eq '}') && $brcount--;
Expand Down

0 comments on commit 463a0fd

Please sign in to comment.