Re: [PATCH 2/2] checkpatch: Add --conf-dir option

From: Petr Vorel

Date: Fri Feb 20 2026 - 06:47:24 EST


Hi,

gently ping about the patchset. We can keep the functionality out of tree,
but I suppose more project which use checkpatch.pl would benefit from it.

Kind regards,
Petr

> This allows to directly use project configuration file for projects
> which vendored checkpatch.pl (e.g. LTP or u-boot).

> Options from the configuration file has been read before processing
> command line options with Getopt::Long since the start (000d1cc1829f9)
> because options read from config file needs to be unshifted from command
> line arguments (@ARGV) before processing with Getopt::Long. Therefore
> parse --conf-dir with direct reading @ARGV.

> Signed-off-by: Petr Vorel <pvorel@xxxxxxx>
> ---
> @ARGV can be probably processed cleaner.

> Kind regards,
> Petr

> scripts/checkpatch.pl | 31 +++++++++++++++++++++++++++++--
> 1 file changed, 29 insertions(+), 2 deletions(-)

> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 8fffdf9e7f85f..7e19287d452d8 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -58,6 +58,7 @@ my @ignore = ();
> my $help = 0;
> my $configuration_file = ".checkpatch.conf";
> my $def_configuration_dirs = ".:$ENV{HOME}:.scripts";
> +my $configuration_dir = "";
> my $max_line_length = 100;
> my $ignore_perl_version = 0;
> my $minimum_perl_version = 5.10.0;
> @@ -144,12 +145,14 @@ Options:
> is a terminal ('auto'). Default is 'auto'.
> --kconfig-prefix=WORD use WORD as a prefix for Kconfig symbols (default
> ${CONFIG_})
> + --conf-dir=DIR directory with $configuration_file configuration file
> + (default:$def_configuration_dirs)
> -h, --help, --version display this help and exit

> When FILE is - read standard input.

> Script searches for a configuration file $configuration_file in path:
> -$def_configuration_dirs
> +$def_configuration_dirs (can be overwritten by --conf-dir)
> EOM

> exit($exitcode);
> @@ -241,7 +244,31 @@ sub list_types {
> exit($exitcode);
> }

> -my $conf = which_conf($configuration_file, $def_configuration_dirs);
> +# parse --conf-dir before the other options
> +my @argv;
> +while (@ARGV) {
> + my $arg = shift @ARGV;
> + if ($arg eq '--conf-dir') {
> + $configuration_dir = shift @ARGV;
> + die "--conf-dir requires value" unless ($configuration_dir);
> + } elsif ($arg =~ /^--conf-dir=(.+)$/) {
> + $configuration_dir = $1;
> + die "--conf-dir requires value" unless ($configuration_dir);
> + } else {
> + push @argv, $arg;
> + }
> +}
> +@ARGV = @argv;
> +
> +my $conf;
> +if ($configuration_dir) {
> + die "Dir. $configuration_dir does not exist" unless (-d $configuration_dir);
> + $conf = "$configuration_dir/$configuration_file";
> + die "File $conf does not exist" unless (-f $conf);
> +} else {
> + $conf = which_conf($configuration_file, $def_configuration_dirs);
> +}
> +
> if (-f $conf) {
> my @conf_args;
> open(my $conffile, '<', "$conf")