Skip to contentSkip to conversation

docs: scripts/kernel-doc: Detect absence of FILE arg

PATCH In review Akira Yokosawa 2 participants 2 messages Feb 24, 2022 Documentation

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 docs: scripts/kernel-doc: Detect absence of FILE arg

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()).

---
Changes since v1 [1]:
- No code change
- Amend subject and reword the whole changelog.
- The message from perl is not an error but a warning. (I thank Tomasz for pointing it out.)

I thought the change of exit code might affect sphinx-build processing, and tested with several runs of "make htmldocs" and "make pdfdocs". So far, I've not seen any regression.

[1] v1: https://lore.kernel.org/r/[email protected]

Thanks, Akira
--

 scripts/kernel-doc | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
scripts/kernel-doc +5 -1
index 3106b7536b89..faefe2977f0e 100755
@@ -494,7 +494,11 @@ while ($ARGV[0] =~ m/^--?(.*)/) {
 	}
     } else {
 	# Unknown argument
-        usage();
+	usage();
+    }
+    if ($#ARGV < 0){
+	print "No FILE!\n";
+	usage();
     }
 }
 

base-commit: b62ef3a1cca0553613adce16515f3640400725b4

Signature · 1 line
2.17.1
maintainer
#1 lore raw
Quoted 7 lines · Akira Yokosawa

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.

Quoted 6 lines

, 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()).

As might be expected, this applied poorly after the pod patches went in. I went ahead and resolved the conflict, substituting an appropriate pod2usage() call.

Thanks,

jon