[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 23/29] scripts: kernel-doc: fix line number handling
From: |
Paolo Bonzini |
Subject: |
[PATCH 23/29] scripts: kernel-doc: fix line number handling |
Date: |
Tue, 17 Nov 2020 17:53:06 +0100 |
From: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Address several issues related to pointing to the wrong line
number:
1) ensure that line numbers will always be initialized
When section is the default (Description), the line number
is not initializing, producing this:
$ ./scripts/kernel-doc --enable-lineno
./drivers/media/v4l2-core/v4l2-mem2mem.c|less
**Description**
#define LINENO 0
In case of streamoff or release called on any context,
1] If the context is currently running, then abort job will be called
2] If the context is queued, then the context will be removed from
the job_queue
Which is not right. Ensure that the line number will always
be there. After applied, the result now points to the right location:
**Description**
#define LINENO 410
In case of streamoff or release called on any context,
1] If the context is currently running, then abort job will be called
2] If the context is queued, then the context will be removed from
the job_queue
2) The line numbers for function prototypes are always + 1,
because it is taken at the line after handling the prototype.
Change the logic to point to the next line after the /** */
block;
3) The "DOC:" line number should point to the same line as this
markup is found, and not to the next one.
Probably part of the issues were due to a but that was causing
the line number offset to be incremented by one, if --export
were used.
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
scripts/kernel-doc | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 667ad3169c..98752164eb 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -1705,7 +1705,7 @@ sub dump_function($$) {
my $file = shift;
my $noret = 0;
- print_lineno($.);
+ print_lineno($new_start_line);
$prototype =~ s/^static +//;
$prototype =~ s/^extern +//;
@@ -2033,7 +2033,7 @@ sub process_name($$) {
if (/$doc_block/o) {
$state = STATE_DOCBLOCK;
$contents = "";
- $new_start_line = $. + 1;
+ $new_start_line = $.;
if ( $1 eq "" ) {
$section = $section_intro;
@@ -2116,6 +2116,7 @@ sub process_body($$) {
if ($state == STATE_BODY_WITH_BLANK_LINE && /^\s*\*\s?\S/) {
dump_section($file, $section, $contents);
$section = $section_default;
+ $new_start_line = $.;
$contents = "";
}
@@ -2171,6 +2172,7 @@ sub process_body($$) {
$prototype = "";
$state = STATE_PROTO;
$brcount = 0;
+ $new_start_line = $. + 1;
} elsif (/$doc_content/) {
if ($1 eq "") {
if ($section eq $section_context) {
--
2.28.0
- [PATCH 14/29] Revert "scripts/kerneldoc: For Sphinx 3 use c:macro for macros with arguments", (continued)
- [PATCH 14/29] Revert "scripts/kerneldoc: For Sphinx 3 use c:macro for macros with arguments", Paolo Bonzini, 2020/11/17
- [PATCH 15/29] Revert "kernel-doc: Use c:struct for Sphinx 3.0 and later", Paolo Bonzini, 2020/11/17
- [PATCH 16/29] scripts: kernel-doc: make it more compatible with Sphinx 3.x, Paolo Bonzini, 2020/11/17
- [PATCH 18/29] scripts: kernel-doc: fix troubles with line counts, Paolo Bonzini, 2020/11/17
- [PATCH 17/29] scripts: kernel-doc: use a less pedantic markup for funcs on Sphinx 3.x, Paolo Bonzini, 2020/11/17
- [PATCH 19/29] scripts: kernel-doc: reimplement -nofunction argument, Paolo Bonzini, 2020/11/17
- [PATCH 20/29] scripts: kernel-doc: fix typedef identification, Paolo Bonzini, 2020/11/17
- [PATCH 25/29] Revert "kernel-doc: Handle function typedefs without asterisks", Paolo Bonzini, 2020/11/17
- [PATCH 21/29] scripts: kernel-doc: don't mangle with parameter list, Paolo Bonzini, 2020/11/17
- [PATCH 22/29] scripts: kernel-doc: allow passing desired Sphinx C domain dialect, Paolo Bonzini, 2020/11/17
- [PATCH 23/29] scripts: kernel-doc: fix line number handling,
Paolo Bonzini <=
- [PATCH 24/29] scripts: kernel-doc: try to use c:function if possible, Paolo Bonzini, 2020/11/17
- [PATCH 26/29] Revert "kernel-doc: Handle function typedefs that return pointers", Paolo Bonzini, 2020/11/17
- [PATCH 27/29] scripts: kernel-doc: fix typedef parsing, Paolo Bonzini, 2020/11/17
- [PATCH 29/29] scripts: kernel-doc: use :c:union when needed, Paolo Bonzini, 2020/11/17
- [PATCH 28/29] scripts: kernel-doc: split typedef complex regex, Paolo Bonzini, 2020/11/17
- Re: [RFC PATCH 00/29] kernel-doc: update from Linux 5.10, Peter Maydell, 2020/11/30