From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 118A9C433E0 for ; Thu, 4 Jun 2020 23:50:40 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C708820885 for ; Thu, 4 Jun 2020 23:50:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="reNIbWB9" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C708820885 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 6D0BD280055; Thu, 4 Jun 2020 19:50:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 63375280005; Thu, 4 Jun 2020 19:50:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5228B280055; Thu, 4 Jun 2020 19:50:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0021.hostedemail.com [216.40.44.21]) by kanga.kvack.org (Postfix) with ESMTP id 3793B280005 for ; Thu, 4 Jun 2020 19:50:39 -0400 (EDT) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 06A492490 for ; Thu, 4 Jun 2020 23:50:39 +0000 (UTC) X-FDA: 76893176598.14.train64_351842d26d9b Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin14.hostedemail.com (Postfix) with ESMTP id D5FBF18229835 for ; Thu, 4 Jun 2020 23:50:38 +0000 (UTC) X-HE-Tag: train64_351842d26d9b X-Filterd-Recvd-Size: 3575 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf45.hostedemail.com (Postfix) with ESMTP for ; Thu, 4 Jun 2020 23:50:38 +0000 (UTC) Received: from localhost.localdomain (c-73-231-172-41.hsd1.ca.comcast.net [73.231.172.41]) (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 51F012087D; Thu, 4 Jun 2020 23:50:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591314637; bh=qcs5yHPSVeodPeo61pZ7iCGzHtunve4m36r0cvNYgYU=; h=Date:From:To:Subject:In-Reply-To:From; b=reNIbWB9XlV7Lu/BC04ZhwyjYMXwT48D3vlQC4qF0nQoXBVHLEWUu0FUZJKyN3zHL oaFzRzzIv9WYwFI+wOs2qJBfEawlQpWHxwE2gS6rZ2mCxQ3Q6HYf+7DeU1A5RAyof6 AG027huBiZEgQp4uIQhMHjipPzCKbgi/9slFIjJI= Date: Thu, 04 Jun 2020 16:50:36 -0700 From: Andrew Morton To: akpm@linux-foundation.org, andreyknvl@google.com, apw@canonical.com, dvyukov@google.com, elver@google.com, glider@google.com, joe@perches.com, linux-mm@kvack.org, mm-commits@vger.kernel.org, paulmck@kernel.org, torvalds@linux-foundation.org, will@kernel.org Subject: [patch 084/127] checkpatch: look for c99 comments in ctx_locate_comment Message-ID: <20200604235036.q8HClPsmV%akpm@linux-foundation.org> In-Reply-To: <20200604164523.e15f3177f4b69dcb4f2534a1@linux-foundation.org> User-Agent: s-nail v14.8.16 X-Rspamd-Queue-Id: D5FBF18229835 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: Joe Perches Subject: checkpatch: look for c99 comments in ctx_locate_comment Some checks look for comments around a specific function like read_barrier_depends. Extend the check to support both c89 and c90 comment styles. c89 /* comment */ or c99 // comment For c99 comments, only look a 3 single lines, the line being scanned, the line above and the line below the line being scanned rather than the patch diff context. Link: http://lkml.kernel.org/r/65cb075435d2f385a53c77571b491b2b09faaf8e.camel@perches.com Signed-off-by: Joe Perches Tested-by: Paul E. McKenney Cc: Marco Elver Cc: Dmitry Vyukov Cc: Alexander Potapenko Cc: Andrey Konovalov Cc: Andy Whitcroft Cc: Will Deacon Signed-off-by: Andrew Morton --- scripts/checkpatch.pl | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) --- a/scripts/checkpatch.pl~checkpatch-look-for-c99-comments-in-ctx_locate_comment +++ a/scripts/checkpatch.pl @@ -1676,8 +1676,16 @@ sub ctx_statement_level { sub ctx_locate_comment { my ($first_line, $end_line) = @_; + # If c99 comment on the current line, or the line before or after + my ($current_comment) = ($rawlines[$end_line - 1] =~ m@^\+.*(//.*$)@); + return $current_comment if (defined $current_comment); + ($current_comment) = ($rawlines[$end_line - 2] =~ m@^[\+ ].*(//.*$)@); + return $current_comment if (defined $current_comment); + ($current_comment) = ($rawlines[$end_line] =~ m@^[\+ ].*(//.*$)@); + return $current_comment if (defined $current_comment); + # Catch a comment on the end of the line itself. - my ($current_comment) = ($rawlines[$end_line - 1] =~ m@.*(/\*.*\*/)\s*(?:\\\s*)?$@); + ($current_comment) = ($rawlines[$end_line - 1] =~ m@.*(/\*.*\*/)\s*(?:\\\s*)?$@); return $current_comment if (defined $current_comment); # Look through the context and try and figure out if there is a _