perl files: clean up warnings

Clean up some perl warnings, some of which were legitimate (apparently
undef doesn't actually take a list of arguments, a common enough
mistake that it is mentioned in the man page!, and a list of variables
after "my" can be cantankerous), and some of which were nuisance but
were easy enough to clean up.

Maybe this can resolve the problems with very old version of Perl?

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
This commit is contained in:
H. Peter Anvin (Intel) 2019-08-09 13:30:19 -07:00
parent 2503cc09a2
commit 177a05d0ce
10 changed files with 38 additions and 38 deletions

View File

@ -174,8 +174,6 @@ if ($what eq 'c') {
verify_hash_table(\%tokens, \@hashinfo);
($n, $sv, $g) = @hashinfo;
$sv2 = $sv+2;
die if ($n & ($n-1));
print OUT "#include \"compiler.h\"\n";

View File

@ -100,7 +100,8 @@ while (defined($line = <RD>)) {
$reg_suffix = $4;
} else {
$nregs = 1;
undef $reg_prefix, $reg_suffix;
undef $reg_prefix;
undef $reg_suffix;
}
while ($nregs--) {
@ -196,8 +197,6 @@ if ($output eq 'h') {
verify_hash_table(\%tokens, \@hashinfo);
($n, $sv, $g) = @hashinfo;
$sv2 = $sv+2;
die if ($n & ($n-1));
print "/*\n";

View File

@ -13,7 +13,7 @@ my $nwarn = 0;
sub quote_for_c($) {
my $s = join('', @_);
$s =~ s/([\"\'\\])/\\\1/g;
$s =~ s/([\"\'\\])/\\$1/g;
return $s;
}
@ -93,7 +93,7 @@ sub find_warnings {
add_alias($name, $this);
$nwarn++;
}
} elsif (defined($this) && $str =~ /^\=([\w-,]+)\s*$/) {
} elsif (defined($this) && $str =~ /^\=([-\w,]+)\s*$/) {
# Alias names for warnings
for my $a (split(/,+/, $1)) {
add_alias($a, $this);
@ -147,7 +147,7 @@ if ($what eq 'c') {
print $out ",\n\t\"", $warn->{name}, "\"";
}
print $out "\n};\n\n";
printf $out "const struct warning_alias warning_alias[NUM_WARNING_ALIAS] = {",
printf $out "const struct warning_alias warning_alias[%d] = {",
scalar(%aliases);
my $sep = '';
foreach my $alias (sort { $a cmp $b } keys(%aliases)) {
@ -200,7 +200,7 @@ if ($what eq 'c') {
print $out "enum warn_const {\n";
printf $out "\tWARN_%-27s = %3d << WARN_SHR", 'NONE', 0;
my $n = 1;
$n = 1;
foreach my $warn (@warn_noall) {
printf $out ",\n\tWARN_%-27s = %3d << WARN_SHR", $warn->{cname}, $n++;
}

View File

@ -51,7 +51,7 @@ my $tasm_count = 0;
#
sub charcify(@) {
my $l = '';
my $c, $o;
my ($c, $o);
my $space = 1;
my $quote = 0;
@ -109,6 +109,7 @@ my @pkg_list = ();
my %pkg_number = ();
my $pkg;
my @out_list = ();
my @std_list = ();
my $outfmt;
my $lastname;
my $z;
@ -145,8 +146,6 @@ foreach $args ( @ARGV ) {
print OUT "\nconst unsigned char ${name}[] = {\n";
print OUT " /* From $fname */\n";
$lastname = $fname;
push(@out_list, $out_alias[0]);
$out_index{$out_alias[0]} = $index;
} elsif (m/^STD:\s*(.*\S)\s*$/) {
undef $pkg;
my @out_alias = split(/\s+/, $1);
@ -161,8 +160,6 @@ foreach $args ( @ARGV ) {
print OUT "\nconst unsigned char ${name}[] = {\n";
print OUT " /* From $fname */\n";
$lastname = $fname;
push(@std_list, $out_alias[0]);
$std_index{$std_alias[0]} = $index;
} elsif (m/^USE:\s*(\S+)\s*$/) {
$pkg = $1;
if (defined($pkg_number{$pkg})) {
@ -185,7 +182,7 @@ foreach $args ( @ARGV ) {
printf OUT " /* %4d */ %s0,\n", $index, charcify($z);
$index += length($z)+1;
} elsif (m/^\s*((\s*([^\"\';\s]+|\"[^\"]*\"|\'[^\']*\'))*)\s*(;.*)?$/) {
my $s1, $s2, $pd, $ws;
my($s1, $s2, $pd, $ws);
if (!defined($name)) {
die "$0: $fname: macro declarations outside a known block\n";
@ -216,7 +213,7 @@ foreach $args ( @ARGV ) {
$index += length($s2)+1;
}
} else {
die "$fname:$line: error unterminated quote";
die "$fname:$line: error: unterminated quote\n";
}
}
close(INPUT);

View File

@ -211,9 +211,9 @@ foreach my $s (keys(%strings)) {
} else {
$enumvals{$v} = $es;
}
$max_enum = $v if ($v > $max_enum || !defined($max_enum));
$tbloffs = $v if ($v < $tbloffs || !defined($tbloffs));
$tbllen = $v+1 if ($v >= $tbllen || !defined($tbllen));
$max_enum = $v if (!defined($max_enum) || $v > $max_enum);
$tbloffs = $v if (!defined($tbloffs) || $v < $tbloffs);
$tbllen = $v+1 if (!defined($tbllen) || $v >= $tbllen);
}
foreach my $s (keys(%specials)) {
my $es = $prefix . $s; # No string mangling here

View File

@ -62,9 +62,9 @@ sub walk_graph($$$$) {
sub gen_hash_n($$$$) {
my($n, $sv, $href, $run) = @_;
my @keys = keys(%{$href});
my $i, $sv;
my $i;
my $gr;
my $k, $v;
my ($k, $v);
my $gsize = 2*$n;
my @nodeval;
my @nodeneigh;
@ -140,7 +140,7 @@ sub gen_perfect_hash($) {
my($href) = @_;
my @keys = keys(%{$href});
my @hashinfo;
my $n, $i, $j, $sv, $maxj;
my ($n, $i, $j, $sv, $maxj);
my $run = 1;
# Minimal power of 2 value for N with enough wiggle room.

View File

@ -49,7 +49,7 @@ use Fcntl;
$barrier = "#-- Everything below is generated by mkdep.pl - do not edit --#\n";
# This converts from filenames to full pathnames for our dependencies
%dep_path = {};
%dep_path = ();
# List of files that cannot be found; these *must* be excluded
@must_exclude = ();
@ -134,7 +134,7 @@ sub _insert_deps($$) {
open(my $in, '<', $file)
or die "$0: Cannot open input: $file\n";
my $line, $parm, $val;
my ($line, $parm, $val);
my $obj = '.o'; # Defaults
my $sep = '/';
my $cont = "\\";

View File

@ -70,7 +70,11 @@
$line = <STDIN>;
chomp $line;
undef $man, $min, $smin, $plvl, $tail;
undef $maj;
undef $min;
undef $smin;
undef $plvl;
undef $tail;
$is_rc = 0;
if ( $line =~ /^([0-9]+)\.([0-9]+)(.*)$/ ) {

View File

@ -441,9 +441,10 @@ sub count_bytecodes(@) {
sub format_insn($$$$$) {
my ($opcode, $operands, $codes, $flags, $relax) = @_;
my $num, $nd = 0, $rawflags, $flagsindex;
my $nd = 0;
my ($num, $flagsindex);
my @bytecode;
my $op, @ops, $opp, @opx, @oppx, @decos, @opevex;
my ($op, @ops, $opp, @opx, @oppx, @decos, @opevex);
return (undef, undef) if $operands eq "ignore";
@ -615,20 +616,20 @@ sub hexstr(@) {
# \24x \250 skip EVEX control bytes
sub startseq($$) {
my ($codestr, $relax) = @_;
my $word, @range;
my $word;
my @codes = ();
my $c = $codestr;
my $c0, $c1, $i;
my($c0, $c1, $i);
my $prefix = '';
@codes = decodify($codestr, $relax);
while ($c0 = shift(@codes)) {
while (defined($c0 = shift(@codes))) {
$c1 = $codes[0];
if ($c0 >= 01 && $c0 <= 04) {
# Fixed byte string
my $fbs = $prefix;
while (1) {
while (defined($c0)) {
if ($c0 >= 01 && $c0 <= 04) {
while ($c0--) {
$fbs .= sprintf("%02X", shift(@codes));
@ -662,7 +663,7 @@ sub startseq($$) {
return $prefix;
} elsif (($c0 & ~3) == 0260 || $c0 == 0270 ||
($c0 & ~3) == 0240 || $c0 == 0250) {
my $c,$m,$wlp;
my($c,$m,$wlp);
$m = shift(@codes);
$wlp = shift(@codes);
$c = ($m >> 6);
@ -740,7 +741,7 @@ sub byte_code_compile($$) {
my $litix = undef;
my %oppos = ();
my $i;
my $op, $oq;
my ($op, $oq);
my $opex;
my %imm_codes = (
@ -813,11 +814,11 @@ sub byte_code_compile($$) {
unless ($str =~ /^(([^\s:]*)\:*([^\s:]*)\:|)\s*(.*\S)\s*$/) {
die "$fname:$line: cannot parse: [$str]\n";
}
$opr = "\L$2";
$tuple = "\L$3"; # Tuple type for AVX512
$opc = "\L$4";
$opr = lc($2);
$tuple = lc($3); # Tuple type for AVX512
$opc = lc($4);
my $op = 0;
$op = 0;
for ($i = 0; $i < length($opr); $i++) {
my $c = substr($opr,$i,1);
if ($c eq '+') {

View File

@ -64,7 +64,8 @@ sub process_line($) {
$reg_suffix = $4;
} else {
$nregs = 1;
undef $reg_prefix, $reg_suffix;
undef $reg_prefix;
undef $reg_suffix;
}
while ($nregs--) {