public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Petr Vorel <pvorel@suse.cz>
To: linux-kernel@vger.kernel.org
Cc: Joe Perches <joe@perches.com>, Simon Glass <sjg@chromium.org>,
	Dwaipayan Ray <dwaipayanray1@gmail.com>,
	Lukas Bulwahn <lukas.bulwahn@gmail.com>
Subject: Re: [PATCH v6 1/2] checkpatch: Allow passing config directory
Date: Tue, 21 Apr 2026 12:30:21 +0200	[thread overview]
Message-ID: <20260421103021.GA506589@pevik> (raw)
In-Reply-To: <20260420133014.484162-1-pvorel@suse.cz>

Hi Simon, all,

> 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.

I'm sorry for the noise, I need to send v7, with diff below.

1) Fix empty variable, (I was thinking about but in the end forget).
2) Print $HOME in help instead the actual value of $HOME environment variable.

Kind regards,
Petr

+++ scripts/checkpatch.pl
@@ -57,7 +57,8 @@ my %ignore_type = ();
 my @ignore = ();
 my $help = 0;
 my $configuration_file = ".checkpatch.conf";
-my $def_configuration_dirs = ".:$ENV{HOME}:.scripts";
+my $def_configuration_dirs_help = '.:$HOME:.scripts';
+(my $def_configuration_dirs = $def_configuration_dirs_help) =~ s/\$(\w+)/$ENV{$1} /g;
 my $env_config_dir = 'CHECKPATCH_CONFIG_DIR';
 my $max_line_length = 100;
 my $ignore_perl_version = 0;
@@ -151,7 +152,7 @@ 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
+search path: '$def_configuration_dirs_help' or in a directory specified by
 \$$env_config_dir environment variable (fallback to the default search path).
 EOM
 
@@ -1541,7 +1542,7 @@ sub which_conf {
 	my ($conf, $env_key, $paths) = @_;
 	my $env_dir = $ENV{$env_key};
 
-	if (defined($env_dir)) {
+	if (defined($env_dir) && $env_dir ne "") {
 		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";
 	}

      parent reply	other threads:[~2026-04-21 10:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-20 13:30 [PATCH v6 1/2] checkpatch: Allow passing config directory Petr Vorel
2026-04-20 13:30 ` [PATCH v6 2/2] checkpatch: Add option to not force /* */ for SPDX Petr Vorel
2026-04-21 10:30 ` Petr Vorel [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260421103021.GA506589@pevik \
    --to=pvorel@suse.cz \
    --cc=dwaipayanray1@gmail.com \
    --cc=joe@perches.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lukas.bulwahn@gmail.com \
    --cc=sjg@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox