From nobody Sat Nov 15 20:48:53 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=1747074356; cv=none; d=zohomail.com; s=zohoarc; b=diTmmst6+dDulydhp6Y14I0jKH3/K+64+Jq+FQvEa5dPnwwJ6+8gDox2Ea6qy8OQnk37q2SLseSH5HuXl9QbTn6jr0Ov4nIZq8G+0MZObftYaTmEgs0KLnW1LUEu7kZlhpANw1OlHMq6m0xYA2hQt4oJWV7+XI7t+KjZqpwO3eE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747074356; 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=dTn4mAIvVZ0H/9QSNH5TjdbPdWCg8+LoMcGYhejbATM=; b=itNTMf09xadxL972/NMyrYohq5cbqCNr61tlzW8Xdmsz+LvhsfnOqW7lZQEplkkHgylCxCMSStEmyPWuZefOAsMX0MVjpg+bRrc7dd88KtxHPp0KUg48ooBS3p+qN3MeelEXG8hqprtKifyrW0Ju7wsaDBTmjyh90XDT6UmKxjE= 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 1747074356897314.68180467142804; Mon, 12 May 2025 11:25:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uEXqT-0003sl-NS; Mon, 12 May 2025 14:25:45 -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 1uEXpr-0003MZ-Jp for qemu-devel@nongnu.org; Mon, 12 May 2025 14:25:07 -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 1uEXpk-0002de-JU for qemu-devel@nongnu.org; Mon, 12 May 2025 14:25:07 -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-108-7JvsVxzeMDydc6BGO_ltWA-1; Mon, 12 May 2025 14:24:54 -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 62E4819541B1; Mon, 12 May 2025 18:24:52 +0000 (UTC) Received: from toolbx.redhat.com (unknown [10.42.28.162]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id DD13319560A3; Mon, 12 May 2025 18:24:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1747074298; 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=dTn4mAIvVZ0H/9QSNH5TjdbPdWCg8+LoMcGYhejbATM=; b=N+BuWmc61mJs61XcT6wcRZSPC3BfUX0zf0wx6c/i68HllYqgsHg4UmJq4EoIVLmlMbBOTS 0kdU7gKBsA0fvLV2lwtBGGlTSwLf+vSeJbN6LDNhMEtmuzzAWtKAg/4JNoYfHIGlhJF1UZ 6YtADuJghEPQ/Vn5N5f3mjZa3kL9sdk= X-MC-Unique: 7JvsVxzeMDydc6BGO_ltWA-1 X-Mimecast-MFC-AGG-ID: 7JvsVxzeMDydc6BGO_ltWA_1747074292 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 v2 1/7] Revert "scripts: mandate that new files have SPDX-License-Identifier" Date: Mon, 12 May 2025 19:24:41 +0100 Message-ID: <20250512182447.1139105-2-berrange@redhat.com> In-Reply-To: <20250512182447.1139105-1-berrange@redhat.com> References: <20250512182447.1139105-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: -35 X-Spam_score: -3.6 X-Spam_bar: --- X-Spam_report: (-3.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.551, 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=0.001, RCVD_IN_MSPIKE_WL=0.001, 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: 1747074357977116600 From: Daniel P. Berrang=C3=A9 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 Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: C=C3=A9dric Le Goater --- 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:53 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=1747074308; cv=none; d=zohomail.com; s=zohoarc; b=SMT1QMwTH9OT0y9siD1+R6+k5upX5uDOLUrHvy6TFNFD+ukR5P1SCX5RrZs2eaBnZYmsVfH2Ah5bGDXF0NKilVMOcJ3LxAAn7KnaJhB1HW1wbdDCdk8ykHhyWlCfSq66kSEM/yHfLROIkhhSvD7l8E98zocAKPeiz+lLgOo7Kss= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747074308; 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=Qk329cArnzB2cZaNtHlJKFaOAAaKC6oWqgsD7L1Zbw0=; b=UB/sXRgrf3z1UMG4lOyrHvogHNzO3JgG2vmVkplumFKhEkOw+BIllPuLzN6V2QRFSLlEOL/U8/jjzpkanFp00hYlUKW+Z24oSBzroAUwjHJvCw5reLewbay2wU+Fe01tGs5clFb2bO9hp1yAB5NmaynIXD1FGy82AwW9/c7Wghw= 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 1747074308197395.11162219256937; Mon, 12 May 2025 11:25:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uEXpm-0003Gl-P7; Mon, 12 May 2025 14:25:02 -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 1uEXpk-0003Ey-L6 for qemu-devel@nongnu.org; Mon, 12 May 2025 14:25:00 -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 1uEXpi-0002dX-Jv for qemu-devel@nongnu.org; Mon, 12 May 2025 14:25:00 -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-198-nR6yhAVbNeCgTp97wvZOhQ-1; Mon, 12 May 2025 14:24:55 -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 20CB81956080; Mon, 12 May 2025 18:24:54 +0000 (UTC) Received: from toolbx.redhat.com (unknown [10.42.28.162]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D29D319560A3; Mon, 12 May 2025 18:24:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1747074297; 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=Qk329cArnzB2cZaNtHlJKFaOAAaKC6oWqgsD7L1Zbw0=; b=TJGS5pRgH84nguUtlabazH/EaD4vu4rO6Iy5o7seqECIBvznWFaPDRpDm6KXVazODW2E9b /RyaORqrn62oxBcQHpTfEQPfVVoOG0JJzAuGVlUvozh4a0YLKLwWvKcYHNT+o8TcgU+2Ie AUK4M6kwFJ4l5URg9u9wywKO9qG8pBU= X-MC-Unique: nR6yhAVbNeCgTp97wvZOhQ-1 X-Mimecast-MFC-AGG-ID: nR6yhAVbNeCgTp97wvZOhQ_1747074294 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 v2 2/7] scripts/checkpatch.pl: fix various indentation mistakes Date: Mon, 12 May 2025 19:24:42 +0100 Message-ID: <20250512182447.1139105-3-berrange@redhat.com> In-Reply-To: <20250512182447.1139105-1-berrange@redhat.com> References: <20250512182447.1139105-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: -35 X-Spam_score: -3.6 X-Spam_bar: --- X-Spam_report: (-3.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.551, 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=0.001, RCVD_IN_MSPIKE_WL=0.001, 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: 1747074310269116600 From: Daniel P. Berrang=C3=A9 Various checks in the code were under-indented relative to other surrounding code. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: C=C3=A9dric Le Goater --- 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:53 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=1747074422; cv=none; d=zohomail.com; s=zohoarc; b=f1Qx3O+BBP/+ZucFizFEzV3MUAcnweIHY96YJGLFPx++w4T20JrZPZDZd8HgzO0UuWCYS0GSjJHoUmjw1dv/w68iVaP4Cgti6i03c8b5is5rG/dLi5BmvscOTOaWf36PbiCXxQ75plUT2Uph73spkqGkgjlfrRitX3DQL8eNiZk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747074422; 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=Gw4dd2QSOv6XRkiJ8PdXqG5e+/IIosT1Cw9Q3h7RFu0=; b=dXvCxrlUi1dPooAvzb7R+RpUnWODYCyUHeZMxetdXe9KOoQ/r9dh8QUA3jOkrmT6IbwZjTs6Yz/bNRwIAErHUowS+vSGzW5Y5Mhe4kuf3Lpcsj+W8+65HyX4ooc62VNp/CUw6APtApUHtTijKrCyKOVDUqxR4TkMAZq0tZXkglw= 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 1747074422495260.91163129011795; Mon, 12 May 2025 11:27:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uEXq0-0003P8-RI; Mon, 12 May 2025 14:25:17 -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 1uEXpr-0003KV-5t for qemu-devel@nongnu.org; Mon, 12 May 2025 14:25:07 -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 1uEXpl-0002dq-G4 for qemu-devel@nongnu.org; Mon, 12 May 2025 14:25:06 -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-392-dLRFyk7aPluE_PM0NHHoPg-1; Mon, 12 May 2025 14:24:57 -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 D63D5195608B; Mon, 12 May 2025 18:24:55 +0000 (UTC) Received: from toolbx.redhat.com (unknown [10.42.28.162]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 7EE4D19560A3; Mon, 12 May 2025 18:24:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1747074300; 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=Gw4dd2QSOv6XRkiJ8PdXqG5e+/IIosT1Cw9Q3h7RFu0=; b=E/9EclVZydUec54szx3gtZvCVQpNes4t+8kbmjx5LddGSv8hoGsPASkKPSKwBe38VKDY16 xnS0ng2lkwiLu5IOxH5/DU1PnIn8DjB9x7Tzo/H9saGlwbAhLYwsk44XNsH/0r3H7rimRX mrSFYjwwz63A0t8P+7L3WZNgU15isN4= X-MC-Unique: dLRFyk7aPluE_PM0NHHoPg-1 X-Mimecast-MFC-AGG-ID: dLRFyk7aPluE_PM0NHHoPg_1747074296 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 v2 3/7] scripts/checkpatch: introduce tracking of file start/end Date: Mon, 12 May 2025 19:24:43 +0100 Message-ID: <20250512182447.1139105-4-berrange@redhat.com> In-Reply-To: <20250512182447.1139105-1-berrange@redhat.com> References: <20250512182447.1139105-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: -35 X-Spam_score: -3.6 X-Spam_bar: --- X-Spam_report: (-3.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.551, 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=0.001, RCVD_IN_MSPIKE_WL=0.001, 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: 1747074423405019000 From: Daniel P. Berrang=C3=A9 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. Signed-off-by: Daniel P. Berrang=C3=A9 --- scripts/checkpatch.pl | 109 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 106 insertions(+), 3 deletions(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 7675418b0b..b74391e63a 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -1417,6 +1417,38 @@ sub checkspdx { } } =20 +# All three of the methods below take a 'file info' record +# which is a hash ref containing +# +# 'isgit': is this from an enhanced git diff or plain diff +# '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 +1485,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 +1626,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 +1684,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 +3311,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:53 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=1747074413; cv=none; d=zohomail.com; s=zohoarc; b=VLrq20Id4VSW23QAiey0oYMWwbxHIDV5BmGt/gNPjN1T10FXGwoDLUC4cbCrYTL0kbG4OY6EYsiPb0wiog9zWMdQicifNEKRcw4Faw/rltz+eErdiVxfIYzeKEPcGHhvu88WShySCqUtM+oP5cCKjYTaXnpgGcetgwqUAoYvaKU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747074413; 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=E0XjWduKtGfCY7Qli5m9VFft4w7g6B5MKRTm6cl8YNE=; b=HtHZm7fbZjkD0sHOn0mx5q8nxVvaLdYR636ptHDZcqtyNSaeE0FVWJlDK5vwUdgLXze0WH47jK6f0ZjsI0XIw9j8rjhTueU5X49vJKuI1j1LreoxwDVkjoB+dZiiO7SRu2G+ppUfbR2xJg8IAYOCYC1xHu8Bvvq4B4KrUtRvsug= 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 1747074413312572.252611401398; Mon, 12 May 2025 11:26:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uEXqY-00043w-Bu; Mon, 12 May 2025 14:25: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 1uEXpr-0003Mm-RX for qemu-devel@nongnu.org; Mon, 12 May 2025 14:25:07 -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 1uEXpn-0002eN-Pb for qemu-devel@nongnu.org; Mon, 12 May 2025 14:25:07 -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-86-e_zpWJDJOReT0q7HU3C_aQ-1; Mon, 12 May 2025 14:24:59 -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 AF0411956089; Mon, 12 May 2025 18:24:57 +0000 (UTC) Received: from toolbx.redhat.com (unknown [10.42.28.162]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 3F87719560A3; Mon, 12 May 2025 18:24:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1747074303; 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=E0XjWduKtGfCY7Qli5m9VFft4w7g6B5MKRTm6cl8YNE=; b=Im5LfS4GEmFya+Ne7TzjVH8OoV66UbMC6crcNj8tAFvVa5O/uX+f7jfI4hpDifgZL4sBv1 LFnvlo87H7nW2OtIEkGA6mLI2XT5USvCH68G22wCwoI33M2NbIWagFDmv3SIPQJr4Zc1an 3RT1gdeSxrmN+m7Vqqmzbmrs/v9K4Wo= X-MC-Unique: e_zpWJDJOReT0q7HU3C_aQ-1 X-Mimecast-MFC-AGG-ID: e_zpWJDJOReT0q7HU3C_aQ_1747074298 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 v2 4/7] scripts/checkpatch: use new hook for ACPI test data check Date: Mon, 12 May 2025 19:24:44 +0100 Message-ID: <20250512182447.1139105-5-berrange@redhat.com> In-Reply-To: <20250512182447.1139105-1-berrange@redhat.com> References: <20250512182447.1139105-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: -35 X-Spam_score: -3.6 X-Spam_bar: --- X-Spam_report: (-3.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.551, 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=0.001, RCVD_IN_MSPIKE_WL=0.001, 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: 1747074415559019000 From: Daniel P. Berrang=C3=A9 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. 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 b74391e63a..6a7b543ddf 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 @@ -1437,6 +1414,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 @@ -1501,9 +1506,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(); @@ -1642,7 +1644,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, @@ -1676,8 +1677,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") { @@ -1770,9 +1769,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:53 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=1747074390; cv=none; d=zohomail.com; s=zohoarc; b=FOHzWFquNuOGMPhZLzfBEIDvHdiaqgFEuGD5+RQw0Ad6sT7W8neHCaCp68Xx5JSqtS/KIAvqRA0+atSsuVLfn8Z85KPbnCGygM0Nh2/W8tlsB8GLrbWR5+E84qfXV/UC4+JoO+10WhIj0GwIYfqYEfTihn7YaKOCSBeApXesy7k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747074390; 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=Dc5OjW7m+vztsMzTh65/3z6NyVbWvMJUNG4yAJfZN1s=; b=d9ErKis1ZxWW6bX6USFiByi29GmGxMmUDWkoAkQTHIIpRgjPdnQrH+YVcmRDHXZ81FiDV3IK6FboHF0UOD3rL38xf88ym0KFipFgQ6iPQVZKMzNTYS0mO0XwlkhnppJKoDZZi31zpP/boPFfKRaty3TprjagwdTitaJoO84m50k= 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 1747074390320650.4739428588172; Mon, 12 May 2025 11:26:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uEXqK-0003eO-6p; Mon, 12 May 2025 14:25:38 -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 1uEXpr-0003Mk-QJ for qemu-devel@nongnu.org; Mon, 12 May 2025 14:25:07 -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 1uEXpn-0002eE-IX for qemu-devel@nongnu.org; Mon, 12 May 2025 14:25:07 -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-623-bBTAlV_iPJeXXsMDNqFUow-1; Mon, 12 May 2025 14:25:00 -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 84EC118003FC; Mon, 12 May 2025 18:24:59 +0000 (UTC) Received: from toolbx.redhat.com (unknown [10.42.28.162]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 18FD419560A3; Mon, 12 May 2025 18:24:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1747074302; 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=Dc5OjW7m+vztsMzTh65/3z6NyVbWvMJUNG4yAJfZN1s=; b=aWpll15xifliQaA1ylUxVCM6n/wPm6WWehZSEXNRSoCYLmWp0PTYQfWQSJNiBb7B03VlIl fF4thugMoqPqPprDQ9Zy8L0ooKpYdzF2mrul6gjYvOGM2CpGMjVhLBxqyXRO6Z+PQ8a/LA yuDUr+DZbouren42fIAKnXthY/w8vuo= X-MC-Unique: bBTAlV_iPJeXXsMDNqFUow-1 X-Mimecast-MFC-AGG-ID: bBTAlV_iPJeXXsMDNqFUow_1747074299 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 v2 5/7] scripts/checkpatch: use new hook for file permissions check Date: Mon, 12 May 2025 19:24:45 +0100 Message-ID: <20250512182447.1139105-6-berrange@redhat.com> In-Reply-To: <20250512182447.1139105-1-berrange@redhat.com> References: <20250512182447.1139105-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: -35 X-Spam_score: -3.6 X-Spam_bar: --- X-Spam_report: (-3.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.551, 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=0.001, RCVD_IN_MSPIKE_WL=0.001, 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: 1747074392379116600 From: Daniel P. Berrang=C3=A9 The file permissions check is the kind of check intended to be performed in the new start of file hook. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: C=C3=A9dric Le Goater --- scripts/checkpatch.pl | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 6a7b543ddf..4a18daa384 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -1447,6 +1447,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 @@ -1718,14 +1729,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:53 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=1747074463; cv=none; d=zohomail.com; s=zohoarc; b=Tl2yAnWL65QJXKRCgy7jak429ANV+Lr1X3fquyGo0s7Zp/sJ+XjAkhO7EtBUbcsbD6UNZ2yMmFmAkF/aLeJ6tc3UoPGeyHGa/uUXJxpZT/8690I4ilZ9qBJXPQh9b7411IJlCPcu07mNXzRWjzwDd8fLJc7YjS5vOns2ii8NAfI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747074463; 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=pPi7TsdCUCbjJd188mz8wJdZpgOwHxDrFtk1yk04jD4=; b=PiuhNO3a0KIuRmmIUyPN3Vl9wYtXcQKgS7+Cu46W1SSAeVUlJFDmC+NgHjUo/XxINNkpEVH6ZKu6bw8T3VbbXwdoP4BHR6MjTzeseh5/9Zntudd2ybMn3NVHVjP0fefDN08b1uMv+xlIFFy61YwhOCBRK3FcW69i1bUncazW0r8= 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 1747074463114411.4007944908785; Mon, 12 May 2025 11:27:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uEXqx-0004Ri-Eh; Mon, 12 May 2025 14:26:17 -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 1uEXps-0003Nv-PP for qemu-devel@nongnu.org; Mon, 12 May 2025 14:25:11 -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 1uEXpq-0002pM-Kf for qemu-devel@nongnu.org; Mon, 12 May 2025 14:25:08 -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-322-ERY_-mOqNRCcVXr2bYpHGg-1; Mon, 12 May 2025 14:25:02 -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 5986F1955DE0; Mon, 12 May 2025 18:25:01 +0000 (UTC) Received: from toolbx.redhat.com (unknown [10.42.28.162]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E392B1955EA0; Mon, 12 May 2025 18:24:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1747074305; 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=pPi7TsdCUCbjJd188mz8wJdZpgOwHxDrFtk1yk04jD4=; b=iSsVkOt2C4V6HbbYL/+AOwbRl+rM5krPgBT7sgnnHERX//8edQl2s2XXtB8AjkEcc9LoKk kW1tVTcDju6FjUlDs5iufzgMdhSVCFUH7Eh/uXkZV/82obF+DN1FZGKmv3gQmn4Mz0fn9T Zvc/89N0zoQYvQfv7Qdwz9/4cHRrLNU= X-MC-Unique: ERY_-mOqNRCcVXr2bYpHGg-1 X-Mimecast-MFC-AGG-ID: ERY_-mOqNRCcVXr2bYpHGg_1747074301 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 v2 6/7] scripts/checkpatch: use new hook for MAINTAINERS update check Date: Mon, 12 May 2025 19:24:46 +0100 Message-ID: <20250512182447.1139105-7-berrange@redhat.com> In-Reply-To: <20250512182447.1139105-1-berrange@redhat.com> References: <20250512182447.1139105-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: -35 X-Spam_score: -3.6 X-Spam_bar: --- X-Spam_report: (-3.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.551, 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=0.001, RCVD_IN_MSPIKE_WL=0.001, 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: 1747074463533019000 From: Daniel P. Berrang=C3=A9 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. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: C=C3=A9dric Le Goater --- scripts/checkpatch.pl | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 4a18daa384..d416a6dcf9 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -1442,6 +1442,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 "MAINTAINEfRS") { + $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 @@ -1485,7 +1504,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; @@ -1760,23 +1778,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:53 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=1747074504; cv=none; d=zohomail.com; s=zohoarc; b=VBEsvX+JgjiOTtZIHk/Xdo57VShdm8Qn2VsXwRBCqD+TtHHp+SZEGbtVV7eXlMmeFt4byg21tSrfZnGA2tCwAOK3BFIm1h4GduFYumHKCQS4l9pKa+2gS/ywRLai5Fu4w2b4wANQemqfB1JQtZanE0BCEtJBBUN9jcyKCtxAd7c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747074504; 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=7deamQ+Td0wwEZUJoSzy9xTc4rv5yWcb1b/jhyM8GRE=; b=ll2NDbXs2FVFp8cTM5tBRy42snOYZQhluIA6hmzNYkqmRElvy0+9+wMtrLZCpVFX8wWr2AZhuu7alRQvcIJNvbMxHt65Ye7wU4QHl+mapXmRTQrWpm7MDousuN/vaZ32emHUKaZ4lqxoxWmik55AgGg7GCCbVfx67HIy3nptim8= 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 1747074504080611.4323714100867; Mon, 12 May 2025 11:28:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uEXqR-0003oK-HJ; Mon, 12 May 2025 14:25:43 -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 1uEXpw-0003PK-AJ for qemu-devel@nongnu.org; Mon, 12 May 2025 14:25:14 -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 1uEXpu-0002qD-6s for qemu-devel@nongnu.org; Mon, 12 May 2025 14:25:11 -0400 Received: from mx-prod-mc-04.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-480-OHr6urqYMn6IOKlATVSZtQ-1; Mon, 12 May 2025 14:25:03 -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-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B732D1955DDE; Mon, 12 May 2025 18:25:02 +0000 (UTC) Received: from toolbx.redhat.com (unknown [10.42.28.162]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 8F4C519560A3; Mon, 12 May 2025 18:25:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1747074309; 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=7deamQ+Td0wwEZUJoSzy9xTc4rv5yWcb1b/jhyM8GRE=; b=CTZYoRLEen9SnU4Mo/ZDOmTmyzzTsWKesJ6MAM2AnXQSQROCSiWL8c7DjxUoXAAweYmszr chPw4GUKHfiDFqr3MbSD6LkfyLj9Jsk7v5de68xPMDJCKvFXy+HLFILGLp1gTjOL4YLLXk YX4CtzVFdEPWaFOgPrXaOPWbTUgrfbE= X-MC-Unique: OHr6urqYMn6IOKlATVSZtQ-1 X-Mimecast-MFC-AGG-ID: OHr6urqYMn6IOKlATVSZtQ_1747074302 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 v2 7/7] scripts/checkpatch: reimplement mandate for SPDX-License-Identifier Date: Mon, 12 May 2025 19:24:47 +0100 Message-ID: <20250512182447.1139105-8-berrange@redhat.com> In-Reply-To: <20250512182447.1139105-1-berrange@redhat.com> References: <20250512182447.1139105-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: -35 X-Spam_score: -3.6 X-Spam_bar: --- X-Spam_report: (-3.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.551, 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=0.001, RCVD_IN_MSPIKE_WL=0.001, 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: 1747074505181116600 From: Daniel P. Berrang=C3=A9 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. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: C=C3=A9dric Le Goater Tested-by: C=C3=A9dric Le Goater --- scripts/checkpatch.pl | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index d416a6dcf9..95609ca010 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -1482,6 +1482,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 { @@ -1780,6 +1794,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