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=-6.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 C24EFC2D0EC for ; Fri, 10 Apr 2020 19:37:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AC04120732 for ; Fri, 10 Apr 2020 19:37:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726866AbgDJThB (ORCPT ); Fri, 10 Apr 2020 15:37:01 -0400 Received: from smtprelay0204.hostedemail.com ([216.40.44.204]:32880 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726847AbgDJTg7 (ORCPT ); Fri, 10 Apr 2020 15:36:59 -0400 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay06.hostedemail.com (Postfix) with ESMTP id 48CFC1802EB4E; Fri, 10 Apr 2020 19:36:59 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-HE-Tag: time34_3ce4cfa07334d X-Filterd-Recvd-Size: 2629 Received: from XPS-9350.home (unknown [47.151.136.130]) (Authenticated sender: joe@perches.com) by omf07.hostedemail.com (Postfix) with ESMTPA; Fri, 10 Apr 2020 19:36:58 +0000 (UTC) Message-ID: Subject: Re: [PATCH] checkpatch: check for missing \n at the end of logging message From: Joe Perches To: Christophe JAILLET , apw@canonical.com Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Date: Fri, 10 Apr 2020 12:34:56 -0700 In-Reply-To: <20200407204908.10420-1-christophe.jaillet@wanadoo.fr> References: <20200407204908.10420-1-christophe.jaillet@wanadoo.fr> Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.34.1-2 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2020-04-07 at 22:49 +0200, Christophe JAILLET wrote: > Strings logged with pr_xxx and dev_xxx often lack a trailing '\n'. > Introduce new tests to try to catch them early. Unintentional resend? > Signed-off-by: Christophe JAILLET > --- > This is more a PoC for now. > > Regex could be improved, merged, ... > We could also check for surrounding pr_cont... > > This patch is based on idea from [1]. coccinelle spots too many places > where \n are missing (~ 2800 with the heuristic I've used). > Fixing them would be painful. > I instead propose to teach checkpatch.pl about it to try to spot cases > early and avoid introducing new cases. > > [1]: https://marc.info/?l=kernel-janitors&m=158619533629657&w=4 > --- > scripts/checkpatch.pl | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl > index c392ab8ea12e..792804bd6ad9 100755 > --- a/scripts/checkpatch.pl > +++ b/scripts/checkpatch.pl > @@ -5676,6 +5676,16 @@ sub process { > } > } > > +# check for missing \n at the end of logging function > + if ($line =~ /\bpr_(emerg|alert|crit|err|warning|warn|notice|info|debug|dbg)\s*\("([^"]*(? + WARN("MISSING NL", > + "Possible missing '\\n' at the end of a log message\n" . $hereprev); > + } > + if ($line =~ /\bdev_(emerg|alert|crit|err|warning|warn|notice|info|debug|dbg)\s*\([^,]*,\s*"([^"]*(? + WARN("MISSING NL", > + "Possible missing '\\n' at the end of a log message\n" . $hereprev); > + } > + > # check for logging functions with KERN_ > if ($line !~ /printk(?:_ratelimited|_once)?\s*\(/ && > $line =~ /\b$logFunctions\s*\(.*\b(KERN_[A-Z]+)\b/) {