[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 103/113] scripts: kernel-doc: don't mangle with parameter list
From: |
Paolo Bonzini |
Subject: |
[PULL 103/113] scripts: kernel-doc: don't mangle with parameter list |
Date: |
Wed, 2 Dec 2020 03:08:39 -0500 |
From: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
While kernel-doc needs to parse parameters in order to
identify its name, it shouldn't be touching the type,
as parsing it is very difficult, and errors happen.
One current error is when parsing this parameter:
const u32 (*tab)[256]
Found at ./lib/crc32.c, on this function:
u32 __pure crc32_be_generic (u32 crc, unsigned char const *p, size_t
len, const u32 (*tab)[256], u32 polynomial);
The current logic mangles it, producing this output:
const u32 ( *tab
That's something that it is not recognizeable.
So, instead, let's push the argument as-is, and use it
when printing the function prototype and when describing
each argument.
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20201117165312.118257-22-pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
scripts/kernel-doc | 26 ++++++++++++++------------
1 file changed, 14 insertions(+), 12 deletions(-)
diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 0c31e9ad66..478037f736 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -655,10 +655,10 @@ sub output_function_man(%) {
$type = $args{'parametertypes'}{$parameter};
if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) {
# pointer-to-function
- print ".BI \"" . $parenth . $1 . "\" " . $parameter . " \") (" . $2
. ")" . $post . "\"\n";
+ print ".BI \"" . $parenth . $1 . "\" " . " \") (" . $2 . ")" .
$post . "\"\n";
} else {
$type =~ s/([^\*])$/$1 /;
- print ".BI \"" . $parenth . $type . "\" " . $parameter . " \"" .
$post . "\"\n";
+ print ".BI \"" . $parenth . $type . "\" " . " \"" . $post . "\"\n";
}
$count++;
$parenth = "";
@@ -929,7 +929,7 @@ sub output_function_rst(%) {
# pointer-to-function
print $1 . $parameter . ") (" . $2 . ")";
} else {
- print $type . " " . $parameter;
+ print $type;
}
}
if ($args{'typedef'}) {
@@ -954,7 +954,7 @@ sub output_function_rst(%) {
$type = $args{'parametertypes'}{$parameter};
if ($type ne "") {
- print "``$type $parameter``\n";
+ print "``$type``\n";
} else {
print "``$parameter``\n";
}
@@ -1479,7 +1479,7 @@ sub create_parameterlist($$$$) {
# Treat preprocessor directive as a typeless variable just to fill
# corresponding data structures "correctly". Catch it later in
# output_* subs.
- push_parameter($arg, "", $file);
+ push_parameter($arg, "", "", $file);
} elsif ($arg =~ m/\(.+\)\s*\(/) {
# pointer-to-function
$arg =~ tr/#/,/;
@@ -1488,7 +1488,7 @@ sub create_parameterlist($$$$) {
$type = $arg;
$type =~ s/([^\(]+\(\*?)\s*$param/$1/;
save_struct_actual($param);
- push_parameter($param, $type, $file, $declaration_name);
+ push_parameter($param, $type, $arg, $file, $declaration_name);
} elsif ($arg) {
$arg =~ s/\s*:\s*/:/g;
$arg =~ s/\s*\[/\[/g;
@@ -1513,26 +1513,28 @@ sub create_parameterlist($$$$) {
foreach $param (@args) {
if ($param =~ m/^(\*+)\s*(.*)/) {
save_struct_actual($2);
- push_parameter($2, "$type $1", $file, $declaration_name);
+
+ push_parameter($2, "$type $1", $arg, $file,
$declaration_name);
}
elsif ($param =~ m/(.*?):(\d+)/) {
if ($type ne "") { # skip unnamed bit-fields
save_struct_actual($1);
- push_parameter($1, "$type:$2", $file, $declaration_name)
+ push_parameter($1, "$type:$2", $arg, $file,
$declaration_name)
}
}
else {
save_struct_actual($param);
- push_parameter($param, $type, $file, $declaration_name);
+ push_parameter($param, $type, $arg, $file,
$declaration_name);
}
}
}
}
}
-sub push_parameter($$$$) {
+sub push_parameter($$$$$) {
my $param = shift;
my $type = shift;
+ my $org_arg = shift;
my $file = shift;
my $declaration_name = shift;
@@ -1596,8 +1598,8 @@ sub push_parameter($$$$) {
# "[blah" in a parameter string;
###$param =~ s/\s*//g;
push @parameterlist, $param;
- $type =~ s/\s\s+/ /g;
- $parametertypes{$param} = $type;
+ $org_arg =~ s/\s\s+/ /g;
+ $parametertypes{$param} = $org_arg;
}
sub check_sections($$$$$) {
--
2.26.2
- [PULL 105/113] scripts: kernel-doc: fix line number handling, (continued)
- [PULL 105/113] scripts: kernel-doc: fix line number handling, Paolo Bonzini, 2020/12/02
- [PULL 113/113] scripts: kernel-doc: remove unnecesssary change wrt Linux, Paolo Bonzini, 2020/12/02
- [PULL 111/113] scripts: kernel-doc: use :c:union when needed, Paolo Bonzini, 2020/12/02
- [PULL 099/113] scripts: kernel-doc: use a less pedantic markup for funcs on Sphinx 3.x, Paolo Bonzini, 2020/12/02
- [PULL 065/113] vl: move CHECKPOINT_INIT after preconfig, Paolo Bonzini, 2020/12/02
- [PULL 091/113] scripts/kernel-doc: handle function pointer prototypes, Paolo Bonzini, 2020/12/02
- [PULL 101/113] scripts: kernel-doc: reimplement -nofunction argument, Paolo Bonzini, 2020/12/02
- [PULL 100/113] scripts: kernel-doc: fix troubles with line counts, Paolo Bonzini, 2020/12/02
- [PULL 109/113] scripts: kernel-doc: fix typedef parsing, Paolo Bonzini, 2020/12/02
- [PULL 108/113] Revert "kernel-doc: Handle function typedefs that return pointers", Paolo Bonzini, 2020/12/02
- [PULL 103/113] scripts: kernel-doc: don't mangle with parameter list,
Paolo Bonzini <=
- [PULL 112/113] Revert "docs: temporarily disable the kernel-doc extension", Paolo Bonzini, 2020/12/02
- [PULL 110/113] scripts: kernel-doc: split typedef complex regex, Paolo Bonzini, 2020/12/02
- Re: [PULL 000/113] First batch of misc (i386, kernel-doc, memory, vl.c) changes for QEMU 6.0, no-reply, 2020/12/02
- Re: [PULL 000/113] First batch of misc (i386, kernel-doc, memory, vl.c) changes for QEMU 6.0, Peter Maydell, 2020/12/09