From patchwork Fri Sep 4 23:35:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 11758679 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 84818138E for ; Fri, 4 Sep 2020 23:35:55 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4A2E82087C for ; Fri, 4 Sep 2020 23:35:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="NXdkWHIV" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4A2E82087C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 2FDC26B0072; Fri, 4 Sep 2020 19:35:54 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 2AEAF6B0073; Fri, 4 Sep 2020 19:35:54 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1C2906B0074; Fri, 4 Sep 2020 19:35:54 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0215.hostedemail.com [216.40.44.215]) by kanga.kvack.org (Postfix) with ESMTP id 059E86B0072 for ; Fri, 4 Sep 2020 19:35:54 -0400 (EDT) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id C598C181AC9CB for ; Fri, 4 Sep 2020 23:35:53 +0000 (UTC) X-FDA: 77226988986.11.cord17_4a003c5270b6 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin11.hostedemail.com (Postfix) with ESMTP id 99764180F8B80 for ; Fri, 4 Sep 2020 23:35:53 +0000 (UTC) X-Spam-Summary: 1,0,0,0ff4ec7ae5eb41e5,d41d8cd98f00b204,akpm@linux-foundation.org,,RULES_HIT:41:355:379:800:960:967:973:982:988:989:1260:1345:1359:1381:1431:1437:1534:1542:1711:1730:1747:1777:1792:2197:2199:2393:2525:2559:2563:2682:2685:2859:2902:2933:2937:2939:2942:2945:2947:2951:2954:3022:3138:3139:3140:3141:3142:3353:3653:3865:3866:3867:3868:3870:3872:3874:3934:3936:3938:3941:3944:3947:3950:3953:3956:3959:4321:4605:5007:6261:6653:7514:7576:7903:9025:9545:10004:11026:11473:11658:11914:12043:12048:12297:12517:12519:12555:12679:12986:13095:13141:13161:13229:13230:14093:14181:14721:21067:21080:21221:21433:21451:21627:21939:21990:30029:30054:30070,0,RBL:198.145.29.99:@linux-foundation.org:.lbl8.mailshell.net-62.2.0.100 64.100.201.201;04yrqh4eqnt81fhgpjsbt7i7qom6zypmzsn68a77erzdcsb9a85kqrezptzqdr9.1ubw1y6q97h9jixx8ka5y6ychsnfdsacjhhahhia3fqz1ybkogfbeibzqw5qg71.e-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,M SBL:0,DN X-HE-Tag: cord17_4a003c5270b6 X-Filterd-Recvd-Size: 3648 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf44.hostedemail.com (Postfix) with ESMTP for ; Fri, 4 Sep 2020 23:35:53 +0000 (UTC) Received: from localhost.localdomain (c-71-198-47-131.hsd1.ca.comcast.net [71.198.47.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 58E80208C7; Fri, 4 Sep 2020 23:35:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599262552; bh=6WT/eIjHIIiMrlzdI/sZtAds5GrfVF+meLSclJlcCyk=; h=Date:From:To:Subject:In-Reply-To:From; b=NXdkWHIV/r+nGvtWJ5kG09Tp7QrwfBezrOztZLvGe+8apdj68uXoi4xZbCXvdgEZA FQARw7MuyZUFDqnSva3ym8cfOHVyRMC0Qi7UWrg5eNsg3nFCdbZKOZK5GsloHwgmO0 oyQv8aLVJXsXb7CpOCtE/c7GCntFOSafVjqzXgmQ= Date: Fri, 04 Sep 2020 16:35:52 -0700 From: Andrew Morton To: akpm@linux-foundation.org, joe@perches.com, linux-mm@kvack.org, lukas.bulwahn@gmail.com, mm-commits@vger.kernel.org, mrinalmni@gmail.com, torvalds@linux-foundation.org Subject: [patch 10/19] checkpatch: fix the usage of capture group ( ... ) Message-ID: <20200904233552.kLq6B7QPc%akpm@linux-foundation.org> In-Reply-To: <20200904163454.4db0e6ce0c4584d2653678a3@linux-foundation.org> User-Agent: s-nail v14.8.16 X-Rspamd-Queue-Id: 99764180F8B80 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam05 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Mrinal Pandey Subject: checkpatch: fix the usage of capture group ( ... ) The usage of "capture group (...)" in the immediate condition after `&&` results in `$1` being uninitialized. This issues a warning "Use of uninitialized value $1 in regexp compilation at ./scripts/checkpatch.pl line 2638". I noticed this bug while running checkpatch on the set of commits from v5.7 to v5.8-rc1 of the kernel on the commits with a diff content in their commit message. This bug was introduced in the script by commit e518e9a59ec3 ("checkpatch: emit an error when there's a diff in a changelog"). It has been in the script since then. The author intended to store the match made by capture group in variable `$1`. This should have contained the name of the file as `[\w/]+` matched. However, this couldn't be accomplished due to usage of capture group and `$1` in the same regular expression. Fix this by placing the capture group in the condition before `&&`. Thus, `$1` can be initialized to the text that capture group matches thereby setting it to the desired and required value. Link: https://lkml.kernel.org/r/20200714032352.f476hanaj2dlmiot@mrinalpandey Fixes: e518e9a59ec3 ("checkpatch: emit an error when there's a diff in a changelog") Signed-off-by: Mrinal Pandey Reviewed-by: Lukas Bulwahn Tested-by: Lukas Bulwahn Cc: Joe Perches Signed-off-by: Andrew Morton --- scripts/checkpatch.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/scripts/checkpatch.pl~checkpatch-fix-the-usage-of-capture-group +++ a/scripts/checkpatch.pl @@ -2639,8 +2639,8 @@ sub process { # Check if the commit log has what seems like a diff which can confuse patch if ($in_commit_log && !$commit_log_has_diff && - (($line =~ m@^\s+diff\b.*a/[\w/]+@ && - $line =~ m@^\s+diff\b.*a/([\w/]+)\s+b/$1\b@) || + (($line =~ m@^\s+diff\b.*a/([\w/]+)@ && + $line =~ m@^\s+diff\b.*a/[\w/]+\s+b/$1\b@) || $line =~ m@^\s*(?:\-\-\-\s+a/|\+\+\+\s+b/)@ || $line =~ m/^\s*\@\@ \-\d+,\d+ \+\d+,\d+ \@\@/)) { ERROR("DIFF_IN_COMMIT_MSG",