From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9A5FC37BE6D for ; Tue, 31 Mar 2026 18:43:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=216.40.44.12 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774982638; cv=none; b=LeYw5Xse6PoykFipNKr+dOxtLrOvGjVLSDA4MWaj0hIFMdC6skpD5A8eiddnsJ8V+yLlHY0PP3U1IKjV78eMzQIzQejUGU0kwZZJCuDzyL98Xcq4HYnMCmAGnB/Eu8vsWHFOlFXvcUocZrbdATOxqCM+gxPhRP00VICHFLMuKSU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774982638; c=relaxed/simple; bh=g5Cvx6UmR1Hh5QHcEFhwuXX1X0cSAwAoxDUeYcZWYuI=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=K5F4UfW2gaeWdt0Wrf14wrkqZnGtW8nOrXspw0jVSia1boBY6cQNFe6+VvfAaFidc1ZXxObcB05LeS3MceqtmJNxDErHnX1Mp0pQqRJ0eEzKolwTzoRH2f6PkAJm1SwRD4jQ8jku5cSJ/gdL5xeAGKIZnQAZPGcOFPY9MUifRTw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=perches.com; spf=pass smtp.mailfrom=perches.com; arc=none smtp.client-ip=216.40.44.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=perches.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=perches.com Received: from omf10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 3848BB82BB; Tue, 31 Mar 2026 18:43:56 +0000 (UTC) Received: from [HIDDEN] (Authenticated sender: joe@perches.com) by omf10.hostedemail.com (Postfix) with ESMTPA id E0B2841; Tue, 31 Mar 2026 18:43:53 +0000 (UTC) Message-ID: <5dfee4e926ee8eaca9c8c42e6a83fd2dafa78f8f.camel@perches.com> Subject: Re: [PATCH v2] checkpatch: exclude forward declarations of const structs From: Joe Perches To: Taylor Nelms , Andy Whitcroft , Andrew Morton Cc: Dwaipayan Ray , Lukas Bulwahn , linux-kernel@vger.kernel.org Date: Tue, 31 Mar 2026 11:43:52 -0700 In-Reply-To: <20260331181509.1258693-1-tknelms@google.com> References: <6d437428c9f4178faec96d8c264c56e31805146e.camel@perches.com> <20260331181509.1258693-1-tknelms@google.com> Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.58.3 (3.58.3-1.fc43) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Rspamd-Queue-Id: E0B2841 X-Stat-Signature: s5c3sqc66mgrgeohredbmqpqgd61w9pb X-Rspamd-Server: rspamout03 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Session-ID: U2FsdGVkX19Igj0o/b5bf3CrU6Vv0T4sxn/00PvqURI= X-HE-Tag: 1774982633-875052 X-HE-Meta: U2FsdGVkX19SyM4cpwSXxz1QbZ+1Twm+CgLNKaK1RCrcFFqaUdnxaa6Ow7yqtEJvAzItr1YgUVWpveWcuuoOiFsLQdVsMzB92nwPNuZL3t/lnYUUUmV/XaUjqWJdHARwroqEJTN/Ci0p1oEc9Oa4P441t2cL4QSEVtX7gSuc+IbckyOcWnywI6hAO+OC4k8iXJJz73EzhFgs43+6POOOOkfS4/WdwdeflE28ivcb/GWE25eGgOtoQDxKjRs+vZ15UYADIc9ZhwwtBCZvhY0vYeDzAUpY0EeZQVZV2yVNbf4Icr6/CnWnK/999Zyg7pngQnDDPPir7iXJbhwt1l/ccGmJ6p95e9MZZs0M5YYnT31BVUqnpxJrQFyv0KmqTf7ip9sVYo4b0TGPKR4UNYY3rw== On Tue, 2026-03-31 at 14:15 -0400, Taylor Nelms wrote: > Limit checkpatch warnings for normally-const structs by excluding > patterns consistent with forward declarations. >=20 > For example, the forward declaration `struct regmap_access_table;` in a > header file currently generates a warning recommending that it is > generally declared as const; however, this would apply a useless type > qualifier in the empty declaration `const struct regmap_access_table;`, > and subsequently generate compiler warnings. >=20 > Signed-off-by: Taylor Nelms <[tknelms@google.com](mailto:tknelms@google.c= om)> Acked-by: Joe Perches > --- >=20 > Changelog since v1: > - Changed capturing group to character class in regex. >=20 > scripts/checkpatch.pl | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) >=20 > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl > index e56374662ff7..bed0bfedf5ba 100755 > --- a/scripts/checkpatch.pl > +++ b/scripts/checkpatch.pl > @@ -7502,10 +7502,10 @@ sub process { > } > =20 > # check for various structs that are normally const (ops, kgdb, device_t= ree) > -# and avoid what seem like struct definitions 'struct foo {' > +# and avoid what seem like struct definitions 'struct foo {' or forward = declarations 'struct foo;' > if (defined($const_structs) && > $line !~ /\bconst\b/ && > - $line =3D~ /\bstruct\s+($const_structs)\b(?!\s*\{)/) { > + $line =3D~ /\bstruct\s+($const_structs)\b(?!\s*[\{;])/) { > WARN("CONST_STRUCT", > "struct $1 should normally be const\n" . $herecurr); > } >=20 > ```