Skip to content

Commit

Permalink
docs: scripts/kernel-doc: Detect absence of FILE arg
Browse files Browse the repository at this point in the history
Currently, when there is no FILE argument following a switch such
as -man, -rst, or -none, kernel-doc exits with a warning from perl
(long msg folded):

    Use of uninitialized value $ARGV[0] in pattern match (m//)
    at ./scripts/kernel-doc line 438.

, which is unhelpful.

Improve the behavior by adding a check at the bottom of parsing
loop.
If the argument is absent, display help text and exit with
the code of 1 (via usage()).

Signed-off-by: Akira Yokosawa <akiyks@gmail.com>
Cc: Randy Dunlap <rdunlap@infradead.org>
Link: https://lore.kernel.org/r/7b136049-a3ba-0eb5-8717-364d773ff914@gmail.com
[jc: reworked to fix conflict with pod patches]
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
  • Loading branch information
Akira Yokosawa authored and Jonathan Corbet committed Feb 24, 2022
1 parent 2b306ec commit e334f87
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions scripts/kernel-doc
Original file line number Diff line number Diff line change
Expand Up @@ -343,14 +343,23 @@ while ($ARGV[0] =~ m/^--?(.*)/) {
die "Sphinx version should either major.minor or major.minor.patch format\n";
}
} else {
# Unknown argument
pod2usage(
-message => "Argument unknown!\n",
-exitval => 1,
-verbose => 99,
-sections => 'SYNOPSIS',
-output => \*STDERR,
);
# Unknown argument
pod2usage(
-message => "Argument unknown!\n",
-exitval => 1,
-verbose => 99,
-sections => 'SYNOPSIS',
-output => \*STDERR,
);
}
if ($#ARGV < 0){
pod2usage(
-message => "FILE argument missing\n",
-exitval => 1,
-verbose => 99,
-sections => 'SYNOPSIS',
-output => \*STDERR,
);
}
}

Expand Down

0 comments on commit e334f87

Please sign in to comment.