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.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,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 ABAD9C4361B for ; Thu, 17 Dec 2020 18:16:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6C0B2238EF for ; Thu, 17 Dec 2020 18:16:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730843AbgLQSQR (ORCPT ); Thu, 17 Dec 2020 13:16:17 -0500 Received: from smtprelay0215.hostedemail.com ([216.40.44.215]:33476 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727063AbgLQSQQ (ORCPT ); Thu, 17 Dec 2020 13:16:16 -0500 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay05.hostedemail.com (Postfix) with ESMTP id B896E1804E50E; Thu, 17 Dec 2020 18:15:34 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-HE-Tag: hot93_45040be27436 X-Filterd-Recvd-Size: 2933 Received: from XPS-9350.home (unknown [47.151.137.21]) (Authenticated sender: joe@perches.com) by omf15.hostedemail.com (Postfix) with ESMTPA; Thu, 17 Dec 2020 18:15:33 +0000 (UTC) Message-ID: Subject: Re: [PATCH] checkpatch: add new warning when lookup_symbol_name() is used From: Joe Perches To: Helge Deller , Andy Whitcroft , linux-kernel@vger.kernel.org Date: Thu, 17 Dec 2020 10:15:32 -0800 In-Reply-To: References: <20201217171111.GA8295@ls3530.fritz.box> <816c1571b4132f991089b40a759cf68afcf4af43.camel@perches.com> Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.38.1-1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2020-12-17 at 18:42 +0100, Helge Deller wrote: > On 12/17/20 6:27 PM, Joe Perches wrote: > > On Thu, 2020-12-17 at 18:11 +0100, Helge Deller wrote: > > > In most cases people use lookup_symbol_name() to resolve a kernel symbol > > > and then print it via printk(). > > > > > > In such cases using the %ps, %pS, %pSR or %pB printk formats are easier > > > to use and thus should be preferred. > > [] > > > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl > > [] > > > @@ -4317,6 +4317,12 @@ sub process { > > >   "LINUX_VERSION_CODE should be avoided, code should be for the version to which it is merged\n" . $herecurr); > > >   } > > > > > > +# avoid lookup_symbol_name() > > > + if ($line =~ /\blookup_symbol_name\b/) { > > > + WARN("PREFER_PRINTK_FORMAT", > > > + "If possible prefer %ps or %pS printk format string to print symbol name instead of using lookup_symbol_name()\n" . $herecurr); > > > + } > > > + > > >  # check for uses of printk_ratelimit > > >   if ($line =~ /\bprintk_ratelimit\s*\(/) { > > >   WARN("PRINTK_RATELIMITED", > > > > Huh? nak. > > > > lookup_symbol_name is used in the kernel a grand total of 3 times. > > Yes, there were much more in the past which got fixed by patches I submitted. Hi Helge. Much more may be a bit of an overstatement. I found 3 instances of lookup_symbol_name removals in 2 patches. commit 36dbca148bf8e3b8658982aa2256bdc7ef040256 - lookup_symbol_name((ulong)pm_power_off, symname); - lookup_symbol_name((ulong)pm_power_off, symname); commit da88f9b3113620dcd30fc203236aa53d5430ee98 - if (lookup_symbol_name((unsigned long)sym, symname) < 0) There's a tension between adding tests and newbies that consider checkpatch warnings as dicta that must be followed so there would be patches submitted eventually against the existing correct uses. So thanks, but given the very few existing all correct uses of this function and the low probability of new uses I'd prefer not to apply this.