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 1D0DD45BD5A for ; Mon, 20 Apr 2026 13:30:27 +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=1776691829; cv=none; b=kiHU8rJ7ZCFgkuAYpp32fpa13sAGo8McACvUDPbyxoynYtWDpYaZkKBLhwGCakmQOgzOAeMUwRe9ACsC9XP2/ofhrQ6e2jMOe/hAfAzDcDr3qQM7ZGaiEFKE4z0Z/a5viVaHVUgSlCM0ESUL0fT9v2dXX+/jjgUfdo+2Jgomegs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776691829; c=relaxed/simple; bh=TqQCBIgjJV0vj3ltyWRX+tA7qZ2di0+Cp1TOIt1vZ/A=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=roQ+uYXMcFH6Gx4HvNAOajgmBbRHPEivZmPId2RUSUfQUVsCS9uD61hrfenLP3LyHeRvIcn1IS0UrH/YCFWUeR9EjN9GrxcCQYWmjX+zBf+sOg/Sr18yRub9HJ4Xs8x6lKE2DgFfSYNWwenjRUMdQBIw68i3eEJ2D0NZ4wJ57Gc= 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=IpHR3wKi; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=IvyQ2ruE; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=IpHR3wKi; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=IvyQ2ruE; 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="IpHR3wKi"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="IvyQ2ruE"; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="IpHR3wKi"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="IvyQ2ruE" Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104: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 384275BCC5; 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; bh=AB4/Thuh4Km4TwqpuF4kQIUg3DIz4Y2y2PfnDkRabjA=; b=IpHR3wKiPsiECaEmEnBsk1ULXfx9bLJnX0Im0YG0Nqv1NjjrfNaP4F2ow+1cxPZxyy9BgP blG+kc0MRDnqKnMK1heyyTh+upMbLY0MapCewtN3/gnjqzTc/PV1R37mPBpndSrN8ZHCph Cqw+W/F2vIs6R2RJdYKgFxYVagOpeZ8= 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; bh=AB4/Thuh4Km4TwqpuF4kQIUg3DIz4Y2y2PfnDkRabjA=; b=IvyQ2ruEq49b3oe4XSEqxj7tdxPb/SGNHN7qngcxB+7WrKnUllH0hF0wWwhU/kiMjbBPqx DyCU2JidSDhcLqBg== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=IpHR3wKi; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=IvyQ2ruE 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; bh=AB4/Thuh4Km4TwqpuF4kQIUg3DIz4Y2y2PfnDkRabjA=; b=IpHR3wKiPsiECaEmEnBsk1ULXfx9bLJnX0Im0YG0Nqv1NjjrfNaP4F2ow+1cxPZxyy9BgP blG+kc0MRDnqKnMK1heyyTh+upMbLY0MapCewtN3/gnjqzTc/PV1R37mPBpndSrN8ZHCph Cqw+W/F2vIs6R2RJdYKgFxYVagOpeZ8= 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; bh=AB4/Thuh4Km4TwqpuF4kQIUg3DIz4Y2y2PfnDkRabjA=; b=IvyQ2ruEq49b3oe4XSEqxj7tdxPb/SGNHN7qngcxB+7WrKnUllH0hF0wWwhU/kiMjbBPqx DyCU2JidSDhcLqBg== 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 04A3F593AE; Mon, 20 Apr 2026 13:30:25 +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 FSk+OXEq5mliMQAAD6G6ig (envelope-from ); Mon, 20 Apr 2026 13:30:25 +0000 From: Petr Vorel To: linux-kernel@vger.kernel.org Cc: Petr Vorel , Joe Perches , Simon Glass , Dwaipayan Ray , Lukas Bulwahn Subject: [PATCH v6 1/2] checkpatch: Allow passing config directory Date: Mon, 20 Apr 2026 15:30:13 +0200 Message-ID: <20260420133014.484162-1-pvorel@suse.cz> X-Mailer: git-send-email 2.53.0 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.51 / 50.00]; BAYES_HAM(-3.00)[100.00%]; SUSPICIOUS_RECIPS(1.50)[]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; TO_MATCH_ENVRCPT_ALL(0.00)[]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; MIME_TRACE(0.00)[0:+]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; TO_DN_SOME(0.00)[]; FUZZY_RATELIMITED(0.00)[rspamd.com]; FREEMAIL_CC(0.00)[suse.cz,perches.com,chromium.org,gmail.com]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns,chromium.org:email,suse.cz:mid,suse.cz:dkim,suse.cz:email]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_FIVE(0.00)[6]; DNSWL_BLOCKED(0.00)[2a07:de40:b281:104:10:150:64:97:from,2a07:de40:b281:106:10:150:64:167:received]; TAGGED_RCPT(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; DKIM_TRACE(0.00)[suse.cz:+]; RCVD_VIA_SMTP_AUTH(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com] X-Rspamd-Action: no action X-Spam-Flag: NO X-Spam-Score: -1.51 X-Spam-Level: X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Rspamd-Queue-Id: 384275BCC5 checkpatch.pl searches for .checkpatch.conf in $CWD, $HOME and $CWD/.scripts. Allow passing a single directory via CHECKPATCH_CONFIG_DIR environment variable. This allows to directly use project configuration file for projects which vendored checkpatch.pl (e.g. LTP or u-boot). Although it'd be more convenient for user to have --conf-dir option (instead of using environment variable), code would get ugly because options from the configuration file needs to be read before processing command line options with Getopt::Long. While at it, document directories and environment variable in -h help and HTML doc. Reviewed-by: Simon Glass Signed-off-by: Petr Vorel --- Changes in v6: * Improve wording "fallback" => falling back" (Simon), "locations" => "search paths" (to be consistent). * Document config file also in Documentation/dev-tools/checkpatch.rst * Remove $! in error message (Simon, sashiko) Link to v5: https://lore.kernel.org/lkml/20260417170346.448758-1-pvorel@suse.cz/ Link to v4: https://lore.kernel.org/lkml/20260415143636.272605-1-pvorel@suse.cz/ Link to v3: https://lore.kernel.org/lkml/20260408120603.54351-1-pvorel@suse.cz/ Link to v2: https://lore.kernel.org/lkml/20260224181623.89904-1-pvorel@suse.cz/ Link to v1: https://lore.kernel.org/lkml/20260202144221.76765-2-pvorel@suse.cz/ Documentation/dev-tools/checkpatch.rst | 7 +++++++ scripts/checkpatch.pl | 19 ++++++++++++++++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/Documentation/dev-tools/checkpatch.rst b/Documentation/dev-tools/checkpatch.rst index dccede68698ca..010dfcd615afc 100644 --- a/Documentation/dev-tools/checkpatch.rst +++ b/Documentation/dev-tools/checkpatch.rst @@ -210,6 +210,13 @@ Available options: Display the help text. +Configuration file +================== + +Default configuration options can be stored in ``.checkpatch.conf``, search +path: ``.:$HOME:.scripts`` or in a directory specified by ``$CHECKPATCH_CONFIG_DIR`` +environment variable (falling back to the default search path). + Message Levels ============== diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 0492d6afc9a1f..d86f5ccb06fe4 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -57,6 +57,8 @@ my %ignore_type = (); my @ignore = (); my $help = 0; my $configuration_file = ".checkpatch.conf"; +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 $minimum_perl_version = 5.10.0; @@ -146,6 +148,11 @@ Options: -h, --help, --version display this help and exit When FILE is - read standard input. + +CONFIGURATION FILE +Default configuration options can be stored in $configuration_file, +search path: '$def_configuration_dirs' or in a directory specified by +\$$env_config_dir environment variable (fallback to the default search path). EOM exit($exitcode); @@ -237,7 +244,7 @@ sub list_types { exit($exitcode); } -my $conf = which_conf($configuration_file); +my $conf = which_conf($configuration_file, $env_config_dir, $def_configuration_dirs); if (-f $conf) { my @conf_args; open(my $conffile, '<', "$conf") @@ -1531,9 +1538,15 @@ sub which { } sub which_conf { - my ($conf) = @_; + my ($conf, $env_key, $paths) = @_; + my $env_dir = $ENV{$env_key}; + + if (defined($env_dir)) { + return "$env_dir/$conf" if (-e "$env_dir/$conf"); + warn "$P: Can't find a readable $conf in '$env_dir', falling back to default search paths\n"; + } - foreach my $path (split(/:/, ".:$ENV{HOME}:.scripts")) { + foreach my $path (split(/:/, $paths)) { if (-e "$path/$conf") { return "$path/$conf"; } -- 2.53.0