Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp301344rwl; Tue, 11 Apr 2023 18:56:11 -0700 (PDT) X-Google-Smtp-Source: AKy350Zz4sand/Av2uO7tNh4pQKjUPOU1ijyMH5Grn3fZi3mB68k5jF30EVvJ4x/CaMDvLFnu998 X-Received: by 2002:a17:90a:ca85:b0:246:ac0b:9d45 with SMTP id y5-20020a17090aca8500b00246ac0b9d45mr658584pjt.18.1681264571409; Tue, 11 Apr 2023 18:56:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681264571; cv=none; d=google.com; s=arc-20160816; b=zoSuzgThx8wo7S08dD4QNdE/DldRRL6fn/twExIeGzU4Afqn2GyNOhdiCGH2vvWKIK 6eiKAuwdo5RKbpsc/aBInGQGCxX5JhwJvpt/fuJibFZkoPmiLASuiT7qPFZw+XvgCZEN kgaMcaiNVw4RHi7eSgqPRegcfVxxciMHC3hilysk9yrL0xxyx9RDm8nAHnWzEsggNa1h ezBpBMDX42xVupXuAPJayLFrJO8EaeXVavz5SbCC39rnPc+Az44z10KI5pQpQJXcDd7i D2Axgi/8G/Mi3EBdN1ienmUiqzcFrBfzHeyjSuFoOwlSQkZBXYc7AkbajNxxac8PvKVd uW8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id; bh=JI8/JTWCTNx9/vk+/tC093vHc9OwxNMbHecZbXl60Dw=; b=H97czsdDb2k6GGzfX0iYOu9yN+ddiIozm4OjAMuewB9io9m2DqM/Vjg/inqduHM+yU E43uO5YDZrsngTyQre4cmEP/sgpXLD6aADD6UqqrNcqcuemVj/UQnj1U6iaB4rObfVLt jg195dCxkS0xJKCuxmvn5y0Eubn2bSmkUKXcLzONcScDfQjh+k2vePdCmnP08BwRT/SB abrd6VI1KBR5V6w5l6HbWo8UuC/rvDKZKaDrI/CmkS/IMNp3tXrvAWo25Sr8TLFYxLlv aV7wg+4H7HO0X8g08wR8K3+MbpOA+StM2m5lVKpl+oxoNHKutlUpqvODNGVFL2Fjg7XJ JTRg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id om16-20020a17090b3a9000b0023d276137a5si731743pjb.30.2023.04.11.18.56.00; Tue, 11 Apr 2023 18:56:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229612AbjDLBxy convert rfc822-to-8bit (ORCPT + 99 others); Tue, 11 Apr 2023 21:53:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229559AbjDLBxx (ORCPT ); Tue, 11 Apr 2023 21:53:53 -0400 Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D7A54C07 for ; Tue, 11 Apr 2023 18:53:47 -0700 (PDT) Received: from omf14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id EE183140A95; Wed, 12 Apr 2023 01:53:45 +0000 (UTC) Received: from [HIDDEN] (Authenticated sender: joe@perches.com) by omf14.hostedemail.com (Postfix) with ESMTPA id 7192032; Wed, 12 Apr 2023 01:53:43 +0000 (UTC) Message-ID: <2b966f46a5f60de629681527bb00401830118947.camel@perches.com> Subject: Re: [RFC PATCH] checkpatch: Support __initconst combined with struct definition From: Joe Perches To: Andy Shevchenko , =?ISO-8859-1?Q?Bj=F6rn_T=F6pel?= Cc: Andy Whitcroft , Dwaipayan Ray , Lukas Bulwahn , linux-kernel@vger.kernel.org, =?ISO-8859-1?Q?Bj=F6rn_T=F6pel?= Date: Tue, 11 Apr 2023 18:53:42 -0700 In-Reply-To: References: <20230301094320.15954-1-bjorn@kernel.org> Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8BIT User-Agent: Evolution 3.44.4 (3.44.4-2.fc36) MIME-Version: 1.0 X-Rspamd-Queue-Id: 7192032 X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS, SPF_NONE,UNPARSEABLE_RELAY autolearn=no autolearn_force=no version=3.4.6 X-Rspamd-Server: rspamout01 X-Stat-Signature: sy964tf6dhz9dnt7e8zigqqwn7xz8i3m X-Session-Marker: 6A6F6540706572636865732E636F6D X-Session-ID: U2FsdGVkX19GLVU+nzrGdem+UwEVe+zM911VbiL4lys= X-HE-Tag: 1681264423-285885 X-HE-Meta: U2FsdGVkX19GwP+aELnsxhseFU2M32tOO4PjvNCwiMPweENuspWK00zanBENykIOMWfhhEpA1DpKCsnbQUZdGw== X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2023-04-11 at 16:38 +0300, Andy Shevchenko wrote: > On Wed, Mar 01, 2023 at 10:43:20AM +0100, Bj?rn T?pel wrote: > > From: Bj?rn T?pel > > > > Checkpatch sometimes report a false positive for __initconst. E.g., for the > > following snippet: > > > > | static const struct strspn_test { > > | const char str[16]; > > | const char accept[16]; > > | const char reject[16]; > > | unsigned a; > > | unsigned r; > > | } tests[] __initconst = { > > | { "foobar", "", "", 0, 6 }, > > | { "abba", "abc", "ABBA", 4, 4 }, > > | { "abba", "a", "b", 1, 1 }, > > | { "", "abc", "abc", 0, 0}, > > | }; > > > > checkpatch would report: > > > > | ERROR: Use of __initconst requires a separate use of const > > | #190: FILE: ./test_string.c:190: > > | + } tests[] __initconst = { > > > > Improve the reporting by trying harder to find the 'const'. > > Joe, what do you think about this? I think the ctx_block_outer_rev function doesn't handle patch context blocks and the loop at best needs to be changed to include last if $rawlines[$line] =~ /^@/);. And the loop parsing couldn't handle structs with embedded unions or structs. I also think that checkpatch will always have false negatives and false positives and this might not be that useful as likely most compilers should now be able to identify this as well.