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 4B592C3526A for ; Thu, 17 Dec 2020 17:28:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1B07E238EF for ; Thu, 17 Dec 2020 17:28:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729857AbgLQR2L (ORCPT ); Thu, 17 Dec 2020 12:28:11 -0500 Received: from smtprelay0182.hostedemail.com ([216.40.44.182]:34976 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729821AbgLQR2K (ORCPT ); Thu, 17 Dec 2020 12:28:10 -0500 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay07.hostedemail.com (Postfix) with ESMTP id C2865181D303C; Thu, 17 Dec 2020 17:27:29 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-HE-Tag: ocean85_55014a627436 X-Filterd-Recvd-Size: 1902 Received: from XPS-9350.home (unknown [47.151.137.21]) (Authenticated sender: joe@perches.com) by omf11.hostedemail.com (Postfix) with ESMTPA; Thu, 17 Dec 2020 17:27:28 +0000 (UTC) Message-ID: <816c1571b4132f991089b40a759cf68afcf4af43.camel@perches.com> 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 09:27:27 -0800 In-Reply-To: <20201217171111.GA8295@ls3530.fritz.box> References: <20201217171111.GA8295@ls3530.fritz.box> 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: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. 2 uses are kprobe, the other is fs/proc None of the existing uses is equivalent to %ps Why should this be applied?