From nobody Mon Jun 22 15:44:20 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1E1CCC433F5 for ; Mon, 21 Mar 2022 18:05:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351990AbiCUSHM (ORCPT ); Mon, 21 Mar 2022 14:07:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345172AbiCUSHJ (ORCPT ); Mon, 21 Mar 2022 14:07:09 -0400 Received: from mail-oi1-x22f.google.com (mail-oi1-x22f.google.com [IPv6:2607:f8b0:4864:20::22f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97A3C5EDDE for ; Mon, 21 Mar 2022 11:05:43 -0700 (PDT) Received: by mail-oi1-x22f.google.com with SMTP id z8so17062197oix.3 for ; Mon, 21 Mar 2022 11:05:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=csFbV8mex3SknnrbFvywrMSrr0CsC7QVTDfRrFG7bIc=; b=RPet5TW1bR0DE2bWAU0VRzEoOKF0hmUrHqGvQL/S8gHdSwSDeg8xJ5mnbmRb04fKlY E13YRRZ8/UN1VdBu3PoT3SWm3oMlVbfIyEA2i2xCQaxrfkKWkalxP+yPAWnrWrJnag0u XXCzsSJNTRLY36JtE0LjLuoubdR4u/OkR+3E9lXsYrYpzIrLIa42k4JrdPaln6fBJcfh Uc51G5e7zC5A40UWGUxrOUplsoBupbErpXcAw457hLkkBEqCPJ7Cd6Z5Dn9eLf5KDL58 vf6jW4Oaw9kgJjgzSveQml59YIqwHB7JwQxPOnMVzaNST5WZbIsMaSwxPXC/ECiyXhoZ 9r7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=csFbV8mex3SknnrbFvywrMSrr0CsC7QVTDfRrFG7bIc=; b=e9/9K7QAXeZ4bjakbcvF2k0YyoS6EaRU3927yXbWjQ3Cxsd9BiXVcxT5Wuto8+OB37 JjpuAet9DoHCMDsMiEDlVpGjlakdynbNaenSgkGUjnfLJABVkLmfSPlZEIjOLaamp2PS D7Y0S4vdejaoh+nkTv21c2TzK7v5eQR8sZjIoAzUN/qwNKBCWAq+LGv7x2kB1shMpaDb ZSm9dQSJ/BQK2spuNNOnBacqktOAXpQ37CQi9qJpqZOllwCKnlINz4buMJIjyDCsfebs MkpyugNhziowHYvMF3MzzFLXMYxlTMPquQNQRJ4jG3hYyn4526xIZIYeEUapAEmM3Ae3 +mZA== X-Gm-Message-State: AOAM5303QkKEdnVcHllNSrAsvBhfSphASq/Zn8Yoe0SK8eYKs/2G/CfU xR3FedzGERihS34TLCZj5UD72g== X-Google-Smtp-Source: ABdhPJx43cjfp86LlzUzMsjt6s0dwo08dMlqc4P2DpMOyie/m//toVQ1lOOAa3zRzo0GllwOMVjkQQ== X-Received: by 2002:a05:6808:19a6:b0:2d9:c463:fac0 with SMTP id bj38-20020a05680819a600b002d9c463fac0mr179438oib.135.1647885942940; Mon, 21 Mar 2022 11:05:42 -0700 (PDT) Received: from ripper.. ([2600:1700:a0:3dc8:205:1bff:fec0:b9b3]) by smtp.gmail.com with ESMTPSA id r129-20020acac187000000b002ef358c6e0esm4086763oif.49.2022.03.21.11.05.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Mar 2022 11:05:42 -0700 (PDT) From: Bjorn Andersson To: Andy Whitcroft , Joe Perches , Dwaipayan Ray , Lukas Bulwahn Cc: linux-kernel@vger.kernel.org, Stephen Rothwell Subject: [PATCH] checkpatch: Validate "Fixes:" references Date: Mon, 21 Mar 2022 11:07:09 -0700 Message-Id: <20220321180709.1177684-1-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.33.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" checkpatch guards about non-compliant or invalid commit references embedded in the commit message, but a similar set of mistakes can be made when referencing commits in "Fixes:". Add sanity checks for references to missing commits, short hashes, improper spacing, improper case or issues with the commit description. Signed-off-by: Bjorn Andersson --- scripts/checkpatch.pl | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 577e02998701..b602ab50fc5c 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -3273,6 +3273,42 @@ sub process { $last_git_commit_id_linenr =3D $linenr if ($line =3D~ /\bcommit\s*$/i); } =20 +# Check for valid Fixes: + if ($line =3D~ /^fixes:\s*([0-9a-f]{5,})/i) { + my $orig_commit =3D lc($1); + + my $case =3D 1; + my $short =3D 1; + my $space =3D 1; + my $has_quotes =3D 0; + my $id =3D '0123456789ab'; + my $orig_desc =3D "commit description"; + my $description =3D ""; + + $case =3D 0 if ($line =3D~ /^Fixes:\s+[0-9a-f]{5,40}[^A-F]/); + $short =3D 0 if ($line =3D~ /\bfixes:\s*[0-9a-f]{12,40}/i); + $space =3D 0 if ($line =3D~ /\bfixes: [0-9a-f]{5,} \(/i); + + if ($line =3D~ /\bfixes:\s+[0-9a-f]{5,}\s*($balanced_parens)/i) { + $orig_desc =3D substr($1, 1, -1); + if ($orig_desc =3D~ /^".*"$/) { + $orig_desc =3D substr($orig_desc, 1, -1); + $has_quotes =3D 1; + } + } + + ($id, $description) =3D git_commit_info($orig_commit, + $id, $orig_desc); + + if (defined($id) && ($short || $space || $case || ($orig_desc ne $descr= iption) || !$has_quotes)) { + ERROR("GIT_COMMIT_ID", + "Please use git commit description style 'Fixes: <12+ chars of s= ha1> (\"\")' - ie: 'Fixes: $id (\"$description\")'\n" . $herecu= rr); + } elsif (!defined($id)) { + WARN("UNKNOWN_COMMIT_ID", + "Unknown commit id '$orig_commit', maybe rebased or not pulled?\n= " . $herecurr); + } + } + # Check for added, moved or deleted files if (!$reported_maintainer_file && !$in_commit_log && ($line =3D~ /^(?:new|deleted) file mode\s*\d+\s*$/ || --=20 2.33.1