From nobody Sat Nov 15 20:48:57 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1747672676; cv=none; d=zohomail.com; s=zohoarc; b=GCPU8uyoBpGZTTQZx4dYt+KjwX6OjP6v0w2b352U/L6l2JM4ZdvnLa/vjJWNHeoxpI/HOiPy6SNmxcOJfveDDXs3mtInt5plqg/QSaKQ/ifT12O76VkUaNHrGoRdTCg2oP7N5JwmCV8W/3hwL8xxOq6qLobRnEhxgo6vUpm7lTI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747672676; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=QlUv3WXzN1tjBcwFhwjIM/PQQRTgeOpjkK85tto1bTY=; b=kTsaiAlV5Euf8s9oNHlRU44Tf9xLKVyNv3iKuOcpX4k8viUke6ETQxqBdnegjWsWjkYv1zqYsNSa0fEx5YF8IHnJidrRIIyl5Atwxc5uIOwCqqTB2pCNLNyKAYKrY7FlfOOV7RFE3lACE2Du/L/JZGRcRVYADhbpyu1yyWV9Nhw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1747672676862732.7739015955917; Mon, 19 May 2025 09:37:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uH3Uf-0002WV-RG; Mon, 19 May 2025 12:37:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uH3Uc-0002OA-H1 for qemu-devel@nongnu.org; Mon, 19 May 2025 12:37:34 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uH3Ua-0005iO-SS for qemu-devel@nongnu.org; Mon, 19 May 2025 12:37:34 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-558-sJpBsaO1N62JXYBHz2gUlw-1; Mon, 19 May 2025 12:37:30 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 46336180036E; Mon, 19 May 2025 16:37:29 +0000 (UTC) Received: from toolbx.redhat.com (unknown [10.42.28.50]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id BF2D019560A3; Mon, 19 May 2025 16:37:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1747672652; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QlUv3WXzN1tjBcwFhwjIM/PQQRTgeOpjkK85tto1bTY=; b=IbeP14rLrYl++9M5yqulq8DrHP9zmQVtEJUpZ/Ffh6aFjmyz63p0OWt5SxJvmsICVZcqIH dhO34zLF5r2S0K930rcZ8O5kSa159Kye/x7X0/drXcVOhJGa0pTDWGj6CKaFWnzTlaEvl9 qQn3klLmoggVO7tYYqDEHwngIRXYfvE= X-MC-Unique: sJpBsaO1N62JXYBHz2gUlw-1 X-Mimecast-MFC-AGG-ID: sJpBsaO1N62JXYBHz2gUlw_1747672649 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH v4 1/9] Revert "scripts: mandate that new files have SPDX-License-Identifier" Date: Mon, 19 May 2025 17:37:13 +0100 Message-ID: <20250519163721.347322-2-berrange@redhat.com> In-Reply-To: <20250519163721.347322-1-berrange@redhat.com> References: <20250519163721.347322-1-berrange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.13, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=-1, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1747672678071116600 This reverts commit fa4d79c64dae03ffa269e42e21822453856618b7. The logic in this commit was flawed in two critical ways * It always failed to report SPDX validation on the last newly added file. IOW, it only worked if at least 2 new files were added in a commit * If an existing file change, followed a new file change, in the commit and the existing file context/changed lines included SPDX-License-Identifier, it would incorrectly associate this with the previous newly added file. Simply reverting this commit will make it significantly easier to understand the improved logic in the following commit. Reported-by: Peter Maydell Reviewed-by: C=C3=A9dric Le Goater Reviewed-by: Peter Maydell Signed-off-by: Daniel P. Berrang=C3=A9 --- scripts/checkpatch.pl | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 365892de04..d355c0dad5 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -1442,8 +1442,6 @@ sub process { my $in_imported_file =3D 0; my $in_no_imported_file =3D 0; my $non_utf8_charset =3D 0; - my $expect_spdx =3D 0; - my $expect_spdx_file; =20 our @report =3D (); our $cnt_lines =3D 0; @@ -1681,34 +1679,6 @@ sub process { WARN("added, moved or deleted file(s), does MAINTAINERS need updating?\= n" . $herecurr); } =20 -# All new files should have a SPDX-License-Identifier tag - if ($line =3D~ /^new file mode\s*\d+\s*$/) { - if ($expect_spdx) { - if ($expect_spdx_file =3D~ - /\.(c|h|py|pl|sh|json|inc|Makefile)$/) { - # source code files MUST have SPDX license declared - ERROR("New file '$expect_spdx_file' requires " . - "'SPDX-License-Identifier'"); - } else { - # Other files MAY have SPDX license if appropriate - WARN("Does new file '$expect_spdx_file' need " . - "'SPDX-License-Identifier'?"); - } - } - $expect_spdx =3D 1; - $expect_spdx_file =3D undef; - } elsif ($expect_spdx) { - $expect_spdx_file =3D $realfile unless - defined $expect_spdx_file; - - # SPDX tags may occurr in comments which were - # stripped from '$line', so use '$rawline' - if ($rawline =3D~ /SPDX-License-Identifier/) { - $expect_spdx =3D 0; - $expect_spdx_file =3D undef; - } - } - # Check SPDX-License-Identifier references a permitted license if ($rawline =3D~ m,SPDX-License-Identifier: (.*?)(\*/)?\s*$,) { &checkspdx($realfile, $1); --=20 2.49.0 From nobody Sat Nov 15 20:48:57 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1747672692; cv=none; d=zohomail.com; s=zohoarc; b=BpfTrI1kMCnSBhNY5o1DBxxueXNQAs1WHivOxLZ75tUj78BjEte084LqsyoGh8soSM3ydkT/q/zeDqJ4O9uS/zYMqLFWTkGNBbeLi2oJ9Gms/4B7gdYso2MA56NWEe4rMTWeTCwaRVsg2ZrF/WmaDLCsJ//Ye/rNw+l7HeTmVrY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747672692; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=6D5RyZES2SWDQ6wNrdDFXxlCfksypSEuA8DR7Bwa5jE=; b=J3DHGCnW+nf7j4BDL1C45jRCUs45VIjxu311NHaPM6IOPhhrs1fs3pO9tDxQ/I6x4FW3C6ScTywrKX+6TnCN6DRY6J+8Fee9s/UW6mD9FSazBQForfreX6L2NKWjG5QuH9RK+g+BmCy6dySYElfbMfHS6Jgya0L/3L7JBWcqbMs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1747672692502924.5781178192215; Mon, 19 May 2025 09:38:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uH3Uj-0002gO-J5; Mon, 19 May 2025 12:37:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uH3Uh-0002bH-HT for qemu-devel@nongnu.org; Mon, 19 May 2025 12:37:39 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uH3Uf-0005ip-Ba for qemu-devel@nongnu.org; Mon, 19 May 2025 12:37:38 -0400 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-63-MuywrLcRMFOlUXdOKt4S-A-1; Mon, 19 May 2025 12:37:32 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E8AEC1956096; Mon, 19 May 2025 16:37:31 +0000 (UTC) Received: from toolbx.redhat.com (unknown [10.42.28.50]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id B927119560A3; Mon, 19 May 2025 16:37:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1747672656; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6D5RyZES2SWDQ6wNrdDFXxlCfksypSEuA8DR7Bwa5jE=; b=QJHQAX5UBwAxBSBD3SlU65gOEnvGzKDhUi8dZBeoV7Ybkg7VDAuHJxTcIDTFXR9xvQ1pR7 3rrxmJcrTrs2AXmZSZSD/lAU7L5eo62aVYtwQj0YDe/OQHa8r76mB5kxYmFuGsWqr7fGRa EC/Ft2Zp7PT3T/LLRN9aUA0cnhAfq4s= X-MC-Unique: MuywrLcRMFOlUXdOKt4S-A-1 X-Mimecast-MFC-AGG-ID: MuywrLcRMFOlUXdOKt4S-A_1747672652 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH v4 2/9] scripts/checkpatch.pl: fix various indentation mistakes Date: Mon, 19 May 2025 17:37:14 +0100 Message-ID: <20250519163721.347322-3-berrange@redhat.com> In-Reply-To: <20250519163721.347322-1-berrange@redhat.com> References: <20250519163721.347322-1-berrange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.13, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=-1, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1747672694382116600 Various checks in the code were under-indented relative to other surrounding code. Some places used 4-space indents instead of single tab, while other places simply used too few tabs. Reviewed-by: C=C3=A9dric Le Goater Reviewed-by: Peter Maydell Signed-off-by: Daniel P. Berrang=C3=A9 --- scripts/checkpatch.pl | 98 +++++++++++++++++++++---------------------- 1 file changed, 49 insertions(+), 49 deletions(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index d355c0dad5..7675418b0b 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -1681,19 +1681,19 @@ sub process { =20 # Check SPDX-License-Identifier references a permitted license if ($rawline =3D~ m,SPDX-License-Identifier: (.*?)(\*/)?\s*$,) { - &checkspdx($realfile, $1); + &checkspdx($realfile, $1); } =20 if ($rawline =3D~ m,(SPDX-[a-zA-Z0-9-_]+):,) { - my $tag =3D $1; - my @permitted =3D qw( - SPDX-License-Identifier - ); - - unless (grep { /^$tag$/ } @permitted) { - ERROR("Tag $tag not permitted in QEMU code, valid " . - "choices are: " . join(", ", @permitted)); - } + my $tag =3D $1; + my @permitted =3D qw( + SPDX-License-Identifier + ); + + unless (grep { /^$tag$/ } @permitted) { + ERROR("Tag $tag not permitted in QEMU code, valid " . + "choices are: " . join(", ", @permitted)); + } } =20 # Check for wrappage within a valid hunk of the file @@ -2274,7 +2274,7 @@ sub process { =20 # missing space after union, struct or enum definition if ($line =3D~ /^.\s*(?:typedef\s+)?(enum|union|struct)(?:\s+$Ident)?(?:= \s+$Ident)?[=3D\{]/) { - ERROR("missing space after $1 definition\n" . $herecurr); + ERROR("missing space after $1 definition\n" . $herecurr); } =20 # check for spacing round square brackets; allowed: @@ -2569,7 +2569,7 @@ sub process { =20 if ($line =3D~ /^.\s*(Q(?:S?LIST|SIMPLEQ|TAILQ)_HEAD)\s*\(\s*[^,]/ && $line !~ /^.typedef/) { - ERROR("named $1 should be typedefed separately\n" . $herecurr); + ERROR("named $1 should be typedefed separately\n" . $herecurr); } =20 # Need a space before open parenthesis after if, while etc @@ -3118,48 +3118,48 @@ sub process { =20 # Qemu error function tests =20 - # Find newlines in error messages - my $qemu_error_funcs =3D qr{error_setg| - error_setg_errno| - error_setg_win32| - error_setg_file_open| - error_set| - error_prepend| - warn_reportf_err| - error_reportf_err| - error_vreport| - warn_vreport| - info_vreport| - error_report| - warn_report| - info_report| - g_test_message}x; - - if ($rawline =3D~ /\b(?:$qemu_error_funcs)\s*\(.*\".*\\n/) { - ERROR("Error messages should not contain newlines\n" . $herecurr); - } + # Find newlines in error messages + my $qemu_error_funcs =3D qr{error_setg| + error_setg_errno| + error_setg_win32| + error_setg_file_open| + error_set| + error_prepend| + warn_reportf_err| + error_reportf_err| + error_vreport| + warn_vreport| + info_vreport| + error_report| + warn_report| + info_report| + g_test_message}x; + + if ($rawline =3D~ /\b(?:$qemu_error_funcs)\s*\(.*\".*\\n/) { + ERROR("Error messages should not contain newlines\n" . $herecurr); + } =20 - # Continue checking for error messages that contains newlines. This - # check handles cases where string literals are spread over multiple line= s. - # Example: - # error_report("Error msg line #1" - # "Error msg line #2\n"); - my $quoted_newline_regex =3D qr{\+\s*\".*\\n.*\"}; - my $continued_str_literal =3D qr{\+\s*\".*\"}; + # Continue checking for error messages that contains newlines. This + # check handles cases where string literals are spread over multiple lin= es. + # Example: + # error_report("Error msg line #1" + # "Error msg line #2\n"); + my $quoted_newline_regex =3D qr{\+\s*\".*\\n.*\"}; + my $continued_str_literal =3D qr{\+\s*\".*\"}; =20 - if ($rawline =3D~ /$quoted_newline_regex/) { - # Backtrack to first line that does not contain only a quoted literal - # and assume that it is the start of the statement. - my $i =3D $linenr - 2; + if ($rawline =3D~ /$quoted_newline_regex/) { + # Backtrack to first line that does not contain only a quoted literal + # and assume that it is the start of the statement. + my $i =3D $linenr - 2; =20 - while (($i >=3D 0) & $rawlines[$i] =3D~ /$continued_str_literal/) { - $i--; - } + while (($i >=3D 0) & $rawlines[$i] =3D~ /$continued_str_literal/) { + $i--; + } =20 - if ($rawlines[$i] =3D~ /\b(?:$qemu_error_funcs)\s*\(/) { - ERROR("Error messages should not contain newlines\n" . $herecurr); + if ($rawlines[$i] =3D~ /\b(?:$qemu_error_funcs)\s*\(/) { + ERROR("Error messages should not contain newlines\n" . $herecurr); + } } - } =20 # check for non-portable libc calls that have portable alternatives in QEMU if ($line =3D~ /\bffs\(/) { --=20 2.49.0 From nobody Sat Nov 15 20:48:57 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1747672743; cv=none; d=zohomail.com; s=zohoarc; b=mf4Cc6Gq4ugZk5N2PzKIjSIJ5wIQZQMLmmElAYXh5o94pMtHXCWl+O03iouOmKtbGiYp1wIcsdfKyYT5bGAUZqsV8MlK55iUa48j1GCNKvfrjScCtwcf4b0iozWyCCTbwgbgThCf90g/O7HxUKFWeyG95g07T/a0Z6v0P+hDPFc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747672743; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=KWHP90eJKf02CTAZoqxu4x58UKkV50XNU1BADJ5KN6w=; b=SexxENU/XnEvXVvg0IDphoI0dQt1/UUIiYmJYfjoIzxK7W9fT4JKUWj9eAkLf7sBSVWpP6mLWquu0CtFdGXDlz1GRZstvT67nMAaxmpJXbcrDIPpmFcAwjZT84hSfb2GpcrKxWyNd0+2iU5b0J3FgETkJkXhEkLnz6kqWvYq0P0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1747672743437345.5879768663315; Mon, 19 May 2025 09:39:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uH3Uk-0002ho-Eh; Mon, 19 May 2025 12:37:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uH3Ui-0002eF-9W for qemu-devel@nongnu.org; Mon, 19 May 2025 12:37:40 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uH3Ug-0005ix-3W for qemu-devel@nongnu.org; Mon, 19 May 2025 12:37:40 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-443-CSxy1bgsMy2aktZgocaR2w-1; Mon, 19 May 2025 12:37:35 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 77D631800772; Mon, 19 May 2025 16:37:34 +0000 (UTC) Received: from toolbx.redhat.com (unknown [10.42.28.50]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 5051419560A3; Mon, 19 May 2025 16:37:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1747672657; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KWHP90eJKf02CTAZoqxu4x58UKkV50XNU1BADJ5KN6w=; b=UVuujxoZ9RbZME1OtwjXPiLXcK5iev/zG+bzEh7d9aEavmISB2zBwf4d3tUGdQxDS9HeEy q3fH7QjOd2KHq61oZ23ngOAc0HkQ4XhnRoJxkzjhgTJOfRPkeGEBuejYcGajvzBUiy/Zux NCJzakbjgvAmFcOtHpUL45ZmKnbs8zU= X-MC-Unique: CSxy1bgsMy2aktZgocaR2w-1 X-Mimecast-MFC-AGG-ID: CSxy1bgsMy2aktZgocaR2w_1747672654 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH v4 3/9] scripts/checkpatch: introduce tracking of file start/end Date: Mon, 19 May 2025 17:37:15 +0100 Message-ID: <20250519163721.347322-4-berrange@redhat.com> In-Reply-To: <20250519163721.347322-1-berrange@redhat.com> References: <20250519163721.347322-1-berrange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.13, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=-1, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1747672745257116600 Some checks want to be performed either at the start of a new file within a patch, or at the end. This is complicated by the fact that the information relevant to the check may be spread across multiple lines. It is further complicated by a need to support both git and non-git diffs, and special handling for renames where there might not be any patch hunks. To handle this more sanely, introduce explicit tracking of file start/end, taking account of git metadata, and calling a hook function at each transition. Reviewed-by: C=C3=A9dric Le Goater Reviewed-by: Peter Maydell Signed-off-by: Daniel P. Berrang=C3=A9 --- scripts/checkpatch.pl | 110 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 107 insertions(+), 3 deletions(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 7675418b0b..82056dcd24 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -1417,6 +1417,39 @@ sub checkspdx { } } =20 +# All three of the methods below take a 'file info' record +# which is a hash ref containing +# +# 'isgit': 1 if an enhanced git diff or 0 for a plain diff +# 'githeader': 1 if still parsing git patch header, 0 otherwise +# 'linestart': line number of start of file diff +# 'lineend': line number of end of file diff +# 'filenew': the new filename +# 'fileold': the old filename (same as 'new filename' except +# for renames in git diffs) +# 'action': one of 'modified' (always) or 'new' or 'deleted' or +# 'renamed' (git diffs only) +# 'mode': file mode for new/deleted files (git diffs only) +# 'similarity': file similarity when renamed (git diffs only) +# 'facts': hash ref for storing any metadata related to checks +# + +# Called at the end of each patch, with the list of +# real filenames that were seen in the patch +sub process_file_list { + my @fileinfos =3D @_; +} + +# Called at the start of processing a diff hunk for a file +sub process_start_of_file { + my $fileinfo =3D shift; +} + +# Called at the end of processing a diff hunk for a file +sub process_end_of_file { + my $fileinfo =3D shift; +} + sub process { my $filename =3D shift; =20 @@ -1453,7 +1486,10 @@ sub process { my $realfile =3D ''; my $realline =3D 0; my $realcnt =3D 0; + my $fileinfo; + my @fileinfolist; my $here =3D ''; + my $oldhere =3D ''; my $in_comment =3D 0; my $comment_edge =3D 0; my $first_line =3D 0; @@ -1591,17 +1627,56 @@ sub process { $prefix =3D "$filename:$realline: " if ($emacs && $file); $prefix =3D "$filename:$linenr: " if ($emacs && !$file); =20 + $oldhere =3D $here; $here =3D "#$linenr: " if (!$file); $here =3D "#$realline: " if ($file); =20 # extract the filename as it passes - if ($line =3D~ /^diff --git.*?(\S+)$/) { - $realfile =3D $1; - $realfile =3D~ s@^([^/]*)/@@ if (!$file); + if ($line =3D~ /^diff --git\s+(\S+)\s+(\S+)$/) { + my $fileold =3D $1; + my $filenew =3D $2; + + if (defined $fileinfo) { + $fileinfo->{lineend} =3D $oldhere; + process_end_of_file($fileinfo) + } + $fileold =3D~ s@^([^/]*)/@@ if (!$file); + $filenew =3D~ s@^([^/]*)/@@ if (!$file); + $realfile =3D $filenew; checkfilename($realfile, \$acpi_testexpected, \$acpi_nont= estexpected); + + $fileinfo =3D { + "isgit" =3D> 1, + "githeader" =3D> 1, + "linestart" =3D> $here, + "lineend" =3D> 0, + "fileold" =3D> $fileold, + "filenew" =3D> $filenew, + "action" =3D> "modified", + "mode" =3D> 0, + "similarity" =3D> 0, + "facts" =3D> {}, + }; + push @fileinfolist, $fileinfo; + } elsif (defined $fileinfo && $fileinfo->{githeader} && + $line =3D~ /^(new|deleted) (?:file )?mode\s+([0-7]+)$/) { + $fileinfo->{action} =3D $1; + $fileinfo->{mode} =3D oct($2); + } elsif (defined $fileinfo && $fileinfo->{githeader} && + $line =3D~ /^similarity index (\d+)%/) { + $fileinfo->{similarity} =3D int($1); + } elsif (defined $fileinfo && $fileinfo->{githeader} && + $line =3D~ /^rename (from|to) [\w\/\.\-]+\s*$/) { + $fileinfo->{action} =3D "renamed"; + # For a no-change rename, we'll never have any "+++..." + # lines, so trigger actions now + if ($1 eq "to" && $fileinfo->{similarity} =3D=3D 100) { + process_start_of_file($fileinfo); + } } elsif ($line =3D~ /^\+\+\+\s+(\S+)/) { $realfile =3D $1; $realfile =3D~ s@^([^/]*)/@@ if (!$file); + checkfilename($realfile, \$acpi_testexpected, \$acpi_nont= estexpected); =20 $p1_prefix =3D $1; @@ -1610,6 +1685,30 @@ sub process { WARN("patch prefix '$p1_prefix' exists, appears to be a -p0 patch\n"); } =20 + if (defined $fileinfo && !$fileinfo->{isgit}) { + $fileinfo->{lineend} =3D $oldhere; + process_end_of_file($fileinfo); + } + + if (!defined $fileinfo || !$fileinfo->{isgit}) { + $fileinfo =3D { + "isgit" =3D> 0, + "githeader" =3D> 0, + "linestart" =3D> $here, + "lineend" =3D> 0, + "fileold" =3D> $realfile, + "filenew" =3D> $realfile, + "action" =3D> "modified", + "mode" =3D> 0, + "similarity" =3D> 0, + "facts" =3D> {}, + }; + push @fileinfolist, $fileinfo; + } else { + $fileinfo->{githeader} =3D 0; + } + process_start_of_file($fileinfo); + next; } =20 @@ -3213,6 +3312,11 @@ sub process { } } =20 + if (defined $fileinfo) { + process_end_of_file($fileinfo); + } + process_file_list(@fileinfolist); + if ($is_patch && $chk_signoff && $signoff =3D=3D 0) { ERROR("Missing Signed-off-by: line(s)\n"); } --=20 2.49.0 From nobody Sat Nov 15 20:48:57 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1747672775; cv=none; d=zohomail.com; s=zohoarc; b=oGrPlT7F4as79DOT1AcomwN5rW1DwELpEhnyOGc5yx0tgWsAoE2cyKUTtTKibJXH3lUJ6j9OepHw/U5P3CBZ6OAGupLAUveVHYUm2EFKBzJwM/Dt5UQwpP8Zuth1vaJHsOG8j3Z1BoW8NZE2vYvKLHZHFPcwT2s3r61IjaMW5Ko= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747672775; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=AcM26vXczQLNBJGv0uqc1uZ7aik0JS+BDC4m3OHXOGM=; b=Nm4RawzBmMDD/5hhqyTmAoqsJh6Opel7+2iX76FRlWCZPYEHEiI46kJ73+hGknOj9A2VUJ4nHA+L1bNNdgKBXdxoaqiBFlUcAzH1JeihO3M4Z+gerowsLau0fAyjJ7ZQ/1y8XbQSxy+3m6c5PFQAavnVaMNIhm2AMYkHrZ7lGVA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1747672775852472.7585588299886; Mon, 19 May 2025 09:39:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uH3Um-0002kJ-5u; Mon, 19 May 2025 12:37:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uH3Uj-0002h0-Tz for qemu-devel@nongnu.org; Mon, 19 May 2025 12:37:41 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uH3Ui-0005j7-3R for qemu-devel@nongnu.org; Mon, 19 May 2025 12:37:41 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-224-8FNOnEwCPIeN4CIuQBplVw-1; Mon, 19 May 2025 12:37:38 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 2B19C1956086; Mon, 19 May 2025 16:37:37 +0000 (UTC) Received: from toolbx.redhat.com (unknown [10.42.28.50]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 1456219560A3; Mon, 19 May 2025 16:37:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1747672659; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AcM26vXczQLNBJGv0uqc1uZ7aik0JS+BDC4m3OHXOGM=; b=MEa8yNVNeS+MALiYTKAW7+exoBBFT4KNlmdp5D6vJC2AmIZ7XbBC9lsUJGmA4W5OCSOWG0 hKOcM0rNXJZD8ddmB0C3PJrkivHKqNBNiJIkkkjz2ngJDhtCUOpMs2zuRm/hDPGzkJaE2F mmI1hfskVjGBIJ8x//MEW+XqynmMzW4= X-MC-Unique: 8FNOnEwCPIeN4CIuQBplVw-1 X-Mimecast-MFC-AGG-ID: 8FNOnEwCPIeN4CIuQBplVw_1747672657 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PATCH v4 4/9] scripts/checkpatch: use new hook for ACPI test data check Date: Mon, 19 May 2025 17:37:16 +0100 Message-ID: <20250519163721.347322-5-berrange@redhat.com> In-Reply-To: <20250519163721.347322-1-berrange@redhat.com> References: <20250519163721.347322-1-berrange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.13, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=-1, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1747672777497116600 The ACPI test data check needs to analyse a list of all files in a commit, so can use the new hook for processing the file list. Reviewed-by: Peter Maydell Signed-off-by: Daniel P. Berrang=C3=A9 --- scripts/checkpatch.pl | 61 ++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 32 deletions(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 82056dcd24..60c26dca06 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -1330,29 +1330,6 @@ sub WARN { } } =20 -# According to tests/qtest/bios-tables-test.c: do not -# change expected file in the same commit with adding test -sub checkfilename { - my ($name, $acpi_testexpected, $acpi_nontestexpected) =3D @_; - - # Note: shell script that rebuilds the expected files is in the sa= me - # directory as files themselves. - # Note: allowed diff list can be changed both when changing expect= ed - # files and when changing tests. - if ($name =3D~ m#^tests/data/acpi/# and not $name =3D~ m#^\.sh$#) { - $$acpi_testexpected =3D $name; - } elsif ($name !~ m#^tests/qtest/bios-tables-test-allowed-diff.h$#) { - $$acpi_nontestexpected =3D $name; - } - if (defined $$acpi_testexpected and defined $$acpi_nontestexpected) { - ERROR("Do not add expected files together with tests, " . - "follow instructions in " . - "tests/qtest/bios-tables-test.c: both " . - $$acpi_testexpected . " and " . - $$acpi_nontestexpected . " found\n"); - } -} - sub checkspdx { my ($file, $expr) =3D @_; =20 @@ -1438,6 +1415,34 @@ sub checkspdx { # real filenames that were seen in the patch sub process_file_list { my @fileinfos =3D @_; + + # According to tests/qtest/bios-tables-test.c: do not + # change expected file in the same commit with adding test + my @acpi_testexpected; + my @acpi_nontestexpected; + + foreach my $fileinfo (@fileinfos) { + # Note: shell script that rebuilds the expected files is in + # the same directory as files themselves. + # Note: allowed diff list can be changed both when changing + # expected files and when changing tests. + if ($fileinfo->{filenew} =3D~ m#^tests/data/acpi/# && + $fileinfo->{filenew} !~ m#^\.sh$#) { + push @acpi_testexpected, $fileinfo->{filenew}; + } elsif ($fileinfo->{filenew} !~ + m#^tests/qtest/bios-tables-test-allowed-diff.h$#) { + push @acpi_nontestexpected, $fileinfo->{filenew}; + } + } + if (int(@acpi_testexpected) > 0 and int(@acpi_nontestexpected) > 0) { + ERROR("Do not add expected files together with tests, " . + "follow instructions in " . + "tests/qtest/bios-tables-test.c. Files\n\n " . + join("\n ", @acpi_testexpected) . + "\n\nand\n\n " . + join("\n ", @acpi_nontestexpected) . + "\n\nfound in the same patch\n"); + } } =20 # Called at the start of processing a diff hunk for a file @@ -1502,9 +1507,6 @@ sub process { my %suppress_whiletrailers; my %suppress_export; =20 - my $acpi_testexpected; - my $acpi_nontestexpected; - # Pre-scan the patch sanitizing the lines. =20 sanitise_line_reset(); @@ -1643,7 +1645,6 @@ sub process { $fileold =3D~ s@^([^/]*)/@@ if (!$file); $filenew =3D~ s@^([^/]*)/@@ if (!$file); $realfile =3D $filenew; - checkfilename($realfile, \$acpi_testexpected, \$acpi_nont= estexpected); =20 $fileinfo =3D { "isgit" =3D> 1, @@ -1677,8 +1678,6 @@ sub process { $realfile =3D $1; $realfile =3D~ s@^([^/]*)/@@ if (!$file); =20 - checkfilename($realfile, \$acpi_testexpected, \$acpi_nont= estexpected); - $p1_prefix =3D $1; if (!$file && $tree && $p1_prefix ne '' && -e "$root/$p1_prefix") { @@ -1771,9 +1770,7 @@ sub process { $line =3D~ /^rename (?:from|to) [\w\/\.\-]+\s*$/ || ($line =3D~ /\{\s*([\w\/\.\-]*)\s*\=3D\>\s*([\w\/\.\-]*)\s*\}/ && (defined($1) || defined($2)))) && - !(($realfile ne '') && - defined($acpi_testexpected) && - ($realfile eq $acpi_testexpected))) { + $realfile !~ m#^tests/data/acpi/#) { $reported_maintainer_file =3D 1; WARN("added, moved or deleted file(s), does MAINTAINERS need updating?\= n" . $herecurr); } --=20 2.49.0 From nobody Sat Nov 15 20:48:57 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1747672704; cv=none; d=zohomail.com; s=zohoarc; b=TgpuB3o+FTLEXXIOfLWUEooD+DRc0CyI1FewVifWGnEwlvHg1hZlYkohEHFGroYSdzNRrkeSCPjKNARaT2JCdCRGuWHevqX+PvARAb8O276eoLYf5AWEs6dqJE96K7omlpLnaZqGmdgFyDY9AH1Cm4rYtYJDMLIV9T1syVtfmHg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747672704; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=h+dWRobRDbXf8iBk4tZlIYJHZdaGNMwO4PK4On7eRJ8=; b=D3g0QfUma1zTPFdfUCsHczBc23V8Me4sXSlq+755WfnFHyBNe21i/sXeJdwtrWHwTsjQ8gNGmQrPlDUiWciuWOeT8jjIzR2oRVul/G9CIs1wDUOyhNn5wHZKUrEUNXyEsyiCV5rITVW7W+ttjuXgBya9/Glve2zkhZXuSYiYPbY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1747672704661486.97649904681464; Mon, 19 May 2025 09:38:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uH3Uq-0002lo-13; Mon, 19 May 2025 12:37:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uH3Up-0002ld-2H for qemu-devel@nongnu.org; Mon, 19 May 2025 12:37:47 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uH3Un-0005ji-HG for qemu-devel@nongnu.org; Mon, 19 May 2025 12:37:46 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-114-X_X-p9OyMB2N81h7YgHVFQ-1; Mon, 19 May 2025 12:37:41 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 04AEC1800773; Mon, 19 May 2025 16:37:40 +0000 (UTC) Received: from toolbx.redhat.com (unknown [10.42.28.50]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id BD30619560A3; Mon, 19 May 2025 16:37:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1747672664; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=h+dWRobRDbXf8iBk4tZlIYJHZdaGNMwO4PK4On7eRJ8=; b=DlIbTshw8m0SJ8taw62yAvmLjVEBVQGyWVaklq9QH/lyz/kpZn1vbWldvJkEYbCWlEN6nc OEd7GWbm4YsaHaCmQmfM7CvtJaavdhjvwc/xuNR+wOu8qfEaAa3+wOPKNMBYntUDxR5Crv jmzqN1m8yC0ugmocTnb7gHp9NruOcFQ= X-MC-Unique: X_X-p9OyMB2N81h7YgHVFQ-1 X-Mimecast-MFC-AGG-ID: X_X-p9OyMB2N81h7YgHVFQ_1747672660 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH v4 5/9] scripts/checkpatch: use new hook for file permissions check Date: Mon, 19 May 2025 17:37:17 +0100 Message-ID: <20250519163721.347322-6-berrange@redhat.com> In-Reply-To: <20250519163721.347322-1-berrange@redhat.com> References: <20250519163721.347322-1-berrange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.13, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=-1, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1747672706394116600 The file permissions check is the kind of check intended to be performed in the new start of file hook. Reviewed-by: C=C3=A9dric Le Goater Reviewed-by: Peter Maydell Signed-off-by: Daniel P. Berrang=C3=A9 --- scripts/checkpatch.pl | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 60c26dca06..e208222e75 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -1448,6 +1448,17 @@ sub process_file_list { # Called at the start of processing a diff hunk for a file sub process_start_of_file { my $fileinfo =3D shift; + + # Check for incorrect file permissions + if ($fileinfo->{action} eq "new" && ($fileinfo->{mode} & 0111)) { + my $permhere =3D $fileinfo->{linestart} . "FILE: " . + $fileinfo->{filenew} . "\n"; + if ($fileinfo->{filenew} =3D~ + /(\bMakefile(?:\.objs)?|\.(c|cc|cpp|h|mak|s|S))$/) { + ERROR("do not set execute permissions for source " . + "files\n" . $permhere); + } + } } =20 # Called at the end of processing a diff hunk for a file @@ -1719,14 +1730,6 @@ sub process { =20 $cnt_lines++ if ($realcnt !=3D 0); =20 -# Check for incorrect file permissions - if ($line =3D~ /^new (file )?mode.*[7531]\d{0,2}$/) { - my $permhere =3D $here . "FILE: $realfile\n"; - if ($realfile =3D~ /(\bMakefile(?:\.objs)?|\.c|\.cc|\.cpp|\.h|\.mak|\.[= sS])$/) { - ERROR("do not set execute permissions for source files\n" . $permhere); - } - } - # Only allow Python 3 interpreter if ($realline =3D=3D 1 && $line =3D~ /^\+#!\ *\/usr\/bin\/(?:env )?python$/) { --=20 2.49.0 From nobody Sat Nov 15 20:48:57 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1747672693; cv=none; d=zohomail.com; s=zohoarc; b=dWoeKOlBVr9mZeSHCx2NDuTayWJusYwD8Ts2iAZHCdVqzid6iMfLmVzXZUYlgGqboo0rENY57ypEz6PyNxIdwsyybm8imEyeNM0+ucbsufJ3F+6IH9BEXWAo64WTYwTuNiOcqC6bFH57bJ4MHhfLZcNhac/vJjzeAGy2oRjKdXA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747672693; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=c4E8rgHsQb3gq0oCSF5CNcRbOTsrBL7NcaTAez1HiMI=; b=n0zyJIYPajcVQjc9YzbU6cxMzOckl7fix8+2s6DS0ecnIuOw4Imf+ZEx1msSZ0snCkGMCS59+vSwFPp67FrqmhRGR+PNUslaZRWnWagxJvj/rC0lQHrgPcWYZg9GPr4JQGA5nhNiRb9ZkfQpxvskeL+CXPo/e3FVJB+F2elXiLA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1747672693835276.1791313532668; Mon, 19 May 2025 09:38:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uH3Uw-0002n6-NA; Mon, 19 May 2025 12:37:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uH3Uv-0002mR-8B for qemu-devel@nongnu.org; Mon, 19 May 2025 12:37:53 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uH3Uo-0005jo-I6 for qemu-devel@nongnu.org; Mon, 19 May 2025 12:37:52 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-262-lQRbvO_lPYGuPwLrZNztIQ-1; Mon, 19 May 2025 12:37:43 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 90E3C1800368; Mon, 19 May 2025 16:37:42 +0000 (UTC) Received: from toolbx.redhat.com (unknown [10.42.28.50]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 786CE19560AB; Mon, 19 May 2025 16:37:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1747672666; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=c4E8rgHsQb3gq0oCSF5CNcRbOTsrBL7NcaTAez1HiMI=; b=iZJA/ap2SQf4WhjcXtD3du63ClypyoltdYnwdNVz/fKxT5G4Lcf/l4PbiKqU1MaW7pH49g J0LoAy2xHIvBrJW47UBDKrgAAU3HND1aqN359K3zFr13EdsJNA5Nsj2XSagorfAJX8uiRZ Dj7cDh0P5JyeGMBFGsySLViq/gF4XDs= X-MC-Unique: lQRbvO_lPYGuPwLrZNztIQ-1 X-Mimecast-MFC-AGG-ID: lQRbvO_lPYGuPwLrZNztIQ_1747672662 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH v4 6/9] scripts/checkpatch: expand pattern for matching makefiles Date: Mon, 19 May 2025 17:37:18 +0100 Message-ID: <20250519163721.347322-7-berrange@redhat.com> In-Reply-To: <20250519163721.347322-1-berrange@redhat.com> References: <20250519163721.347322-1-berrange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.13, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=-1, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1747672702389116600 The current regex matches Makefile & Makefile.objs, but the latter is no longer used, anjd we're missing coverage of Makefile.include and Makefile.target. Expand the pattern to match any suffix. Reviewed-by: C=C3=A9dric Le Goater Reviewed-by: Peter Maydell Signed-off-by: Daniel P. Berrang=C3=A9 --- scripts/checkpatch.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index e208222e75..2c8e8135b6 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -1454,7 +1454,7 @@ sub process_start_of_file { my $permhere =3D $fileinfo->{linestart} . "FILE: " . $fileinfo->{filenew} . "\n"; if ($fileinfo->{filenew} =3D~ - /(\bMakefile(?:\.objs)?|\.(c|cc|cpp|h|mak|s|S))$/) { + /(\bMakefile.*|\.(c|cc|cpp|h|mak|s|S))$/) { ERROR("do not set execute permissions for source " . "files\n" . $permhere); } --=20 2.49.0 From nobody Sat Nov 15 20:48:57 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1747672772; cv=none; d=zohomail.com; s=zohoarc; b=k1yQKVO/Tnh4CABo2fLOUEcGcIuzPeUYfE5Dcl04NfqkWaq9tntkjzRyu5y1lGtlE+x4PtxBzYb9blgV4EIrIXaZ/XV1zsJ5+4TQfV39wnwWdGGESMa4+oNF5hKLDALZfMMyuuQy5486tahfcYAjg4OyaNdhxIPNu5cyUWwsMWA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747672772; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=nf8LkFWMBn9+9mPkCxsByAQm9qHcIlr5yFs/l+ijCoI=; b=kPGWkj4SdUV3PdQF+5j5/nnVJLtH8uQq7Q0wcQ6+rWQA0QklrE1LMDvMNd53NdIpygOc8KzydvltKxAkuCTv1bqE5+b3cppvAf6Hzp+RkvWtHGP1E/MZHhTERyuVWCjhXZklvZk4VkCSkFbxyBKEQkqsOnJSqp8BtHk9AmnzBD8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1747672772528595.0104932669078; Mon, 19 May 2025 09:39:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uH3Uv-0002md-KX; Mon, 19 May 2025 12:37:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uH3Ut-0002mH-RC for qemu-devel@nongnu.org; Mon, 19 May 2025 12:37:51 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uH3Us-0005k7-6A for qemu-devel@nongnu.org; Mon, 19 May 2025 12:37:51 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-36-EQGbdcl3Oj-caUtcwQ-zlw-1; Mon, 19 May 2025 12:37:46 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 870FC1800446; Mon, 19 May 2025 16:37:45 +0000 (UTC) Received: from toolbx.redhat.com (unknown [10.42.28.50]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 2848E19560AB; Mon, 19 May 2025 16:37:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1747672669; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nf8LkFWMBn9+9mPkCxsByAQm9qHcIlr5yFs/l+ijCoI=; b=Yneh2VUezOHvXYcI10NPtYMIIMwIYrz0wXJ5jfWght1hpVDeUBntlk7dWZY0nlrI2lQqNv UyP8JPZn0NXqrg031DD74jbHB6y6qPo5UuQoSpVQCa8shdpmMo5jlu/n/ZalHNQ7IuEwyH e1LTYqcPN3OEFfn4FOVBXlN2fcsRRqA= X-MC-Unique: EQGbdcl3Oj-caUtcwQ-zlw-1 X-Mimecast-MFC-AGG-ID: EQGbdcl3Oj-caUtcwQ-zlw_1747672665 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH v4 7/9] scripts/checkpatch: use new hook for MAINTAINERS update check Date: Mon, 19 May 2025 17:37:19 +0100 Message-ID: <20250519163721.347322-8-berrange@redhat.com> In-Reply-To: <20250519163721.347322-1-berrange@redhat.com> References: <20250519163721.347322-1-berrange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.13, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=-1, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1747672773401116600 When seeing a new/deleted/renamed file we check to see if MAINTAINERS is updated, but we don't give the user a list of files affected, as we don't want to repeat the same warning many times over. Using the new file list hook, we can give a single warning at the end with a list of filenames included. Reviewed-by: C=C3=A9dric Le Goater Reviewed-by: Peter Maydell Signed-off-by: Daniel P. Berrang=C3=A9 --- scripts/checkpatch.pl | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 2c8e8135b6..de6ea2fc14 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -1443,6 +1443,25 @@ sub process_file_list { join("\n ", @acpi_nontestexpected) . "\n\nfound in the same patch\n"); } + + my $sawmaintainers =3D 0; + my @maybemaintainers; + foreach my $fileinfo (@fileinfos) { + if ($fileinfo->{action} ne "modified" && + $fileinfo->{filenew} !~ m#^tests/data/acpi/#) { + push @maybemaintainers, $fileinfo->{filenew}; + } + if ($fileinfo->{filenew} eq "MAINTAINERS") { + $sawmaintainers =3D 1; + } + } + + # If we don't see a MAINTAINERS update, prod the user to check + if (int(@maybemaintainers) > 0 && !$sawmaintainers) { + WARN("added, moved or deleted file(s):\n\n " . + join("\n ", @maybemaintainers) . + "\n\nDoes MAINTAINERS need updating?\n"); + } } =20 # Called at the start of processing a diff hunk for a file @@ -1486,7 +1505,6 @@ sub process { =20 my $in_header_lines =3D $file ? 0 : 1; my $in_commit_log =3D 0; #Scanning lines before patch - my $reported_maintainer_file =3D 0; my $reported_mixing_imported_file =3D 0; my $in_imported_file =3D 0; my $in_no_imported_file =3D 0; @@ -1761,23 +1779,6 @@ sub process { } } =20 -# Check if MAINTAINERS is being updated. If so, there's probably no need = to -# emit the "does MAINTAINERS need updating?" message on file add/move/dele= te - if ($line =3D~ /^\s*MAINTAINERS\s*\|/) { - $reported_maintainer_file =3D 1; - } - -# Check for added, moved or deleted files - if (!$reported_maintainer_file && !$in_commit_log && - ($line =3D~ /^(?:new|deleted) file mode\s*\d+\s*$/ || - $line =3D~ /^rename (?:from|to) [\w\/\.\-]+\s*$/ || - ($line =3D~ /\{\s*([\w\/\.\-]*)\s*\=3D\>\s*([\w\/\.\-]*)\s*\}/ && - (defined($1) || defined($2)))) && - $realfile !~ m#^tests/data/acpi/#) { - $reported_maintainer_file =3D 1; - WARN("added, moved or deleted file(s), does MAINTAINERS need updating?\= n" . $herecurr); - } - # Check SPDX-License-Identifier references a permitted license if ($rawline =3D~ m,SPDX-License-Identifier: (.*?)(\*/)?\s*$,) { &checkspdx($realfile, $1); --=20 2.49.0 From nobody Sat Nov 15 20:48:57 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1747672710; cv=none; d=zohomail.com; s=zohoarc; b=F6M8p85kb3LkrcJtn3TfgUZdXflGS8aJbnKGQmljSEKhxrQOrOhtDbxRqUTatN1bdMEEk5WixFGX/3t+jxwhOaI/NPlqxb9hmaG8JzZKl+ZedYupc3IIHPY0rZLQisDB4RCRxZcaAqVj/2F7P9iIkJX3EGXjRG2Sc3FMNUah4TQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747672710; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=PIUaRKuYcvrrpm/JrbDy5K1w1botK8DhkqScYbEn/0g=; b=T++85AkVUccWSDrVKMujLyvmVYj6YQY1uBeCUoARerWsOU+C/prm4arjZmLeAkWHWszSon+X6bUO0UzWudoTqtBvKWUWZOUpgksIR9a1y8823FO4p6o81cLEkqVLJna3I7Z42uhj7AOiBbCaFmC3p9V4RZKI5hGjr77m/2VSqd8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1747672710103882.9310860677286; Mon, 19 May 2025 09:38:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uH3Uz-0002qA-Ab; Mon, 19 May 2025 12:37:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uH3Ux-0002nJ-74 for qemu-devel@nongnu.org; Mon, 19 May 2025 12:37:55 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uH3Uv-0005kR-Ff for qemu-devel@nongnu.org; Mon, 19 May 2025 12:37:54 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-168-Cavy5Gi9MQyQjliDmnXwUA-1; Mon, 19 May 2025 12:37:49 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4C1F61800877; Mon, 19 May 2025 16:37:48 +0000 (UTC) Received: from toolbx.redhat.com (unknown [10.42.28.50]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 5043619560AB; Mon, 19 May 2025 16:37:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1747672672; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PIUaRKuYcvrrpm/JrbDy5K1w1botK8DhkqScYbEn/0g=; b=Z1mSDZMc0EZw/j4BS/aYrSKsLo15YE4vkU8GFpiK9Xne2EDk8ecNoObqh3kHyqhzm58tvw wjKhQE3uSHaMCNlZS25UlIdwWFYOyFo5VHRzRSOaawqNj2WHsVp7BPQv4UQPjYqFOiFIeR 0phl7BhH3VyvKDkS5r0zs9+J91oFrBI= X-MC-Unique: Cavy5Gi9MQyQjliDmnXwUA-1 X-Mimecast-MFC-AGG-ID: Cavy5Gi9MQyQjliDmnXwUA_1747672668 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH v4 8/9] scripts/checkpatch: reimplement mandate for SPDX-License-Identifier Date: Mon, 19 May 2025 17:37:20 +0100 Message-ID: <20250519163721.347322-9-berrange@redhat.com> In-Reply-To: <20250519163721.347322-1-berrange@redhat.com> References: <20250519163721.347322-1-berrange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.13, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=-1, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1747672712332116600 Going forward we want all newly created source files to have an SPDX-License-Identifier tag present. Initially mandate this for C, Python, Perl, Shell source files, as well as JSON (QAPI) and Makefiles, while encouraging users to consider it for other file types. The new attempt at detecting missing SPDX-License-Identifier relies on the hooks for relying triggering logic at the end of scanning a new file in the diff. Tested-by: C=C3=A9dric Le Goater Reviewed-by: C=C3=A9dric Le Goater Reviewed-by: Peter Maydell Signed-off-by: Daniel P. Berrang=C3=A9 --- scripts/checkpatch.pl | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index de6ea2fc14..dc2c3e6aa1 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -1483,6 +1483,20 @@ sub process_start_of_file { # Called at the end of processing a diff hunk for a file sub process_end_of_file { my $fileinfo =3D shift; + + if ($fileinfo->{action} eq "new" && + !exists $fileinfo->{facts}->{sawspdx}) { + if ($fileinfo->{filenew} =3D~ + /(\.(c|h|py|pl|sh|json|inc)|Makefile.*)$/) { + # source code files MUST have SPDX license declared + ERROR("New file '" . $fileinfo->{filenew} . + "' requires 'SPDX-License-Identifier'"); + } else { + # Other files MAY have SPDX license if appropriate + WARN("Does new file '" . $fileinfo->{filenew} . + "' need 'SPDX-License-Identifier'?"); + } + } } =20 sub process { @@ -1781,6 +1795,7 @@ sub process { =20 # Check SPDX-License-Identifier references a permitted license if ($rawline =3D~ m,SPDX-License-Identifier: (.*?)(\*/)?\s*$,) { + $fileinfo->{facts}->{sawspdx} =3D 1; &checkspdx($realfile, $1); } =20 --=20 2.49.0 From nobody Sat Nov 15 20:48:57 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1747672745; cv=none; d=zohomail.com; s=zohoarc; b=QSnsGI5jhqJtWcnCKYebz3W3CcaXf4PlvwnDHYD8aFGuVwFnz8YqitliGVFpyWX3c+udlYyYZJx9j0BpbvAO4RFbCheTPWwqnRKrFTc1WEykN6H0NRyA0iIXcr769AGRIDuKAOXWdTaA10M8vlVz8X5bITG5R9rKgP91NfhN1bU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747672745; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=3v48TWij8rjIJBWVr32ofNj1KQbwMmnbi8Jfg7B65Q4=; b=j65VV4o8XC596jB3DTsGnSRo65YJjPnY4E5j+fqhHbrCBYcGtfOueFrGQcFsMnGAT5Ziju0pjybYOM2ooGfmXIIcbVTAHGS2z8NiPkuWeVSF5lP3aMR2Ea4sOZgYoszh/RqsnVey4AjeH0FixbPPPOdok8+etEGCj0JeWp518/U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1747672745738841.6160936231653; Mon, 19 May 2025 09:39:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uH3V0-0002ss-3n; Mon, 19 May 2025 12:37:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uH3Uy-0002p9-IQ for qemu-devel@nongnu.org; Mon, 19 May 2025 12:37:56 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uH3Uw-0005ke-U5 for qemu-devel@nongnu.org; Mon, 19 May 2025 12:37:56 -0400 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-77-bjJLirAaMsKFUaOPYEyiMA-1; Mon, 19 May 2025 12:37:51 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A6EB8195608C; Mon, 19 May 2025 16:37:50 +0000 (UTC) Received: from toolbx.redhat.com (unknown [10.42.28.50]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E03AC19560A3; Mon, 19 May 2025 16:37:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1747672674; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3v48TWij8rjIJBWVr32ofNj1KQbwMmnbi8Jfg7B65Q4=; b=DnnSwCB5+UUmG+pzC8WybEyQ04Sh3yMSF5MareXadRhD9LZSYij6KmsxgkMoWSz1BMjTB/ XVdCQyn90Gs/KIdpeodOcahk3IQdvfVsD1lvIOP066q81gpOVZqUziCVoTQDYr2H15iKUz GlrPgTQ8MXKnUpiuVpZW12wIv1yh9qA= X-MC-Unique: bjJLirAaMsKFUaOPYEyiMA-1 X-Mimecast-MFC-AGG-ID: bjJLirAaMsKFUaOPYEyiMA_1747672670 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PATCH v4 9/9] scripts/checkpatch: reject license boilerplate on new files Date: Mon, 19 May 2025 17:37:21 +0100 Message-ID: <20250519163721.347322-10-berrange@redhat.com> In-Reply-To: <20250519163721.347322-1-berrange@redhat.com> References: <20250519163721.347322-1-berrange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.13, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=-1, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1747672747102116600 The previous commit mandates use of SPDX-License-Identifier on common source files, and encourages it on all other files. Some contributors are none the less still also including the license boilerplate text. This is redundant and will potentially cause trouble if inconsistent with the SPDX declaration. Match common boilerplate text blurbs and report them as invalid, for newly added files. Reviewed-by: Peter Maydell Signed-off-by: Daniel P. Berrang=C3=A9 --- scripts/checkpatch.pl | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index dc2c3e6aa1..691c267a8c 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -365,6 +365,17 @@ our @typeList =3D ( qr{guintptr}, ); =20 +# Match text found in common license boilerplate comments: +# for new files the SPDX-License-Identifier line is sufficient. +our $LICENSE_BOILERPLATE =3D qr{ + licensed under the terms of the GNU GPL| + under the terms of the GNU General Public License| + under the terms of the GNU Lesser General Public| + Permission is hereby granted, free of charge| + GNU GPL, version 2 or later| + See the COPYING file +}x; + # Load common spelling mistakes and build regular expression list. my $misspellings; my %spelling_fix; @@ -1497,6 +1508,13 @@ sub process_end_of_file { "' need 'SPDX-License-Identifier'?"); } } + if ($fileinfo->{action} eq "new" && + !exists $fileinfo->{facts}->{sawboilerplate}) { + ERROR("New file '" . $fileinfo->{filenew} . "' must " . + "not have license boilerplate header text, only " . + "the SPDX-License-Identifier, unless this file was " . + "copied from existing code already having such text."); + } } =20 sub process { @@ -1799,6 +1817,10 @@ sub process { &checkspdx($realfile, $1); } =20 + if ($rawline =3D~ /$LICENSE_BOILERPLATE/) { + $fileinfo->{facts}->{sawboilerplate} =3D 1; + } + if ($rawline =3D~ m,(SPDX-[a-zA-Z0-9-_]+):,) { my $tag =3D $1; my @permitted =3D qw( --=20 2.49.0