diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2025-08-19 12:56:48 +0100 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2025-08-30 16:37:23 +0100 |
commit | 5ffd387e9e0f787744fadaad35e1bf92224b0642 (patch) | |
tree | 0500a23bbc53e760bb2ce49659e7bcb422a25728 | |
parent | 36bc78aca83cfd3c8f73cbcb428bc7f0ce7a4a61 (diff) | |
download | qemu-5ffd387e9e0f787744fadaad35e1bf92224b0642.zip qemu-5ffd387e9e0f787744fadaad35e1bf92224b0642.tar.gz qemu-5ffd387e9e0f787744fadaad35e1bf92224b0642.tar.bz2 |
scripts/kernel-doc: Avoid new Perl precedence warning
Newer versions of Perl (5.41.x and up) emit a warning for code in
kernel-doc:
Possible precedence problem between ! and pattern match (m//) at /scripts/kernel-doc line 1597.
This is because the code does:
if (!$param =~ /\w\.\.\.$/) {
In Perl, the ! operator has higher precedence than the =~
pattern-match binding, so the effect of this condition is to first
logically-negate the string $param into a true-or-false value and
then try to pattern match it against the regex, which in this case
will always fail. This is almost certainly not what the author
intended.
In the new Python version of kernel-doc in the Linux kernel,
the equivalent code is written:
if KernRe(r'\w\.\.\.$').search(param):
# For named variable parameters of the form `x...`,
# remove the dots
param = param[:-3]
else:
# Handles unnamed variable parameters
param = "..."
which is a more sensible way of writing the behaviour you would
get if you put in brackets to make the regex match first and
then negate the result.
Take this as the intended behaviour, and update the Perl to match.
For QEMU, this produces no change in output, presumably because we
never used the "unnamed variable parameters" syntax.
Cc: qemu-stable@nongnu.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Message-id: 20250819115648.2125709-1-peter.maydell@linaro.org
-rwxr-xr-x | scripts/kernel-doc | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/scripts/kernel-doc b/scripts/kernel-doc index fec83f5..117ec8f 100755 --- a/scripts/kernel-doc +++ b/scripts/kernel-doc @@ -1594,13 +1594,12 @@ sub push_parameter($$$$$) { if ($type eq "" && $param =~ /\.\.\.$/) { - if (!$param =~ /\w\.\.\.$/) { - # handles unnamed variable parameters - $param = "..."; - } - elsif ($param =~ /\w\.\.\.$/) { + if ($param =~ /\w\.\.\.$/) { # for named variable parameters of the form `x...`, remove the dots $param =~ s/\.\.\.$//; + } else { + # handles unnamed variable parameters + $param = "..."; } if (!defined $parameterdescs{$param} || $parameterdescs{$param} eq "") { $parameterdescs{$param} = "variable arguments"; |