mirror of
https://github.com/torvalds/linux.git
synced 2024-11-27 14:41:39 +00:00
0058d07ec6
Set the x bit to some scripts to make them directly executable.
Especially, scripts/checkdeclares.pl is not hooked by anyone.
It should be executable since it is tedious to type
'perl scripts/checkdeclares.pl'.
The original patch [1] set the x bit properly, but it was lost when
it was merged as commit 21917bded7
("scripts: a new script for
checking duplicate struct declaration").
[1] https://lore.kernel.org/lkml/20210401110943.1010796-1-wanjiabing@vivo.com/
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
54 lines
1.1 KiB
Perl
Executable File
54 lines
1.1 KiB
Perl
Executable File
#!/usr/bin/env perl
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
#
|
|
# checkdeclares: find struct declared more than once
|
|
#
|
|
# Copyright 2021 Wan Jiabing<wanjiabing@vivo.com>
|
|
# Inspired by checkincludes.pl
|
|
#
|
|
# This script checks for duplicate struct declares.
|
|
# Note that this will not take into consideration macros so
|
|
# you should run this only if you know you do have real dups
|
|
# and do not have them under #ifdef's.
|
|
# You could also just review the results.
|
|
|
|
use strict;
|
|
|
|
sub usage {
|
|
print "Usage: checkdeclares.pl file1.h ...\n";
|
|
print "Warns of struct declaration duplicates\n";
|
|
exit 1;
|
|
}
|
|
|
|
if ($#ARGV < 0) {
|
|
usage();
|
|
}
|
|
|
|
my $dup_counter = 0;
|
|
|
|
foreach my $file (@ARGV) {
|
|
open(my $f, '<', $file)
|
|
or die "Cannot open $file: $!.\n";
|
|
|
|
my %declaredstructs = ();
|
|
|
|
while (<$f>) {
|
|
if (m/^\s*struct\s*(\w*);$/o) {
|
|
++$declaredstructs{$1};
|
|
}
|
|
}
|
|
|
|
close($f);
|
|
|
|
foreach my $structname (keys %declaredstructs) {
|
|
if ($declaredstructs{$structname} > 1) {
|
|
print "$file: struct $structname is declared more than once.\n";
|
|
++$dup_counter;
|
|
}
|
|
}
|
|
}
|
|
|
|
if ($dup_counter == 0) {
|
|
print "No duplicate struct declares found.\n";
|
|
}
|