From nobody Wed Apr 1 08:17:51 2026 Received: from mail-qv1-f73.google.com (mail-qv1-f73.google.com [209.85.219.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E97A03A451A for ; Tue, 31 Mar 2026 17:26:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774978019; cv=none; b=akXsvM76XZ+xZqYzYYTgGHsaMFdXB9x3QA22s+1XrQZf+h45XFJ7BSkj87nHu4dyrfpK4SGyq5uRJFLRX6xaBZeCPN60yP1mg4zYEXWstA7CGsYXKqTUJlYkg2X5lyxmz8qgpppzZYz1fkZMihNrnSo3dWO4pZMyopMAp9PGUHU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774978019; c=relaxed/simple; bh=G294sDAnsDXlUTBV+ihCCfhululEIMvrlXqR9SKBoO0=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=jK/MINNjmhAJxuwfHcX1gZuI9nzQawH/hgj58dQNXTB6zvn31PXiCYSFs1Bi3IRsPzOUm9riojaLpp8VIe+NmYHDkb/1r2J7lYvo6IWSRc4m66zZVYFGFGcMILFh+qJpQBtNZf6DnuqywH94sGfbDUxzOgZctWjnRpvMXtWNWCg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--tknelms.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=T68nHdvq; arc=none smtp.client-ip=209.85.219.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--tknelms.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="T68nHdvq" Received: by mail-qv1-f73.google.com with SMTP id 6a1803df08f44-89e56a8c863so27868076d6.3 for ; Tue, 31 Mar 2026 10:26:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1774978017; x=1775582817; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=Pc20DbqksAifYCMfjGqJd+rdS0+n6dw7inUo9DJOGNg=; b=T68nHdvqiKbq0vvEvGasVgtN9m4Rs3YfGXWTWkfI3nHCHYudDPBF/e3x9mY95LHPX/ IUzgybCBRaENTAYCcOspZx4Ie7Klal5lLOSGlTqWkbgy+0IUz+m13brwTzQdnTLe/dN+ kvOGF4qbId/QZbjJHCkErs31rH9lgBVbgcK3YHquBir87UIm2pGVx5ooAicnEusISsXz Vdv9NHZxJvceL6SKur1LjDkLGDEcdEzps6uDXs7bvhBAN3wveyJugiNfcf3Fm6uhowtj HdijVrxKZ0/mp1MDqdJauw4Yg7zB7wNqNshw69ppAxroHR9/iUSZ4qg2fTXfIhen94+T 0llQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774978017; x=1775582817; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=Pc20DbqksAifYCMfjGqJd+rdS0+n6dw7inUo9DJOGNg=; b=LKvz1+MEC+/t2h9lHf8VJRSgiM0GtzNfRuCPP/n6qhG8U6EYnLIhoQ5duWX2nN/kJN jQZQFwi6hPQLGOq4WWrZfmW6Q2isHPBhkN8O2rWnroxAYdEcSTX02nEG0vozVD/JiMIR MKxM9etoYoxCn245K1RgUNvzOQVgP2iouF/2E/cNFt8jsywxM9DimTYt2CilF1QrHvsW uTsWBBclU0D/AcPGsUPKA0OkqlVG2KQj8998kuqBzzrfPRTAxk0Aqk7j0RQs/dEvWNbV O2R3oYuUInx6VtaRTWsuJrbxVQ61x81AV+bfA8vr3gX+5EkJCPBsvfnbaM+xs3dD5J5w fp6g== X-Forwarded-Encrypted: i=1; AJvYcCUpujfQirm3ZqKl4TiHqvIZcdGU4A5k9umq0xUEN1DbZ+1qoHS5QciiyFqDu1ZLEI2IvBd5edLcfY/ZrWw=@vger.kernel.org X-Gm-Message-State: AOJu0YxWxXD7BC3gKzjrECrGtsw+f4jnsLp9E13LXeIR44da+erFTSM0 3VlCtMuQv1J4IPwZS+xSMgYJ/J2Ne8poCMeIV1++RTT5rfqwTmNcqoMRmXDLv6P0RU8ERrqzEgV Ji6uZC69ncg== X-Received: from qvt10.prod.google.com ([2002:a05:6214:dca:b0:89e:e890:4225]) (user=tknelms job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6214:5682:b0:89c:4cac:74c5 with SMTP id 6a1803df08f44-8a437f1c083mr7172276d6.25.1774978016634; Tue, 31 Mar 2026 10:26:56 -0700 (PDT) Date: Tue, 31 Mar 2026 13:26:48 -0400 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.53.0.1118.gaef5881109-goog Message-ID: <20260331172649.1234732-1-tknelms@google.com> Subject: [PATCH] checkpatch: exclude forward declarations of const structs From: Taylor Nelms To: Joe Perches , Andy Whitcroft Cc: Taylor Nelms , Dwaipayan Ray , Lukas Bulwahn , linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Limit checkpatch warnings for normally-const structs by excluding patterns consistent with forward declarations. 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. Signed-off-by: Taylor Nelms --- scripts/checkpatch.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index e56374662ff7..47bce7e7aeba 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_tre= e) -# and avoid what seem like struct definitions 'struct foo {' +# and avoid what seem like struct definitions 'struct foo {' or forward de= clarations '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 2.53.0.1118.gaef5881109-goog