summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/bloat-o-meter1
-rwxr-xr-xscripts/checkpatch.pl53
-rwxr-xr-xscripts/get_maintainer.pl73
-rw-r--r--scripts/spelling.txt1
4 files changed, 85 insertions, 43 deletions
diff --git a/scripts/bloat-o-meter b/scripts/bloat-o-meter
index 9b4fb996d95b..5868a8b11b0f 100755
--- a/scripts/bloat-o-meter
+++ b/scripts/bloat-o-meter
@@ -43,6 +43,7 @@ def getsizes(file, format):
if name.startswith("__se_compat_sys"): continue
if name.startswith("__addressable_"): continue
if name.startswith("__noinstr_text_start"): continue
+ if name.startswith("_sdata"): continue
if name == "linux_banner": continue
if name == "vermagic": continue
# statics and some other optimizations adds random .NUMBER
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index cc5bbd70cb84..2b7a42bbdd94 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -57,8 +57,12 @@ my %ignore_type = ();
my @ignore = ();
my $help = 0;
my $configuration_file = ".checkpatch.conf";
+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;
+my $spdx_cxx_comments = 0;
my $minimum_perl_version = 5.10.0;
my $min_conf_desc_length = 4;
my $spelling_file = "$D/spelling.txt";
@@ -135,6 +139,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
@@ -146,6 +154,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_help' or in a directory specified by
+\$$env_config_dir environment variable (fallback to the default search path).
EOM
exit($exitcode);
@@ -237,7 +250,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")
@@ -339,6 +352,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,
@@ -1529,9 +1543,15 @@ sub which {
}
sub which_conf {
- my ($conf) = @_;
+ my ($conf, $env_key, $paths) = @_;
+ my $env_dir = $ENV{$env_key};
+
+ 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";
+ }
- foreach my $path (split(/:/, ".:$ENV{HOME}:.scripts")) {
+ foreach my $path (split(/:/, $paths)) {
if (-e "$path/$conf") {
return "$path/$conf";
}
@@ -3231,10 +3251,10 @@ sub process {
if ($sign_off =~ /^reported(?:|-and-tested)-by:$/i) {
if (!defined $lines[$linenr]) {
WARN("BAD_REPORTED_BY_LINK",
- "Reported-by: should be immediately followed by Closes: with a URL to the report\n" . $herecurr . "\n");
- } elsif ($rawlines[$linenr] !~ /^closes:\s*/i) {
+ "Reported-by: should be immediately followed by Closes: or Link: with a URL to the report\n" . $herecurr . "\n");
+ } elsif ($rawlines[$linenr] !~ /^(closes|link):\s*/i) {
WARN("BAD_REPORTED_BY_LINK",
- "Reported-by: should be immediately followed by Closes: with a URL to the report\n" . $herecurr . $rawlines[$linenr] . "\n");
+ "Reported-by: should be immediately followed by Closes: or Link: with a URL to the report\n" . $herecurr . $rawlines[$linenr] . "\n");
}
}
}
@@ -3799,26 +3819,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: .*)/) {
@@ -4154,7 +4181,7 @@ sub process {
$pl =~ s/\b(?:$Attribute|$Sparse)\b//g;
if (($pl =~ /^\+\s+$Declare\s*$Ident\s*[=,;:\[]/ ||
# function pointer declarations
- $pl =~ /^\+\s+$Declare\s*\(\s*\*\s*$Ident\s*\)\s*[=,;:\[\(]/ ||
+ $pl =~ /^\+\s+$Declare\s*\(\s*\*\s*$Ident(?:\s*\[\s*(?:$Ident|$Constant)?\s*\])?\s*\)\s*[=,;:\[\(]/ ||
# foo bar; where foo is some local typedef or #define
$pl =~ /^\+\s+$Ident(?:\s+|\s*\*\s*)$Ident\s*[=,;\[]/ ||
# known declaration macros
@@ -4168,7 +4195,7 @@ sub process {
# looks like a declaration
!($sl =~ /^\+\s+$Declare\s*$Ident\s*[=,;:\[]/ ||
# function pointer declarations
- $sl =~ /^\+\s+$Declare\s*\(\s*\*\s*$Ident\s*\)\s*[=,;:\[\(]/ ||
+ $sl =~ /^\+\s+$Declare\s*\(\s*\*\s*$Ident(?:\s*\[\s*(?:$Ident|$Constant)?\s*\])?\s*\)\s*[=,;:\[\(]/ ||
# foo bar; where foo is some local typedef or #define
$sl =~ /^\+\s+$Ident(?:\s+|\s*\*\s*)$Ident\s*[=,;\[]/ ||
# known declaration macros
diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl
index f0ca0db6ddc2..16b80a700d4a 100755
--- a/scripts/get_maintainer.pl
+++ b/scripts/get_maintainer.pl
@@ -21,6 +21,7 @@ use Cwd;
use File::Find;
use File::Spec::Functions;
use open qw(:std :encoding(UTF-8));
+use JSON::PP;
my $cur_path = fastgetcwd() . '/';
my $lk_path = "./";
@@ -68,6 +69,7 @@ my $pattern_depth = 0;
my $self_test = undef;
my $version = 0;
my $help = 0;
+my $json = 0;
my $find_maintainer_files = 0;
my $maintainer_path;
my $vcs_used = 0;
@@ -285,6 +287,7 @@ if (!GetOptions(
'find-maintainer-files' => \$find_maintainer_files,
'mpath|maintainer-path=s' => \$maintainer_path,
'self-test:s' => \$self_test,
+ 'json!' => \$json,
'v|version' => \$version,
'h|help|usage' => \$help,
)) {
@@ -650,39 +653,48 @@ my %deduplicate_name_hash = ();
my %deduplicate_address_hash = ();
my @maintainers = get_maintainers();
-if (@maintainers) {
- @maintainers = merge_email(@maintainers);
- output(@maintainers);
-}
-
-if ($scm) {
- @scm = uniq(@scm);
- output(@scm);
-}
-
-if ($output_substatus) {
- @substatus = uniq(@substatus);
- output(@substatus);
-}
-
-if ($status) {
- @status = uniq(@status);
- output(@status);
-}
-if ($subsystem) {
- @subsystem = uniq(@subsystem);
- output(@subsystem);
-}
+@maintainers = merge_email(@maintainers) if (@maintainers);
+@scm = uniq(@scm) if ($scm);
+@substatus = uniq(@substatus) if ($output_substatus);
+@status = uniq(@status) if ($status);
+@subsystem = uniq(@subsystem) if ($subsystem);
+@web = uniq(@web) if ($web);
+@bug = uniq(@bug) if ($bug);
+
+if ($json) {
+ my @json_maintainers;
+ for my $m (@maintainers) {
+ my ($addr, $role);
+ if ($output_roles && $m =~ /^(.*?)\s+\((.+)\)\s*$/) {
+ $addr = $1;
+ $role = $2;
+ } else {
+ $addr = $m;
+ }
+ my ($name, $email_addr) = parse_email($addr);
+ my %entry = (name => $name, email => $email_addr);
+ $entry{role} = $role if (defined $role && $role ne '');
+ push(@json_maintainers, \%entry);
+ }
-if ($web) {
- @web = uniq(@web);
- output(@web);
-}
+ my %result = (maintainers => \@json_maintainers);
+ $result{scm} = \@scm if ($scm);
+ $result{status} = \@status if ($status);
+ $result{subsystem} = \@subsystem if ($subsystem);
+ $result{web} = \@web if ($web);
+ $result{bug} = \@bug if ($bug);
-if ($bug) {
- @bug = uniq(@bug);
- output(@bug);
+ my $json_encoder = JSON::PP->new->canonical->utf8;
+ print($json_encoder->encode(\%result) . "\n");
+} else {
+ output(@maintainers) if (@maintainers);
+ output(@scm) if ($scm);
+ output(@substatus) if ($output_substatus);
+ output(@status) if ($status);
+ output(@subsystem) if ($subsystem);
+ output(@web) if ($web);
+ output(@bug) if ($bug);
}
exit($exit);
@@ -1104,6 +1116,7 @@ Output type options:
--separator [, ] => separator for multiple entries on 1 line
using --separator also sets --nomultiline if --separator is not [, ]
--multiline => print 1 entry per line
+ --json => output results as JSON
Other options:
--pattern-depth => Number of pattern directory traversals (default: 0 (all))
diff --git a/scripts/spelling.txt b/scripts/spelling.txt
index 2f2e81dbda03..3372873cd7bb 100644
--- a/scripts/spelling.txt
+++ b/scripts/spelling.txt
@@ -176,6 +176,7 @@ assgined||assigned
assiged||assigned
assigment||assignment
assigments||assignments
+assinged||assigned
assistent||assistant
assocaited||associated
assocated||associated