Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp2392192rdh; Wed, 27 Sep 2023 00:44:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHSpwr1dkNfLlAZCd+cCIaawGq0wC2dglrHaop8YoeQmcPP2rsnoPYqfG90BbXmpQ/BTLAW X-Received: by 2002:a05:6870:1c9:b0:196:45b7:9385 with SMTP id n9-20020a05687001c900b0019645b79385mr1575823oad.27.1695800683725; Wed, 27 Sep 2023 00:44:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695800683; cv=none; d=google.com; s=arc-20160816; b=UcQNi8rQXVl0xJRUVtqTD+4PJzG91iVUm/8xR+fqoAjxfCOvYmtoPCGnHGiaRsP8Dp JHj2NTmuWBbg2wQX34o7PjbpTAjlbAdmfY19aUgG7avg2HIwF+ysJCVYdIvmHMJ25i2V doo4uN+NFPrdH9wP/GqCyq6vENGT4+DGY/LHMsydWDjJUeeyocVjrdDPWYbeUImyPn54 JEWkeyF1t9xhr3Bh6CBqngz79hAvn6+5HAah3Cj+mvKstWJl/gDikDwln0Wub1J5Fuqe WxbN5sna0AuNtcA0ONnhVGE5gL9MOnxAmm/d8AlokdP2UluT9vvLgPU6DlMoqp5ngPpe Zm7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=KAPBFzZN0dmTVWniM3sPE3x5J4rA8/bJMZqbj+O/yl8=; fh=Bz8UUsZchZ5UFVJALnQs98QsrPxirta0ko37IxXuEVs=; b=cEq3GRdsqOOVSRilSggAMqZAzmK80QRm/AaI9RtOI52bqKFDUAOoArBv3ri+UCpiRw 2Xka0YMlaJxaPNlA4QyaaDJV75iEErQUE2KAgEr2XwOTNdysaqgUGdkmxhGlBypkk2bA Rp0nUNj0mkjs/TikSVjY/UfWewTbvLDLqdtJI8zzurGnkJF338Z8RozfHqRUFMLSNz5I Guez+aQHZZsUvjYRdOW9+JCMNArZnC+HqW5+8i3lhRcHtWnaC3Dd9C4+60sDksl2Xufg ORur7W2zJ+x+YDlpg2V1ClSMLPTCEXBEJgiDDv2LEg5UB3pePI8gHZZ+p2HcjuTlPBB8 pE4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tesarici.cz header.s=mail header.b=Vudmlmje; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=tesarici.cz Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id s196-20020a6377cd000000b00577723d24b0si14852621pgc.46.2023.09.27.00.44.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 00:44:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@tesarici.cz header.s=mail header.b=Vudmlmje; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=tesarici.cz Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id CD3408024620; Tue, 26 Sep 2023 23:21:44 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229892AbjI0GVc (ORCPT + 99 others); Wed, 27 Sep 2023 02:21:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230028AbjI0GUq (ORCPT ); Wed, 27 Sep 2023 02:20:46 -0400 Received: from bee.tesarici.cz (bee.tesarici.cz [77.93.223.253]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE8231982 for ; Tue, 26 Sep 2023 23:20:03 -0700 (PDT) Received: from meshulam.tesarici.cz (dynamic-2a00-1028-83b8-1e7a-4427-cc85-6706-c595.ipv6.o2.cz [IPv6:2a00:1028:83b8:1e7a:4427:cc85:6706:c595]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bee.tesarici.cz (Postfix) with ESMTPSA id C068F183146; Wed, 27 Sep 2023 08:20:00 +0200 (CEST) Authentication-Results: mail.tesarici.cz; dmarc=fail (p=none dis=none) header.from=tesarici.cz DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tesarici.cz; s=mail; t=1695795600; bh=VXOLDgrjE//bKAwXR5UHYe1arN35YLrbw8ZC5YE0+AY=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=VudmlmjejNhW76DI85HdTdQXc8aRUFWXvuJ0p62jFtnIHKD2JvM9UlR4mmJXFsnwV wVN/uS4qSc8m9bEPpHYtSnQYT9qfF3HF2nXcW9aatwMUuEApfErQLqII8u5XFdG4dW jxTypVunRJ+fqbeyPApPnpPXnb4g8TDdrIPtiKNteBqt7jVsuYgMFalSMZ6P3R+l8j fEYfaOAbxKpxzkf9mMrqRYkaNd5YEnPe8lN5DDPCPDLoZCUGwdOXhVD9xxIwxHPmyb ZyB6fQeWClqo7HMUmN5rETxOXmVdFlxI0ZqOaYUPa0bspQ4BU57v9IB4ZLQwcDAYBF PMBU63xqLlSug== Date: Wed, 27 Sep 2023 08:19:59 +0200 From: Petr =?UTF-8?B?VGVzYcWZw61r?= To: Joe Perches Cc: Andy Whitcroft , Dwaipayan Ray , Lukas Bulwahn , open list , Catalin Marinas Subject: Re: [PATCH v2] checkpatch: warn about multi-line comments without an empty /* line Message-ID: <20230927081959.210166e9@meshulam.tesarici.cz> In-Reply-To: <402f586ec556f557921c552dcea2831c4d65dc7a.camel@perches.com> References: <20230926192400.19366-1-petr@tesarici.cz> <1adcfeaa4bd01d59a349daa697cc007e81bc81b1.camel@perches.com> <20230926221521.08f4a64d@meshulam.tesarici.cz> <402f586ec556f557921c552dcea2831c4d65dc7a.camel@perches.com> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; x86_64-suse-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Tue, 26 Sep 2023 23:21:44 -0700 (PDT) Hi Joe, On Tue, 26 Sep 2023 13:39:34 -0700 Joe Perches wrote: > On Tue, 2023-09-26 at 22:16 +0200, Petr Tesa=C5=99=C3=ADk wrote: > > On Tue, 26 Sep 2023 12:56:33 -0700 > > Joe Perches wrote: > > =20 > > > On Tue, 2023-09-26 at 21:24 +0200, Petr Tesarik wrote: =20 > > > > According to Documentation/process/coding-style.rst, the preferred = style > > > > for multi-line comments outside net/ and drivers/net/ is: > > > >=20 > > > > .. code-block:: c > > > >=20 > > > > /* > > > > * This is the preferred style for multi-line > > > > * comments in the Linux kernel source code. > > > > * Please use it consistently. > > > > * > > > > * Description: A column of asterisks on the left side, > > > > * with beginning and ending almost-blank lines. > > > > */ > > > >=20 > > > > Signed-off-by: Petr Tesarik =20 > > > [] =20 > > > > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl =20 > > > [] =20 > > > > @@ -4006,6 +4006,14 @@ sub process { > > > > "networking block comments don't use an empty /* line, use= /* Comment...\n" . $hereprev); > > > > } > > > > =20 > > > > +# Non-networking without an initial /* > > > > + if ($realfile !~ m@^(drivers/net/|net/)@ && > > > > + $prevrawline =3D~ /^\+[ \t]*\/\*.*[^ \t]$/ && > > > > + $rawline =3D~ /^\+[ \t]*\*/) { > > > > + WARN("BLOCK_COMMENT_STYLE", > > > > + "multi-line block comments should start with an empty /* l= ine\n" . $hereprev); > > > > + } > > > > + > > > > # Block comments use * on subsequent lines > > > > if ($prevline =3D~ /$;[ \t]*$/ && #ends in comment > > > > $prevrawline =3D~ /^\+.*?\/\*/ && #starting /* =20 > > >=20 > > > Still nack. Too many existing instances. > > >=20 > > > $ git grep '/\*.*' -- '*.[ch]' | \ > > > grep -v '/\*.*\*/' | \ > > > grep -v -P "/\*\s*$" | \ > > > grep -v '/\*\*' | \ > > > grep -v "SPDX-License" | \ > > > grep -v -P '^drivers/net|^net/' | \ > > > wc -l > > > 51834 =20 > >=20 > > Um. Not everything that is currently found in the source tree would be > > accepted as new code by today's standards... > >=20 > > As it stands, the script checks the special case for net/ and > > drivers/net/ but does not help prevent unnecessary respins, like this > > one: > >=20 > > https://lore.kernel.org/linux-iommu/ZRMgObTMkfq8Bjbe@arm.com/ > >=20 > > OTOH if we don't want to warn about multi-line comments, maybe we don't > > want to call it the preferred style, and the corresponding paragraph > > should be removed from coding-style.rst. Do you suggest I try that > > instead? =20 >=20 > If you really want to bring it up as a coding style issue > go ahead, but consider that the link above is a 'nitpick' > and not an actual issue. I don't want to start a flamewar. In fact, I'm quite relaxed about coding style, so I'm not the right person to propose changes. However, if enough people believe that most instances found by your grep command are perfectly valid style, then the text in coding-style.rst does not match reality... > If you _really_ want, but I am not at all sure it's useful, > I suggest you change the message to a CHK so that it is only > emitted with --strict and not a WARN and only emit anything > when the thing being scanned is a patch and _not_ a file. OK, I'm trying to understand what it means when the script WARNs about something. IIUC these are just warnings about _possible_ coding style violations; authors and maintainers can choose to ignore them (although I know some maintainers are more strict than others on this matter). And then there is existing code. On the one hand, I get a warning when for BUG_ON(), although there are many existing BUG_ON() instances: $ git grep -w BUG_ON | wc -l 7561 Yet, there is a check for BUG_ON(). I get a warning even when I merely modify the argument of a BUG_ON(), e.g. as a result of renaming a struct member. This makes me believe that warnings from checkpatch.pl are not meant to be enforced. On the other hand, you (the maintainer) are not sure if it's useful to add a warning about block comment style, where the official guidelines has explicitly asked authors to "use it consistently" since 2006 when Randy Dunlap wrote commit b3fc9941fbc6e ("CodingStyle updates"). > Something like: >=20 > # Non-networking without an initial /* > if (!$file && > $realfile !~ m@^(?:drivers/net/|net/)@ && > $prevrawline =3D~ /^\+[ \t]*\/\*.*[^ \t]$/ && > $rawline =3D~ /^\+[ \t]*\*/) { > CHK("BLOCK_COMMENT_STYLE", > "multi-line block comments should start with an empty /* line\n" .= $hereprev); >=20 > But you still want to examine some of the false positives > this would create like: >=20 > /* ------------------------ > * block message > * ------------------------ */ OK, I can see this style is often used to mark larger sections. > and >=20 > struct foo { > int a; /* some desriptor */ > int b; /* some descriptor > on multiple lines */ AFAICS this would not trigger a warning in my proposed code, because the first line of the comment is preceded by non-white-space characters. I have also seen a lot of instances at the very beginning of a file. What about skipping the check if a block comment is followed by an empty line? I was also thinking about minus signs, but I'm not sure if the following instance is considered perfectly acceptable: /* -- Watchdog Timeout -- * Bit 0-6 (Reserved) * Bit 7 WDT Time-out Value Units Select * (0 =3D Minutes, 1 =3D Seconds) */ outb(timeout_unit, sch311x_wdt_data.runtime_reg + WDT_TIME_OUT); (found in drivers/watchdog/sch311x_wdt.c) All I want to achieve is that the check script somehow helps me keep a consistent style both in network code and non-network code. It's difficult for me as a human to keep paying attention to all these little details and subtle differences among maintainers, but at least some people do care about them. An automated check might help productivity IMO. Petr T