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=-19.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT 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 4369AC432BE for ; Thu, 26 Aug 2021 02:20:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 167ED610CB for ; Thu, 26 Aug 2021 02:20:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236600AbhHZCUM (ORCPT ); Wed, 25 Aug 2021 22:20:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:49060 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235677AbhHZCUK (ORCPT ); Wed, 25 Aug 2021 22:20:10 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 84E92601FE; Thu, 26 Aug 2021 02:19:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1629944364; bh=xOADAxsafKh08ynoLGlWX9hW7/cYaZagi+PU2WUNpMQ=; h=From:To:Cc:Subject:Date:From; b=AnU9MqhXn+EduAnPMTLBgQw423RRaECkjSHvKa8OS62oDlZj0icc8+zK52Bpu3qcJ 51N34aqYHwJ8l5ElN7VAmmRsmdIFKo8BV5RED7GfFoFBXHVPRXawBhlCwjItOjaCVe dYsBaoX1n7jrzi7WfggISaE5ckbuFfYADKDGEziP943Wgm8ito2VuU5IQ8K/41nt2V wFuLfkJ52Cryp7XppHO4w5qDA+yTVHuSUb65hQj/5x9F5sPPoI1mHbdZwVV//EV+Nk MU5bnxn86OWt29uQlcw4K/q+6ZH0GxIJk85Q5O3Wq+E25tGWsi5l/0d6dp8PqnOQvB LtluMpHJXeV/w== From: Masami Hiramatsu To: Andy Whitcroft , Joe Perches Cc: Dwaipayan Ray , Lukas Bulwahn , linux-kernel@vger.kernel.org, mhiramat@kernel.org Subject: [PATCH] checkpatch: Do not warn __initconst for const char *. Date: Thu, 26 Aug 2021 11:19:21 +0900 Message-Id: <162994436171.204899.977391959489238226.stgit@devnote2> X-Mailer: git-send-email 2.25.1 User-Agent: StGit/0.19 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org checkpatch.pl warns if an '__initdata' variable has 'const' attribute to use __initconst, but it doesn't check that attribute affects the type of a pointer or the variable. Thus it reports an false error if 'const char *' variable is '__initdata'. e.g. ERROR: Use of const init definition must use __initconst #32: FILE: lib/bootconfig.c:32: +static const char *xbc_err_msg __initdata; To fix this issue, this ensures that the 'const' does not follows any type string and a pointer ('*') too. Signed-off-by: Masami Hiramatsu --- scripts/checkpatch.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 461d4221e4a4..c04213a7b633 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -6330,7 +6330,7 @@ sub process { } # check for $InitAttributeData (ie: __initdata) with const - if ($line =~ /\bconst\b/ && $line =~ /($InitAttributeData)/) { + if ($line =~ /\bconst\b/ && $line !~ /\bconst\b[^\*\(]+\*/ && $line =~ /($InitAttributeData)/) { my $attr = $1; $attr =~ /($InitAttributePrefix)(.*)/; my $attr_prefix = $1;