Skip to content

Commit 5ef09c9

Browse files
committed
scripts: kernel-doc: fix line number handling
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>
1 parent 93351d4 commit 5ef09c9

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

‎scripts/kernel-doc‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1705,7 +1705,7 @@ sub dump_function($$) {
17051705
my $file = shift;
17061706
my $noret = 0;
17071707

1708-
print_lineno($.);
1708+
print_lineno($new_start_line);
17091709

17101710
$prototype =~ s/^static +//;
17111711
$prototype =~ s/^extern +//;
@@ -2033,7 +2033,7 @@ sub process_name($$) {
20332033
if (/$doc_block/o) {
20342034
$state = STATE_DOCBLOCK;
20352035
$contents = "";
2036-
$new_start_line = $. + 1;
2036+
$new_start_line = $.;
20372037

20382038
if ( $1 eq "" ) {
20392039
$section = $section_intro;
@@ -2116,6 +2116,7 @@ sub process_body($$) {
21162116
if ($state == STATE_BODY_WITH_BLANK_LINE && /^\s*\*\s?\S/) {
21172117
dump_section($file, $section, $contents);
21182118
$section = $section_default;
2119+
$new_start_line = $.;
21192120
$contents = "";
21202121
}
21212122

@@ -2171,6 +2172,7 @@ sub process_body($$) {
21712172
$prototype = "";
21722173
$state = STATE_PROTO;
21732174
$brcount = 0;
2175+
$new_start_line = $. + 1;
21742176
} elsif (/$doc_content/) {
21752177
if ($1 eq "") {
21762178
if ($section eq $section_context) {

0 commit comments

Comments
 (0)