From mboxrd@z Thu Jan 1 00:00:00 1970 From: Denis Efremov Subject: Re: [PATCH v3 01/11] checkpatch: check for nested (un)?likely() calls Date: Sat, 31 Aug 2019 20:07:34 +0300 Message-ID: References: <20190829165025.15750-1-efremov@linux.com> <0d9345ed-f16a-de0b-6125-1f663765eb46@web.de> <689c8baf-2298-f086-3461-5cd1cdd191c6@linux.com> <493a7377-2de9-1d44-cd8f-c658793d15db@web.de> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Return-path: In-Reply-To: <493a7377-2de9-1d44-cd8f-c658793d15db@web.de> Content-Language: en-US Sender: netdev-owner@vger.kernel.org To: Markus Elfring , Joe Perches Cc: Andrew Morton , Anton Altaparmakov , Andy Whitcroft , Boris Ostrovsky , Boris Pismenny , "Darrick J. Wong" , "David S. Miller" , Dennis Dalessandro , Dmitry Torokhov , dri-devel@lists.freedesktop.org, Inaky Perez-Gonzalez , =?UTF-8?B?SsO8cmdlbiBHcm/Dnw==?= , Leon Romanovsky , linux-arm-msm@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, linux-ntfs-dev@lists.sourceforge.net, linux-rdma@vger.kernel.org, linux-wimax@intel.com List-Id: linux-input@vger.kernel.org On 31.08.2019 19:45, Markus Elfring wrote: >>>> +# 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? > … >> 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. >> 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 (4) 4: CURLYX[0]{0,1} (16) 6: EXACT <_> (8) <-- common prefix 8: TRIE-EXACT[OV] (15) ... > > 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