From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4A20A46AED3 for ; Mon, 20 Apr 2026 13:30:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776691836; cv=none; b=F1uTbLbiCnuzGNbLRj5iiKrJvmfXVlO37atfRXNMWAAC1t/ejJJgUSX90D2sff9VccyMdnR0iCpFV92P/04ieaRKSOgFAz55VNgiNSPpAkmjxaUhaiEzM5KLCzPJBVAQGwplmGKAE+4mlzqG6QnLQzASt5D1gdFmg7U8JInCBuM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776691836; c=relaxed/simple; bh=6zWd0VgLpV77xZtLYPbEwhjReqRUcilTR7gUp0o/Zyc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EwXV0f7PgQNMVtSlTgL0u1eSWec0iAtjh9xQW2I9O5uLSS/iDfVjMhifoC3mf55vdKIJvOOOZDPGRBEO/7YPiqlrBhR3QqNX9iuuI79nPjAnIP+/9CdeM3rNU7dYnkvTB5MuNTjoJofmTXjH8kATf41CdOMykoWDNziNmC4Gj4c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz; spf=pass smtp.mailfrom=suse.cz; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=WHJE7on5; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=KJjr4QEh; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=WHJE7on5; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=KJjr4QEh; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.cz Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="WHJE7on5"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="KJjr4QEh"; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="WHJE7on5"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="KJjr4QEh" Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 814835BCCF; Mon, 20 Apr 2026 13:30:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1776691826; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XsfCMBqLuV9eTVL2KgCxikpyr2CPdduEDzpEWnrcRrw=; b=WHJE7on5QcIZ4zm+Tgu5vAQGGWCPCukH9JYHNIPpB79ksmYaHvtrTkZBG1uldcOj3nseRV wFCkXnh/f0t40m/gr1IqNhtlw4BXh1s6PbidqqhBZIl/cXEf0yvXc8xoov/nx/bPBtiLwF MieVZV6Hlc278+uQRld41C04KXZi980= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1776691826; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XsfCMBqLuV9eTVL2KgCxikpyr2CPdduEDzpEWnrcRrw=; b=KJjr4QEhQuptGVvV9FYxJ+i73/DDg2OkO98FCAJatwFiGsKxaxKKR3gqD5f2q1/07ayg19 lPjH5R8V2OgfKdDg== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1776691826; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XsfCMBqLuV9eTVL2KgCxikpyr2CPdduEDzpEWnrcRrw=; b=WHJE7on5QcIZ4zm+Tgu5vAQGGWCPCukH9JYHNIPpB79ksmYaHvtrTkZBG1uldcOj3nseRV wFCkXnh/f0t40m/gr1IqNhtlw4BXh1s6PbidqqhBZIl/cXEf0yvXc8xoov/nx/bPBtiLwF MieVZV6Hlc278+uQRld41C04KXZi980= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1776691826; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XsfCMBqLuV9eTVL2KgCxikpyr2CPdduEDzpEWnrcRrw=; b=KJjr4QEhQuptGVvV9FYxJ+i73/DDg2OkO98FCAJatwFiGsKxaxKKR3gqD5f2q1/07ayg19 lPjH5R8V2OgfKdDg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 4092C593AF; Mon, 20 Apr 2026 13:30:26 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id AERxDnIq5mliMQAAD6G6ig (envelope-from ); Mon, 20 Apr 2026 13:30:26 +0000 From: Petr Vorel To: linux-kernel@vger.kernel.org Cc: Petr Vorel , Joe Perches , Simon Glass , Dwaipayan Ray , Lukas Bulwahn Subject: [PATCH v6 2/2] checkpatch: Add option to not force /* */ for SPDX Date: Mon, 20 Apr 2026 15:30:14 +0200 Message-ID: <20260420133014.484162-2-pvorel@suse.cz> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260420133014.484162-1-pvorel@suse.cz> References: <20260420133014.484162-1-pvorel@suse.cz> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spamd-Result: default: False [-1.30 / 50.00]; BAYES_HAM(-3.00)[100.00%]; SUSPICIOUS_RECIPS(1.50)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,chromium.org:email,suse.cz:mid,suse.cz:email]; RCVD_VIA_SMTP_AUTH(0.00)[]; FUZZY_RATELIMITED(0.00)[rspamd.com]; ARC_NA(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; TAGGED_RCPT(0.00)[]; FREEMAIL_CC(0.00)[suse.cz,perches.com,chromium.org,gmail.com]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_FIVE(0.00)[6]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; FREEMAIL_ENVRCPT(0.00)[gmail.com] X-Spam-Flag: NO X-Spam-Score: -1.30 X-Spam-Level: Add option --spdx-cxx-comments to not force C comments (/* */) for SPDX, but allow also C++ comments (//). As documented in aa19a176df95d6, this is required for some old toolchains still have older assembler tools which cannot handle C++ style comments. This avoids forcing this for projects which vendored checkpatch.pl (e.g. LTP or u-boot). Reviewed-by: Simon Glass Signed-off-by: Petr Vorel --- Changes in v6: * Fix escaping '..' by \Q \E (Simon, sashiko) * Fix formatting of /* */ in Documentation/dev-tools/checkpatch.rst (sashiko) * Fix wording in the commit message (Simon) Link to v5: https://lore.kernel.org/lkml/20260417170346.448758-2-pvorel@suse.cz/ Link to v4: https://lore.kernel.org/lkml/20260415143636.272605-2-pvorel@suse.cz/ Link to v3: https://lore.kernel.org/lkml/20260408120603.54351-2-pvorel@suse.cz/ Thanks Simon for patient review, let's see if maintainers like the changes. Documentation/dev-tools/checkpatch.rst | 7 +++++++ scripts/checkpatch.pl | 23 ++++++++++++++++++----- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/Documentation/dev-tools/checkpatch.rst b/Documentation/dev-tools/checkpatch.rst index 010dfcd615afc..6139a08c34cd8 100644 --- a/Documentation/dev-tools/checkpatch.rst +++ b/Documentation/dev-tools/checkpatch.rst @@ -184,6 +184,13 @@ Available options: Override checking of perl version. Runtime errors may be encountered after enabling this flag if the perl version does not meet the minimum specified. + - --spdx-cxx-comments + + Don't force C comments ``/* */`` for SPDX license (required by old + toolchains), allow also C++ comments ``//``. + + NOTE: it should *not* be used for Linux mainline. + - --codespell Use the codespell dictionary for checking spelling errors. diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index d86f5ccb06fe4..18da0cbf873cb 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -61,6 +61,7 @@ my $def_configuration_dirs = ".:$ENV{HOME}:.scripts"; my $env_config_dir = 'CHECKPATCH_CONFIG_DIR'; my $max_line_length = 100; my $ignore_perl_version = 0; +my $spdx_cxx_comments = 0; my $minimum_perl_version = 5.10.0; my $min_conf_desc_length = 4; my $spelling_file = "$D/spelling.txt"; @@ -137,6 +138,10 @@ Options: file. It's your fault if there's no backup or git --ignore-perl-version override checking of perl version. expect runtime errors. + --spdx-cxx-comments don't force C comments (/* */) for SPDX license + (required by old toolchains), allow also C++ + comments (//). + NOTE: it should *not* be used for Linux mainline. --codespell Use the codespell dictionary for spelling/typos (default:$codespellfile) --codespellfile Use this codespell dictionary @@ -346,6 +351,7 @@ GetOptions( 'fix!' => \$fix, 'fix-inplace!' => \$fix_inplace, 'ignore-perl-version!' => \$ignore_perl_version, + 'spdx-cxx-comments!' => \$spdx_cxx_comments, 'debug=s' => \%debug, 'test-only=s' => \$tst_only, 'codespell!' => \$codespell, @@ -3814,26 +3820,33 @@ sub process { $checklicenseline = 2; } elsif ($rawline =~ /^\+/) { my $comment = ""; - if ($realfile =~ /\.(h|s|S)$/) { - $comment = '/*'; - } elsif ($realfile =~ /\.(c|rs|dts|dtsi)$/) { + if ($realfile =~ /\.(c|rs|dts|dtsi)$/) { $comment = '//'; } elsif (($checklicenseline == 2) || $realfile =~ /\.(sh|pl|py|awk|tc|yaml)$/) { $comment = '#'; } elsif ($realfile =~ /\.rst$/) { $comment = '..'; } + my $pattern = qr{\Q$comment\E}; + if ($realfile =~ /\.(h|s|S)$/) { + $comment = '/*'; + $pattern = qr{/\*}; + if ($spdx_cxx_comments) { + $comment = '// or /*'; + $pattern = qr{//|/\*}; + } + } # check SPDX comment style for .[chsS] files if ($realfile =~ /\.[chsS]$/ && $rawline =~ /SPDX-License-Identifier:/ && - $rawline !~ m@^\+\s*\Q$comment\E\s*@) { + $rawline !~ m@^\+\s*$pattern\s*@) { WARN("SPDX_LICENSE_TAG", "Improper SPDX comment style for '$realfile', please use '$comment' instead\n" . $herecurr); } if ($comment !~ /^$/ && - $rawline !~ m@^\+\Q$comment\E SPDX-License-Identifier: @) { + $rawline !~ m@^\+$pattern SPDX-License-Identifier: @) { WARN("SPDX_LICENSE_TAG", "Missing or malformed SPDX-License-Identifier tag in line $checklicenseline\n" . $herecurr); } elsif ($rawline =~ /(SPDX-License-Identifier: .*)/) { -- 2.53.0