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=-8.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,UNPARSEABLE_RELAY,URIBL_BLOCKED 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 3D96FC11F65 for ; Wed, 30 Jun 2021 17:33:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 220536146E for ; Wed, 30 Jun 2021 17:33:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232431AbhF3Rf5 (ORCPT ); Wed, 30 Jun 2021 13:35:57 -0400 Received: from smtprelay0017.hostedemail.com ([216.40.44.17]:34280 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229852AbhF3Rfz (ORCPT ); Wed, 30 Jun 2021 13:35:55 -0400 Received: from omf19.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay08.hostedemail.com (Postfix) with ESMTP id 89441182CF669; Wed, 30 Jun 2021 17:33:25 +0000 (UTC) Received: from [HIDDEN] (Authenticated sender: joe@perches.com) by omf19.hostedemail.com (Postfix) with ESMTPA id 049E120D751; Wed, 30 Jun 2021 17:33:24 +0000 (UTC) Message-ID: Subject: Re: [PATCH 2/3] checkpatch: tweak extern in C warning From: Joe Perches To: jim.cromie@gmail.com Cc: LKML Date: Wed, 30 Jun 2021 10:33:23 -0700 In-Reply-To: References: <20210626034016.170306-1-jim.cromie@gmail.com> <20210626034016.170306-3-jim.cromie@gmail.com> Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.40.0-1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Server: rspamout01 X-Rspamd-Queue-Id: 049E120D751 X-Stat-Signature: xm9jujjg5nouzutkfi3xgywfn19nrebb X-Session-Marker: 6A6F6540706572636865732E636F6D X-Session-ID: U2FsdGVkX19VdBI13MJr65OEhEVChqywAUzcvQcQSJE= X-HE-Tag: 1625074404-837417 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 2021-06-26 at 21:47 -0600, jim.cromie@gmail.com wrote: > On Sat, Jun 26, 2021 at 12:46 PM Joe Perches wrote: > > On Fri, 2021-06-25 at 21:40 -0600, Jim Cromie wrote: > > > The extern-in-C rule has one important exception: the symbol is > > > defined in/by the linker script. By convention, these almost always > > > contain: _start, _stop, _end. Suppress the warning on such symbols. > > [] > > > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl > > > [] > > > @@ -6910,7 +6910,8 @@ sub process { > > >                   $stat =~ /^.\s*extern\s+/) > > >               { > > >                       WARN("AVOID_EXTERNS", > > > - "externs should be avoided in .c files\n" . $herecurr); > > > + "externs should be avoided in .c files\n($stat)\n" . $herecurr) > > > + unless $stat =~ /_start|_stop|_end/; > > > > nak. > > > > As far as I can tell, there's no reason these symbols > > should not be in .h files. > > judging from the codebase, it has been a case-by-case decision, > with 8/10 of the linker-vars extern'd into C files, not headers. [] > > besides that: > > > > output is single line, $stat should not be used and > > using unless is not desired. > > > > could you clarify ? > style issues are easy, std if form... > $stat is already used, it must contain extern to get here. Sure, it's used as part of a test but it's never output as part of an error message. $stat strips any leading '+' from the 2nd and subsequent lines. There's a mechanism used in several other tests to show these lines. my $cnt = statement_rawlines($stat); my $herectx = get_stat_here($linenr, $cnt, $here); with the output of $herectx. > checking it for a likely-linker-symbol seems fair.