]> git.proxmox.com Git - mirror_qemu.git/commit - scripts/checkpatch.pl
checkpatch: handle token pasting better
authorPaolo Bonzini <pbonzini@redhat.com>
Wed, 4 Jul 2018 16:05:43 +0000 (18:05 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 6 Jul 2018 16:39:19 +0000 (18:39 +0200)
commite20122ff0faf07cb701d35e39e106d1783c07725
treefa492a77218e6cbba2932d04bef07a2dbefaedbb
parent960a479f7f94bb615991d41b8c5ff4e3c7d0088d
checkpatch: handle token pasting better

The mechanism to find possible type tokens can sometimes be confused and go into an
infinite loop.  This happens for example in QEMU for a line that looks like

         uint## BITS ##_t S = _S, T = _T;                            \
         uint## BITS ##_t as, at, xs, xt, xd;                        \

Because the token pasting operator does not have a space before _t, it does not
match $notPermitted.  However, (?x) is turned on in the regular expression for
modifiers, and thus ##_t matches the empty string.  As a result, annotate_values
goes in an infinite loop.

The solution is simply to remove token pasting operators from the string before
looking for modifiers.  In the example above, the string uintBITS_t will be
evaluated as a candidate modifier.  This is not optimal, but it works as long
as people do not write things like a##s##m, and it fits nicely into sub
possible.

For a similar reason, \# should be rejected always, even if it is not
at end of line or followed by whitespace.

The same patch was sent to the Linux kernel mailing list.

Reported-by: Aleksandar Markovic <amarkovic@wavecomp.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
scripts/checkpatch.pl