Thread (12 messages) 12 messages, 5 authors, 2019-08-31

Re: [PATCH v3 01/11] checkpatch: check for nested (un)?likely() calls

From: Denis Efremov <efremov@linux.com>
Date: 2019-08-31 17:07:48
Also in: dri-devel, linux-arm-msm, linux-fsdevel, linux-rdma, linux-xfs, lkml, netdev, xen-devel


On 31.08.2019 19:45, Markus Elfring wrote:
quoted
quoted
quoted
+# nested likely/unlikely calls
+        if ($line =~ /\b(?:(?:un)?likely)\s*\(\s*!?\s*(IS_ERR(?:_OR_NULL|_VALUE)?|WARN)/) {
+            WARN("LIKELY_MISUSE",
How do you think about to use the specification “(?:IS_ERR(?:_(?:OR_NULL|VALUE))?|WARN)”
in this regular expression?
quoted
   IS_ERR
   (?:_ <- Another atomic group just to show that '_' is a common prefix?
Yes. - I hope that this specification detail can help a bit.
I'm not sure that another pair of brackets for a single char worth it.
quoted
           Usually, Perl interpreter is very good at optimizing such things.
The interpreter optimizes it internally:
echo 'IS_ERR_OR_NULL' | perl -Mre=debug -ne '/IS_ERR(?:_OR_NULL|_VALUE)?/ && print'
Compiling REx "IS_ERR(?:_OR_NULL|_VALUE)?"
Final program:
   1: EXACT <IS_ERR> (4)
   4: CURLYX[0]{0,1} (16)
   6:   EXACT <_> (8)      <-- common prefix
   8:   TRIE-EXACT[OV] (15)
        <OR_NULL> 
        <VALUE>
...
Would you like to help this software component by omitting a pair of
non-capturing parentheses at the beginning?

\b(?:un)?likely\s*
This pair of brackets is required to match "unlikely" and it's
optional in order to match "likely".

Regards,
Denis
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help