Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp508378pxv; Wed, 30 Jun 2021 10:34:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxZtFf9zsO4dSx4YwyRG5NzffFJvQs8szq+ecxDIXq5/nTAqBSADydbw2Hd4deuVKcP3LJh X-Received: by 2002:a05:6e02:1145:: with SMTP id o5mr16488029ill.101.1625074462783; Wed, 30 Jun 2021 10:34:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625074462; cv=none; d=google.com; s=arc-20160816; b=VuAYmnKBG1CItThitnYivZQlpb6AzE+Z7cO5q6TjAM3pw7Bgh/G7U+0MF/1DfQ3PIx S3CIYcEvMFi3gA/1XhJAxKRXXoehKBbbP2apqf39/C5hOl/8xa2+dPEq7J1NOL7Y8Gww Ww2NDGBXIZl/mLCzYiecoDW3qbpsxuv4a4vmzzrHzbf6OhEXUOs1S5liw/XLii/VeD+Y J2SVm5wIW8bwBgU3E21m0+zOsIwdUdLBfRmZ4DYSc4CLkx14pmbaxUhXIL0S2ZX4e3Wn gZ7snqKSflV/+rAOVwBNoN6/ocjzMpkxMyCUCklamMeWhyRjTW4huPDSvpYe2pfgDC0i KqHA== 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 :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id; bh=jL55ZQcX07bA2j84IIXo7xFm+Wwg7eA+8R9u2GN9bXw=; b=YD5RL3diK1lOGbFkQXIxaFtH32oZqubIdEnD0Rl1uEOuza++eRGwyx4+ZDBjbb5YbX e8TVXJ66getN5trxDz19cdzIHGkDPD3jmaxGHrhiRZhJxCYT8+TmCnDr6ywrLOhgZq+o nbjBxNGLmXn0fSCGUEkcn/5B3Z+qsApjT1O4FKX8NNKLxdbLFh5sHTSkdWNwCwOtgcw5 pnmhj2PK07SRCwv6sOidJ3j0mQ1ao3OD1r57phkknoE7nzfnyZ28QYWcaZLOW/rZzUki /m7evZChSFri9dONoKsJqY9K9jN7tWStNxCTgoK5aXxvI80X3r/E5Wyh9xUaxXbL6XeN Ycew== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g5si23191388ilk.102.2021.06.30.10.34.08; Wed, 30 Jun 2021 10:34:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230191AbhF3Rf4 (ORCPT + 99 others); Wed, 30 Jun 2021 13:35:56 -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-Spam-Status: No, score=-2.90 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.