From nobody Wed Apr 1 08:16:42 2026 Received: from mail-qt1-f202.google.com (mail-qt1-f202.google.com [209.85.160.202]) (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 15333421EEC for ; Tue, 31 Mar 2026 18:15:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774980926; cv=none; b=pqf/JtHnFya7OCzH66AF6apneiSPSp0fMKGjaiyw9F/JrvQ8dixX22Lrwp/LneGiiwYG98f7TdOalAXiMHQyugBoK1Ygq3qqAOiWS+sCKtu0V/gU7XIlU/tDYFMW4x04LHKlflHxeSuk8hnsLUPvzYmsxp+up+RYMYbiWykAgZA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774980926; c=relaxed/simple; bh=915/5FnaRcX7Hguec817GDpUcKvWHsslPJx3GgCRe8o=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=ErCayG1aIQPCtA/j/GMKsSeRJXPJhSSSvdiokmf2VGR8XOosiO/DDzg3NrDREpDFAprBB04CWhD7KW1LYWjn+/mC2ndQtQT9vTHCI4gdjhEb7JCsrecCNulFdcKwZPHBOTydKbEN/qzomd6uchNeeDScqgQ4zrg2qpL0PWxlxKk= 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=udQsmBpg; arc=none smtp.client-ip=209.85.160.202 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="udQsmBpg" Received: by mail-qt1-f202.google.com with SMTP id d75a77b69052e-5093787e2fdso294412201cf.2 for ; Tue, 31 Mar 2026 11:15:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1774980923; x=1775585723; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=beWcDgGfbV6uyCvKLo+V23TdJ3MTj2i1Czd4DdYgPD0=; b=udQsmBpgq2EH7EjYcAxfVSq7o4VxQDadnmxt2RS2X6Q4J/AauXFVXcvWo3S6eDKdS6 3mfBYGq3T7IOLQ1Gv5iFmvT/AdPlmoCSimLb8PNMR31lQQZqarIcWuh8c2T2+FFZBRX2 TDa+4GL5whKAZbIims9qq3n6pJAItkrXuu1TGWCmDfywLHfpqV8BlvGfCYwEDDSHgvgU 8HoxNSyFVvPgBzBCjFrQ3EzA3mwZJQOoB7Uwvqe3Z/gMZQnkXlqSQtr+qUXKCz36DjOe fxjMXu+hE6w5/iRAra8fOm+5nptHYGrk++WNryL8vDi5Z9m/I1LriklR5ZMUKokCzfO0 bbHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774980923; x=1775585723; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=beWcDgGfbV6uyCvKLo+V23TdJ3MTj2i1Czd4DdYgPD0=; b=JWY56Dchz3fvgM/fYSqicuDS+/WAplR5IECBbrw43SOSz7ElOxHG6OKOQm4lv6ZPLq X0PTIWbAOuvtWxnZiH7rYVNAjvqpeJ6kkKoDL/KZkCezL5T8tdHoq/r5TQKzVvUymNkE CL4WMruHPhk4VeI5RuxuMmXDI4iq3xDyIiQjs5UJ/CdwccYPsFXEwBbD+PuzXw28x4n3 qDxwE1yI3++Dm3oEVdvDXTtLbSAg1ln1XuFJxuVWjJwlQEwoFcX1W/NJ45m4zZJuaoO0 u26c+6dJF4Vgg/s0N4CtSwblO1XlHRL6xIoCW/je0QGjbFqM5VIignIk3bM9dCDswZ5Q MNug== X-Forwarded-Encrypted: i=1; AJvYcCXvmg3bEXoN9ocwKvgDk/G3dVtsGH8Xf5XSoFo22RZh24ewsy8weKV8cGHr+fViyWhfFKf7E2FRjn0tp+A=@vger.kernel.org X-Gm-Message-State: AOJu0Yyel2x28WDOsrvZC+Oo3GpV3CBYG7jGuQO/Cz9yNVvdHufE3pIf kxUv+3km8HA7c34n9iOwroaLyQl22D+Qyu5ClRHTNR19JBVf3K+HGRqEmOnQcXwrL5m+2l4FOlN A3LpSyFLwJQ== X-Received: from qtbke18.prod.google.com ([2002:a05:622a:2892:b0:50b:2fbb:408a]) (user=tknelms job=prod-delivery.src-stubby-dispatcher) by 2002:a05:622a:5a0f:b0:501:17a9:5ff5 with SMTP id d75a77b69052e-50d3bbb20a1mr9154311cf.21.1774980922617; Tue, 31 Mar 2026 11:15:22 -0700 (PDT) Date: Tue, 31 Mar 2026 14:15:09 -0400 In-Reply-To: <6d437428c9f4178faec96d8c264c56e31805146e.camel@perches.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <6d437428c9f4178faec96d8c264c56e31805146e.camel@perches.com> X-Mailer: git-send-email 2.53.0.1118.gaef5881109-goog Message-ID: <20260331181509.1258693-1-tknelms@google.com> Subject: [PATCH v2] 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 Acked-by: Joe Perches --- Changelog since v1: - Changed capturing group to character class in regex. scripts/checkpatch.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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_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