提交 92c5924a 编写于 作者: D Daniel P. Berrange

Remove tabs from all perl files & enforce this

The cfg.mk file rule to check for tab characters was not
applied to perl files. Much of our Perl code is full of
tabs as a result. Kill them, kill them all !
上级 cb612ee4
...@@ -41,28 +41,28 @@ open TEMPLATE, "<", $template or die "cannot read $template: $!"; ...@@ -41,28 +41,28 @@ open TEMPLATE, "<", $template or die "cannot read $template: $!";
my $group = 0; my $group = 0;
while (<TEMPLATE>) { while (<TEMPLATE>) {
if (/::CONFIG::/) { if (/::CONFIG::/) {
my $group = 0; my $group = 0;
print AUGTEST " let conf = \""; print AUGTEST " let conf = \"";
while (<CONFIG>) { while (<CONFIG>) {
if (/^#\w/) { if (/^#\w/) {
s/^#//; s/^#//;
s/\"/\\\"/g; s/\"/\\\"/g;
print AUGTEST $_; print AUGTEST $_;
$group = /\[\s$/; $group = /\[\s$/;
} elsif ($group) { } elsif ($group) {
s/\"/\\\"/g; s/\"/\\\"/g;
if (/#\s*\]/) { if (/#\s*\]/) {
$group = 0; $group = 0;
} }
if (/^#/) { if (/^#/) {
s/^#//; s/^#//;
print AUGTEST $_; print AUGTEST $_;
} }
} }
} }
print AUGTEST "\"\n"; print AUGTEST "\"\n";
} else { } else {
print AUGTEST $_; print AUGTEST $_;
} }
} }
......
...@@ -454,7 +454,7 @@ sc_size_of_brackets: ...@@ -454,7 +454,7 @@ sc_size_of_brackets:
# Ensure that no C source file, docs, or rng schema uses TABs for # Ensure that no C source file, docs, or rng schema uses TABs for
# indentation. Also match *.h.in files, to get libvirt.h.in. Exclude # indentation. Also match *.h.in files, to get libvirt.h.in. Exclude
# files in gnulib, since they're imported. # files in gnulib, since they're imported.
space_indent_files=(\.(rng|s?[ch](\.in)?|html.in|py|syms)|(daemon|tools)/.*\.in) space_indent_files=(\.(rng|s?[ch](\.in)?|html.in|py|pl|syms)|(daemon|tools)/.*\.in)
sc_TAB_in_indentation: sc_TAB_in_indentation:
@prohibit='^ * ' \ @prohibit='^ * ' \
in_vc_files='$(space_indent_files)$$' \ in_vc_files='$(space_indent_files)$$' \
......
...@@ -27,9 +27,9 @@ my %groupheaders = ( ...@@ -27,9 +27,9 @@ my %groupheaders = (
my @srcs; my @srcs;
find({ find({
wanted => sub { wanted => sub {
if (m!$srcdir/.*/\w+_(driver|tmpl|monitor|hal|udev)\.c$!) { if (m!$srcdir/.*/\w+_(driver|tmpl|monitor|hal|udev)\.c$!) {
push @srcs, $_ if $_ !~ /vbox_driver\.c/; push @srcs, $_ if $_ !~ /vbox_driver\.c/;
} }
}, no_chdir => 1}, $srcdir); }, no_chdir => 1}, $srcdir);
my $line; my $line;
...@@ -47,26 +47,26 @@ while (defined($line = <FILE>)) { ...@@ -47,26 +47,26 @@ while (defined($line = <FILE>)) {
next if $line =~ /^\s*$/; next if $line =~ /^\s*$/;
next if $line =~ /^\s*(global|local):/; next if $line =~ /^\s*(global|local):/;
if ($line =~ /^\s*LIBVIRT_(\d+\.\d+\.\d+)\s*{\s*$/) { if ($line =~ /^\s*LIBVIRT_(\d+\.\d+\.\d+)\s*{\s*$/) {
if (defined $vers) { if (defined $vers) {
die "malformed syms file"; die "malformed syms file";
} }
$vers = $1; $vers = $1;
} elsif ($line =~ /\s*}\s*;\s*$/) { } elsif ($line =~ /\s*}\s*;\s*$/) {
if (defined $prevvers) { if (defined $prevvers) {
die "malformed syms file"; die "malformed syms file";
} }
$prevvers = $vers; $prevvers = $vers;
$vers = undef; $vers = undef;
} elsif ($line =~ /\s*}\s*LIBVIRT_(\d+\.\d+\.\d+)\s*;\s*$/) { } elsif ($line =~ /\s*}\s*LIBVIRT_(\d+\.\d+\.\d+)\s*;\s*$/) {
if ($1 ne $prevvers) { if ($1 ne $prevvers) {
die "malformed syms file $1 != $vers"; die "malformed syms file $1 != $vers";
} }
$prevvers = $vers; $prevvers = $vers;
$vers = undef; $vers = undef;
} elsif ($line =~ /\s*(\w+)\s*;\s*$/) { } elsif ($line =~ /\s*(\w+)\s*;\s*$/) {
$apis{$1} = $vers; $apis{$1} = $vers;
} else { } else {
die "unexpected data $line\n"; die "unexpected data $line\n";
} }
} }
...@@ -86,26 +86,26 @@ while (defined($line = <FILE>)) { ...@@ -86,26 +86,26 @@ while (defined($line = <FILE>)) {
next if $line =~ /^\s*$/; next if $line =~ /^\s*$/;
next if $line =~ /^\s*(global|local):/; next if $line =~ /^\s*(global|local):/;
if ($line =~ /^\s*LIBVIRT_QEMU_(\d+\.\d+\.\d+)\s*{\s*$/) { if ($line =~ /^\s*LIBVIRT_QEMU_(\d+\.\d+\.\d+)\s*{\s*$/) {
if (defined $vers) { if (defined $vers) {
die "malformed syms file"; die "malformed syms file";
} }
$vers = $1; $vers = $1;
} elsif ($line =~ /\s*}\s*;\s*$/) { } elsif ($line =~ /\s*}\s*;\s*$/) {
if (defined $prevvers) { if (defined $prevvers) {
die "malformed syms file"; die "malformed syms file";
} }
$prevvers = $vers; $prevvers = $vers;
$vers = undef; $vers = undef;
} elsif ($line =~ /\s*}\s*LIBVIRT_QEMU_(\d+\.\d+\.\d+)\s*;\s*$/) { } elsif ($line =~ /\s*}\s*LIBVIRT_QEMU_(\d+\.\d+\.\d+)\s*;\s*$/) {
if ($1 ne $prevvers) { if ($1 ne $prevvers) {
die "malformed syms file $1 != $vers"; die "malformed syms file $1 != $vers";
} }
$prevvers = $vers; $prevvers = $vers;
$vers = undef; $vers = undef;
} elsif ($line =~ /\s*(\w+)\s*;\s*$/) { } elsif ($line =~ /\s*(\w+)\s*;\s*$/) {
$apis{$1} = $vers; $apis{$1} = $vers;
} else { } else {
die "unexpected data $line\n"; die "unexpected data $line\n";
} }
} }
...@@ -143,31 +143,31 @@ my %groups; ...@@ -143,31 +143,31 @@ my %groups;
my $ingrp; my $ingrp;
while (defined($line = <FILE>)) { while (defined($line = <FILE>)) {
if ($line =~ /struct _(vir\w*(?:Driver|Monitor))/) { if ($line =~ /struct _(vir\w*(?:Driver|Monitor))/) {
my $grp = $1; my $grp = $1;
if ($grp ne "virStateDriver" && if ($grp ne "virStateDriver" &&
$grp ne "virStreamDriver") { $grp ne "virStreamDriver") {
$ingrp = $grp; $ingrp = $grp;
$groups{$ingrp} = { apis => {}, drivers => {} }; $groups{$ingrp} = { apis => {}, drivers => {} };
} }
} elsif ($ingrp) { } elsif ($ingrp) {
if ($line =~ /^\s*vir(?:Drv|DevMon)(\w+)\s+(\w+);\s*$/) { if ($line =~ /^\s*vir(?:Drv|DevMon)(\w+)\s+(\w+);\s*$/) {
my $field = $2; my $field = $2;
my $name = $1; my $name = $1;
my $api; my $api;
if (exists $apis{"vir$name"}) { if (exists $apis{"vir$name"}) {
$api = "vir$name"; $api = "vir$name";
} elsif (exists $apis{"virConnect$name"}) { } elsif (exists $apis{"virConnect$name"}) {
$api = "virConnect$name"; $api = "virConnect$name";
} elsif (exists $apis{"virNode$name"}) { } elsif (exists $apis{"virNode$name"}) {
$api = "virNode$name"; $api = "virNode$name";
} else { } else {
die "driver $name does not have a public API"; die "driver $name does not have a public API";
} }
$groups{$ingrp}->{apis}->{$field} = $api; $groups{$ingrp}->{apis}->{$field} = $api;
} elsif ($line =~ /};/) { } elsif ($line =~ /};/) {
$ingrp = undef; $ingrp = undef;
} }
} }
} }
...@@ -179,60 +179,60 @@ close FILE; ...@@ -179,60 +179,60 @@ close FILE;
foreach my $src (@srcs) { foreach my $src (@srcs) {
open FILE, "<$src" or open FILE, "<$src" or
die "cannot read $src: $!"; die "cannot read $src: $!";
$ingrp = undef; $ingrp = undef;
my $impl; my $impl;
while (defined($line = <FILE>)) { while (defined($line = <FILE>)) {
if (!$ingrp) { if (!$ingrp) {
foreach my $grp (keys %groups) { foreach my $grp (keys %groups) {
if ($line =~ /^\s*(?:static\s+)?$grp\s+(\w+)\s*=\s*{/ || if ($line =~ /^\s*(?:static\s+)?$grp\s+(\w+)\s*=\s*{/ ||
$line =~ /^\s*(?:static\s+)?$grp\s+NAME\(\w+\)\s*=\s*{/) { $line =~ /^\s*(?:static\s+)?$grp\s+NAME\(\w+\)\s*=\s*{/) {
$ingrp = $grp; $ingrp = $grp;
$impl = $src; $impl = $src;
if ($impl =~ m,.*/node_device_(\w+)\.c,) { if ($impl =~ m,.*/node_device_(\w+)\.c,) {
$impl = $1; $impl = $1;
} else { } else {
$impl =~ s,.*/(\w+?)_((\w+)_)?(\w+)\.c,$1,; $impl =~ s,.*/(\w+?)_((\w+)_)?(\w+)\.c,$1,;
} }
if ($groups{$ingrp}->{drivers}->{$impl}) { if ($groups{$ingrp}->{drivers}->{$impl}) {
die "Group $ingrp already contains $impl"; die "Group $ingrp already contains $impl";
} }
$groups{$ingrp}->{drivers}->{$impl} = {}; $groups{$ingrp}->{drivers}->{$impl} = {};
} }
} }
} else { } else {
if ($line =~ m!\s*\.(\w+)\s*=\s*(\w+)\s*,?\s*(?:/\*\s*(\d+\.\d+\.\d+)\s*\*/\s*)?$!) { if ($line =~ m!\s*\.(\w+)\s*=\s*(\w+)\s*,?\s*(?:/\*\s*(\d+\.\d+\.\d+)\s*\*/\s*)?$!) {
my $api = $1; my $api = $1;
my $meth = $2; my $meth = $2;
my $vers = $3; my $vers = $3;
next if $api eq "no" || $api eq "name"; next if $api eq "no" || $api eq "name";
die "Method $meth in $src is missing version" unless defined $vers; die "Method $meth in $src is missing version" unless defined $vers;
die "Driver method for $api is NULL in $src" if $meth eq "NULL"; die "Driver method for $api is NULL in $src" if $meth eq "NULL";
if (!exists($groups{$ingrp}->{apis}->{$api})) { if (!exists($groups{$ingrp}->{apis}->{$api})) {
die "Found unexpected method $api in $ingrp\n"; die "Found unexpected method $api in $ingrp\n";
} }
$groups{$ingrp}->{drivers}->{$impl}->{$api} = $vers; $groups{$ingrp}->{drivers}->{$impl}->{$api} = $vers;
if ($api eq "domainMigratePrepare" || if ($api eq "domainMigratePrepare" ||
$api eq "domainMigratePrepare2" || $api eq "domainMigratePrepare2" ||
$api eq "domainMigratePrepare3") { $api eq "domainMigratePrepare3") {
$groups{$ingrp}->{drivers}->{$impl}->{"domainMigrate"} = $vers $groups{$ingrp}->{drivers}->{$impl}->{"domainMigrate"} = $vers
unless $groups{$ingrp}->{drivers}->{$impl}->{"domainMigrate"}; unless $groups{$ingrp}->{drivers}->{$impl}->{"domainMigrate"};
} }
} elsif ($line =~ /}/) { } elsif ($line =~ /}/) {
$ingrp = undef; $ingrp = undef;
} }
} }
} }
close FILE; close FILE;
...@@ -253,21 +253,21 @@ foreach my $drv (keys %{$groups{"virDriver"}->{drivers}}) { ...@@ -253,21 +253,21 @@ foreach my $drv (keys %{$groups{"virDriver"}->{drivers}}) {
my $openVersStr = $groups{"virDriver"}->{drivers}->{$drv}->{"open"}; my $openVersStr = $groups{"virDriver"}->{drivers}->{$drv}->{"open"};
my $openVers; my $openVers;
if ($openVersStr =~ /(\d+)\.(\d+)\.(\d+)/) { if ($openVersStr =~ /(\d+)\.(\d+)\.(\d+)/) {
$openVers = ($1 * 1000 * 1000) + ($2 * 1000) + $3; $openVers = ($1 * 1000 * 1000) + ($2 * 1000) + $3;
} }
# virConnectOpenReadOnly always matches virConnectOpen version # virConnectOpenReadOnly always matches virConnectOpen version
$groups{"virDriver"}->{drivers}->{$drv}->{"openReadOnly"} = $groups{"virDriver"}->{drivers}->{$drv}->{"openReadOnly"} =
$groups{"virDriver"}->{drivers}->{$drv}->{"open"}; $groups{"virDriver"}->{drivers}->{$drv}->{"open"};
# virConnectOpenAuth is always 0.4.0 if the driver existed # virConnectOpenAuth is always 0.4.0 if the driver existed
# before this time, otherwise it matches the version of # before this time, otherwise it matches the version of
# the driver's virConnectOpen entry # the driver's virConnectOpen entry
if ($openVersStr eq "Y" || if ($openVersStr eq "Y" ||
$openVers >= $openAuthVers) { $openVers >= $openAuthVers) {
$groups{"virDriver"}->{drivers}->{$drv}->{"openAuth"} = $openVersStr; $groups{"virDriver"}->{drivers}->{$drv}->{"openAuth"} = $openVersStr;
} else { } else {
$groups{"virDriver"}->{drivers}->{$drv}->{"openAuth"} = "0.4.0"; $groups{"virDriver"}->{drivers}->{$drv}->{"openAuth"} = "0.4.0";
} }
} }
...@@ -283,17 +283,17 @@ foreach my $drv (keys %{$groups{"virDriver"}->{drivers}}) { ...@@ -283,17 +283,17 @@ foreach my $drv (keys %{$groups{"virDriver"}->{drivers}}) {
next unless defined $createVersStr; next unless defined $createVersStr;
my $createVers; my $createVers;
if ($createVersStr =~ /(\d+)\.(\d+)\.(\d+)/) { if ($createVersStr =~ /(\d+)\.(\d+)\.(\d+)/) {
$createVers = ($1 * 1000 * 1000) + ($2 * 1000) + $3; $createVers = ($1 * 1000 * 1000) + ($2 * 1000) + $3;
} }
# virCreateLinux is always 0.0.3 if the driver existed # virCreateLinux is always 0.0.3 if the driver existed
# before this time, otherwise it matches the version of # before this time, otherwise it matches the version of
# the driver's virCreateXML entry # the driver's virCreateXML entry
if ($createVersStr eq "Y" || if ($createVersStr eq "Y" ||
$createVers >= $createAPIVers) { $createVers >= $createAPIVers) {
$groups{"virDriver"}->{drivers}->{$drv}->{"domainCreateLinux"} = $createVersStr; $groups{"virDriver"}->{drivers}->{$drv}->{"domainCreateLinux"} = $createVersStr;
} else { } else {
$groups{"virDriver"}->{drivers}->{$drv}->{"domainCreateLinux"} = "0.0.3"; $groups{"virDriver"}->{drivers}->{$drv}->{"domainCreateLinux"} = "0.0.3";
} }
} }
...@@ -329,7 +329,7 @@ foreach my $grp (sort { $a cmp $b } keys %groups) { ...@@ -329,7 +329,7 @@ foreach my $grp (sort { $a cmp $b } keys %groups) {
EOF EOF
foreach my $drv (sort { $a cmp $b } keys %{$groups{$grp}->{drivers}}) { foreach my $drv (sort { $a cmp $b } keys %{$groups{$grp}->{drivers}}) {
print " <th>$drv</th>\n"; print " <th>$drv</th>\n";
} }
print <<EOF; print <<EOF;
...@@ -340,27 +340,27 @@ EOF ...@@ -340,27 +340,27 @@ EOF
my $row = 0; my $row = 0;
foreach my $field (sort { foreach my $field (sort {
$groups{$grp}->{apis}->{$a} $groups{$grp}->{apis}->{$a}
cmp cmp
$groups{$grp}->{apis}->{$b} $groups{$grp}->{apis}->{$b}
} keys %{$groups{$grp}->{apis}}) { } keys %{$groups{$grp}->{apis}}) {
my $api = $groups{$grp}->{apis}->{$field}; my $api = $groups{$grp}->{apis}->{$field};
my $vers = $apis{$api}; my $vers = $apis{$api};
print <<EOF; print <<EOF;
<tr> <tr>
<td><a href=\"html/libvirt-libvirt.html#$api\">$api</a></td> <td><a href=\"html/libvirt-libvirt.html#$api\">$api</a></td>
<td>$vers</td> <td>$vers</td>
EOF EOF
foreach my $drv (sort {$a cmp $b } keys %{$groups{$grp}->{drivers}}) { foreach my $drv (sort {$a cmp $b } keys %{$groups{$grp}->{drivers}}) {
if (exists $groups{$grp}->{drivers}->{$drv}->{$field}) { if (exists $groups{$grp}->{drivers}->{$drv}->{$field}) {
print "<td>", $groups{$grp}->{drivers}->{$drv}->{$field}, "</td>\n"; print "<td>", $groups{$grp}->{drivers}->{$drv}->{$field}, "</td>\n";
} else { } else {
print "<td></td>\n"; print "<td></td>\n";
} }
} }
print <<EOF; print <<EOF;
</tr> </tr>
EOF EOF
...@@ -373,13 +373,13 @@ EOF ...@@ -373,13 +373,13 @@ EOF
EOF EOF
foreach my $drv (sort { $a cmp $b } keys %{$groups{$grp}->{drivers}}) { foreach my $drv (sort { $a cmp $b } keys %{$groups{$grp}->{drivers}}) {
print " <th>$drv</th>\n"; print " <th>$drv</th>\n";
} }
print <<EOF; print <<EOF;
</tr> </tr>
EOF EOF
} }
} }
......
...@@ -22,17 +22,17 @@ my $blurb = $cfg->get("output/blurb", undef); ...@@ -22,17 +22,17 @@ my $blurb = $cfg->get("output/blurb", undef);
$SIG{__DIE__} = sub { $SIG{__DIE__} = sub {
my $err = shift; my $err = shift;
if (UNIVERSAL::isa($err, "BZ::Client::Exception")) { if (UNIVERSAL::isa($err, "BZ::Client::Exception")) {
die "Unable to access bugzilla: " . $err->message; die "Unable to access bugzilla: " . $err->message;
} }
die $err; die $err;
}; };
my $client = BZ::Client->new(url => $server, my $client = BZ::Client->new(url => $server,
user => $username, user => $username,
password => $password); password => $password);
my $todo = BZ::Client::Bug->search($client, {'product' => $product, my $todo = BZ::Client::Bug->search($client, {'product' => $product,
'alias' => $todoalias}); 'alias' => $todoalias});
die "Cannot find bug alias 'libvirtTodo'" unless $#{$todo} > -1; die "Cannot find bug alias 'libvirtTodo'" unless $#{$todo} > -1;
my $todoid = $todo->[0]->{'bug_id'}; my $todoid = $todo->[0]->{'bug_id'};
...@@ -42,7 +42,7 @@ $todosummary =~ s/^\s*\[\s*RFE\s*\]\s*:?\s*//; ...@@ -42,7 +42,7 @@ $todosummary =~ s/^\s*\[\s*RFE\s*\]\s*:?\s*//;
$todosummary =~ s/^\s*Tracker\s*:\s*//; $todosummary =~ s/^\s*Tracker\s*:\s*//;
my $trackers = BZ::Client::Bug->search($client, {'product' => $product, my $trackers = BZ::Client::Bug->search($client, {'product' => $product,
'blocked' => $todoid }); 'blocked' => $todoid });
my @trackers; my @trackers;
...@@ -55,27 +55,27 @@ foreach my $tracker (@{$trackers}) { ...@@ -55,27 +55,27 @@ foreach my $tracker (@{$trackers}) {
$summary =~ s/^\s*Tracker\s*:\s*//; $summary =~ s/^\s*Tracker\s*:\s*//;
push @trackers, { push @trackers, {
id => $tracker->{'bug_id'}, id => $tracker->{'bug_id'},
summary => $summary, summary => $summary,
features => [], features => [],
}; };
} }
foreach my $tracker (@trackers) { foreach my $tracker (@trackers) {
my $features = BZ::Client::Bug->search($client, {'product' => $product, my $features = BZ::Client::Bug->search($client, {'product' => $product,
'blocked' => $tracker->{id}}); 'blocked' => $tracker->{id}});
foreach my $feature (@{$features}) { foreach my $feature (@{$features}) {
next if $feature->{'bug_status'} eq "CLOSED"; next if $feature->{'bug_status'} eq "CLOSED";
my $summary = $feature->{'short_desc'}; my $summary = $feature->{'short_desc'};
$summary =~ s/^\s*RFE\s*:\s*//; $summary =~ s/^\s*RFE\s*:\s*//;
$summary =~ s/^\s*\[\s*RFE\s*\]\s*:?\s*//; $summary =~ s/^\s*\[\s*RFE\s*\]\s*:?\s*//;
push @{$tracker->{features}}, { push @{$tracker->{features}}, {
id => $feature->{'bug_id'}, id => $feature->{'bug_id'},
summary => $summary, summary => $summary,
}; };
} }
} }
...@@ -108,11 +108,11 @@ foreach my $tracker (sort { $a->{summary} cmp $b->{summary} } @trackers) { ...@@ -108,11 +108,11 @@ foreach my $tracker (sort { $a->{summary} cmp $b->{summary} } @trackers) {
print " <h2><a href=\"$server/$id\">$summary</a></h2>\n"; print " <h2><a href=\"$server/$id\">$summary</a></h2>\n";
print " <ul>\n"; print " <ul>\n";
foreach my $feature (sort { $a->{summary} cmp $b->{summary} } @{$tracker->{features}}) { foreach my $feature (sort { $a->{summary} cmp $b->{summary} } @{$tracker->{features}}) {
$summary = &escape($feature->{summary}); $summary = &escape($feature->{summary});
$summary =~ s,^([^:]+):,<strong>$1</strong>,; $summary =~ s,^([^:]+):,<strong>$1</strong>,;
$id = $feature->{id}; $id = $feature->{id};
print " <li>$summary (<strong>rhbz <a href=\"$server/$id\">$id</a></strong>)</li>\n"; print " <li>$summary (<strong>rhbz <a href=\"$server/$id\">$id</a></strong>)</li>\n";
} }
print " </ul>\n"; print " </ul>\n";
} }
......
...@@ -34,9 +34,9 @@ foreach my $elflib (@elflibs) { ...@@ -34,9 +34,9 @@ foreach my $elflib (@elflibs) {
open NM, "-|", "nm", $elflib or die "cannot run 'nm $elflib': $!"; open NM, "-|", "nm", $elflib or die "cannot run 'nm $elflib': $!";
while (<NM>) { while (<NM>) {
next unless /^\S+\s(?:T|D)\s(\S+)\s*$/; next unless /^\S+\s(?:T|D)\s(\S+)\s*$/;
$gotsyms{$1} = 1; $gotsyms{$1} = 1;
} }
close NM; close NM;
......
...@@ -46,38 +46,38 @@ while (<>) { ...@@ -46,38 +46,38 @@ while (<>) {
next if /^\s*};\s*$/; next if /^\s*};\s*$/;
if (m,^\s*\#,) { if (m,^\s*\#,) {
if (m,^\s*\#\s*file:\s*(\S+)\s*$,) { if (m,^\s*\#\s*file:\s*(\S+)\s*$,) {
$file = $1; $file = $1;
push @files, $file; push @files, $file;
$files{$file} = { prefix => undef, probes => [] }; $files{$file} = { prefix => undef, probes => [] };
} elsif (m,^\s*\#\s*prefix:\s*(\S+)\s*$,) { } elsif (m,^\s*\#\s*prefix:\s*(\S+)\s*$,) {
$files{$file}->{prefix} = $1; $files{$file}->{prefix} = $1;
} elsif (m,^\s*\#\s*binary:\s*(\S+)\s*$,) { } elsif (m,^\s*\#\s*binary:\s*(\S+)\s*$,) {
$files{$file}->{binary} = $1; $files{$file}->{binary} = $1;
} else { } else {
# ignore unknown comments # ignore unknown comments
} }
} else { } else {
if (m,\s*probe\s+([a-zA-Z0-9_]+)\((.*?)(\);)?$,) { if (m,\s*probe\s+([a-zA-Z0-9_]+)\((.*?)(\);)?$,) {
$probe = $1; $probe = $1;
$args = $2; $args = $2;
if ($3) { if ($3) {
push @{$files{$file}->{probes}}, [$probe, $args]; push @{$files{$file}->{probes}}, [$probe, $args];
$probe = $args = undef; $probe = $args = undef;
} }
} elsif ($probe) { } elsif ($probe) {
if (m,^(.*?)(\);)?$,) { if (m,^(.*?)(\);)?$,) {
$args .= $1; $args .= $1;
if ($2) { if ($2) {
push @{$files{$file}->{probes}}, [$probe, $args]; push @{$files{$file}->{probes}}, [$probe, $args];
$probe = $args = undef; $probe = $args = undef;
} }
} else { } else {
die "unexpected data $_ on line $."; die "unexpected data $_ on line $.";
} }
} else { } else {
die "unexpected data $_ on line $."; die "unexpected data $_ on line $.";
} }
} }
} }
...@@ -88,32 +88,32 @@ foreach my $file (@files) { ...@@ -88,32 +88,32 @@ foreach my $file (@files) {
print "# $file\n\n"; print "# $file\n\n";
foreach my $probe (@probes) { foreach my $probe (@probes) {
my $name = $probe->[0]; my $name = $probe->[0];
my $args = $probe->[1]; my $args = $probe->[1];
my $pname = $name; my $pname = $name;
$pname =~ s/${prefix}_/libvirt.$prefix./; $pname =~ s/${prefix}_/libvirt.$prefix./;
my $binary = "$libdir/libvirt.so"; my $binary = "$libdir/libvirt.so";
if (exists $files{$file}->{binary}) { if (exists $files{$file}->{binary}) {
$binary = $sbindir . "/" . $files{$file}->{binary}; $binary = $sbindir . "/" . $files{$file}->{binary};
} }
print "probe $pname = process(\"$binary\").mark(\"$name\") {\n"; print "probe $pname = process(\"$binary\").mark(\"$name\") {\n";
my @args = split /,/, $args; my @args = split /,/, $args;
for (my $i = 0 ; $i <= $#args ; $i++) { for (my $i = 0 ; $i <= $#args ; $i++) {
my $arg = $args[$i]; my $arg = $args[$i];
my $isstr = $arg =~ /char\s+\*/; my $isstr = $arg =~ /char\s+\*/;
$arg =~ s/^.*\s\*?(\S+)$/$1/; $arg =~ s/^.*\s\*?(\S+)$/$1/;
if ($isstr) { if ($isstr) {
print " $arg = user_string(\$arg", $i + 1, ");\n"; print " $arg = user_string(\$arg", $i + 1, ");\n";
} else { } else {
print " $arg = \$arg", $i + 1, ";\n"; print " $arg = \$arg", $i + 1, ";\n";
} }
} }
print "}\n\n"; print "}\n\n";
} }
print "\n"; print "\n";
} }
...@@ -54,11 +54,11 @@ sub name_to_ProcName { ...@@ -54,11 +54,11 @@ sub name_to_ProcName {
my @elems; my @elems;
if ($name =~ /_/ || (lc $name) eq "open" || (lc $name) eq "close") { if ($name =~ /_/ || (lc $name) eq "open" || (lc $name) eq "close") {
@elems = split /_/, $name; @elems = split /_/, $name;
@elems = map lc, @elems; @elems = map lc, @elems;
@elems = map ucfirst, @elems; @elems = map ucfirst, @elems;
} else { } else {
@elems = $name; @elems = $name;
} }
@elems = map { fixup_name($_) } @elems; @elems = map { fixup_name($_) } @elems;
my $procname = join "", @elems; my $procname = join "", @elems;
...@@ -332,53 +332,53 @@ elsif ($opt_b) { ...@@ -332,53 +332,53 @@ elsif ($opt_b) {
# skip things which are REMOTE_MESSAGE # skip things which are REMOTE_MESSAGE
next if $call->{msg}; next if $call->{msg};
my $name = $structprefix . "Dispatch" . $call->{ProcName}; my $name = $structprefix . "Dispatch" . $call->{ProcName};
my $argtype = $call->{args}; my $argtype = $call->{args};
my $rettype = $call->{ret}; my $rettype = $call->{ret};
my $argann = $argtype ne "void" ? "" : " ATTRIBUTE_UNUSED"; my $argann = $argtype ne "void" ? "" : " ATTRIBUTE_UNUSED";
my $retann = $rettype ne "void" ? "" : " ATTRIBUTE_UNUSED"; my $retann = $rettype ne "void" ? "" : " ATTRIBUTE_UNUSED";
# First we print out a function declaration for the # First we print out a function declaration for the
# real dispatcher body # real dispatcher body
print "static int ${name}(\n"; print "static int ${name}(\n";
print " virNetServerPtr server,\n"; print " virNetServerPtr server,\n";
print " virNetServerClientPtr client,\n"; print " virNetServerClientPtr client,\n";
print " virNetMessagePtr msg,\n"; print " virNetMessagePtr msg,\n";
print " virNetMessageErrorPtr rerr"; print " virNetMessageErrorPtr rerr";
if ($argtype ne "void") { if ($argtype ne "void") {
print ",\n $argtype *args"; print ",\n $argtype *args";
} }
if ($rettype ne "void") { if ($rettype ne "void") {
print ",\n $rettype *ret"; print ",\n $rettype *ret";
} }
print ");\n"; print ");\n";
# Next we print out a generic wrapper method which has # Next we print out a generic wrapper method which has
# fixed function signature, for use in the dispatcher # fixed function signature, for use in the dispatcher
# table. This simply callers the real dispatcher method # table. This simply callers the real dispatcher method
print "static int ${name}Helper(\n"; print "static int ${name}Helper(\n";
print " virNetServerPtr server,\n"; print " virNetServerPtr server,\n";
print " virNetServerClientPtr client,\n"; print " virNetServerClientPtr client,\n";
print " virNetMessagePtr msg,\n"; print " virNetMessagePtr msg,\n";
print " virNetMessageErrorPtr rerr,\n"; print " virNetMessageErrorPtr rerr,\n";
print " void *args$argann,\n"; print " void *args$argann,\n";
print " void *ret$retann)\n"; print " void *ret$retann)\n";
print "{\n"; print "{\n";
print " VIR_DEBUG(\"server=%p client=%p msg=%p rerr=%p args=%p ret=%p\", server, client, msg, rerr, args, ret);\n"; print " VIR_DEBUG(\"server=%p client=%p msg=%p rerr=%p args=%p ret=%p\", server, client, msg, rerr, args, ret);\n";
print " return $name(server, client, msg, rerr"; print " return $name(server, client, msg, rerr";
if ($argtype ne "void") { if ($argtype ne "void") {
print ", args"; print ", args";
} }
if ($rettype ne "void") { if ($rettype ne "void") {
print ", ret"; print ", ret";
} }
print ");\n"; print ");\n";
print "}\n"; print "}\n";
# Finally we print out the dispatcher method body impl # Finally we print out the dispatcher method body impl
# (if possible) # (if possible)
if (!exists($generate{$call->{ProcName}})) { if (!exists($generate{$call->{ProcName}})) {
print "/* ${structprefix}Dispatch$call->{ProcName} body has " . print "/* ${structprefix}Dispatch$call->{ProcName} body has " .
"to be implemented manually */\n\n\n\n"; "to be implemented manually */\n\n\n\n";
...@@ -794,18 +794,18 @@ elsif ($opt_b) { ...@@ -794,18 +794,18 @@ elsif ($opt_b) {
} }
# print functions signature # print functions signature
print "static int $name(\n"; print "static int $name(\n";
print " virNetServerPtr server ATTRIBUTE_UNUSED,\n"; print " virNetServerPtr server ATTRIBUTE_UNUSED,\n";
print " virNetServerClientPtr client,\n"; print " virNetServerClientPtr client,\n";
print " virNetMessagePtr msg ATTRIBUTE_UNUSED,\n"; print " virNetMessagePtr msg ATTRIBUTE_UNUSED,\n";
print " virNetMessageErrorPtr rerr"; print " virNetMessageErrorPtr rerr";
if ($argtype ne "void") { if ($argtype ne "void") {
print ",\n $argtype *args"; print ",\n $argtype *args";
} }
if ($rettype ne "void") { if ($rettype ne "void") {
print ",\n $rettype *ret"; print ",\n $rettype *ret";
} }
print ")\n"; print ")\n";
# print function body # print function body
print "{\n"; print "{\n";
...@@ -814,7 +814,7 @@ elsif ($opt_b) { ...@@ -814,7 +814,7 @@ elsif ($opt_b) {
foreach my $var (@vars_list) { foreach my $var (@vars_list) {
print " $var;\n"; print " $var;\n";
} }
print " struct daemonClientPrivate *priv =\n"; print " struct daemonClientPrivate *priv =\n";
print " virNetServerClientGetPrivateData(client);\n"; print " virNetServerClientGetPrivateData(client);\n";
if ($call->{streamflag} ne "none") { if ($call->{streamflag} ne "none") {
...@@ -994,32 +994,32 @@ elsif ($opt_b) { ...@@ -994,32 +994,32 @@ elsif ($opt_b) {
print "virNetServerProgramProc ${structprefix}Procs[] = {\n"; print "virNetServerProgramProc ${structprefix}Procs[] = {\n";
for ($id = 0 ; $id <= $#calls ; $id++) { for ($id = 0 ; $id <= $#calls ; $id++) {
my ($comment, $name, $argtype, $arglen, $argfilter, $retlen, $retfilter, $priority); my ($comment, $name, $argtype, $arglen, $argfilter, $retlen, $retfilter, $priority);
if (defined $calls[$id] && !$calls[$id]->{msg}) { if (defined $calls[$id] && !$calls[$id]->{msg}) {
$comment = "/* Method $calls[$id]->{ProcName} => $id */"; $comment = "/* Method $calls[$id]->{ProcName} => $id */";
$name = $structprefix . "Dispatch" . $calls[$id]->{ProcName} . "Helper"; $name = $structprefix . "Dispatch" . $calls[$id]->{ProcName} . "Helper";
my $argtype = $calls[$id]->{args}; my $argtype = $calls[$id]->{args};
my $rettype = $calls[$id]->{ret}; my $rettype = $calls[$id]->{ret};
$arglen = $argtype ne "void" ? "sizeof($argtype)" : "0"; $arglen = $argtype ne "void" ? "sizeof($argtype)" : "0";
$retlen = $rettype ne "void" ? "sizeof($rettype)" : "0"; $retlen = $rettype ne "void" ? "sizeof($rettype)" : "0";
$argfilter = $argtype ne "void" ? "xdr_$argtype" : "xdr_void"; $argfilter = $argtype ne "void" ? "xdr_$argtype" : "xdr_void";
$retfilter = $rettype ne "void" ? "xdr_$rettype" : "xdr_void"; $retfilter = $rettype ne "void" ? "xdr_$rettype" : "xdr_void";
} else { } else {
if ($calls[$id]->{msg}) { if ($calls[$id]->{msg}) {
$comment = "/* Async event $calls[$id]->{ProcName} => $id */"; $comment = "/* Async event $calls[$id]->{ProcName} => $id */";
} else { } else {
$comment = "/* Unused $id */"; $comment = "/* Unused $id */";
} }
$name = "NULL"; $name = "NULL";
$arglen = $retlen = 0; $arglen = $retlen = 0;
$argfilter = "xdr_void"; $argfilter = "xdr_void";
$retfilter = "xdr_void"; $retfilter = "xdr_void";
} }
$priority = defined $calls[$id]->{priority} ? $calls[$id]->{priority} : 0; $priority = defined $calls[$id]->{priority} ? $calls[$id]->{priority} : 0;
print "{ $comment\n ${name},\n $arglen,\n (xdrproc_t)$argfilter,\n $retlen,\n (xdrproc_t)$retfilter,\n true,\n $priority\n},\n"; print "{ $comment\n ${name},\n $arglen,\n (xdrproc_t)$argfilter,\n $retlen,\n (xdrproc_t)$retfilter,\n true,\n $priority\n},\n";
} }
print "};\n"; print "};\n";
print "size_t ${structprefix}NProcs = ARRAY_CARDINALITY(${structprefix}Procs);\n"; print "size_t ${structprefix}NProcs = ARRAY_CARDINALITY(${structprefix}Procs);\n";
...@@ -1039,8 +1039,8 @@ elsif ($opt_k) { ...@@ -1039,8 +1039,8 @@ elsif ($opt_k) {
# skip procedures not on generate list # skip procedures not on generate list
next if ! exists($generate{$call->{ProcName}}); next if ! exists($generate{$call->{ProcName}});
my $argtype = $call->{args}; my $argtype = $call->{args};
my $rettype = $call->{ret}; my $rettype = $call->{ret};
# handle arguments to the function # handle arguments to the function
my @args_list = (); my @args_list = ();
...@@ -1574,10 +1574,10 @@ elsif ($opt_k) { ...@@ -1574,10 +1574,10 @@ elsif ($opt_k) {
} }
if ($call->{ProcName} eq "DomainDestroy" || if ($call->{ProcName} eq "DomainDestroy" ||
$call->{ProcName} eq "DomainSave" || $call->{ProcName} eq "DomainSave" ||
$call->{ProcName} eq "DomainManagedSave") { $call->{ProcName} eq "DomainManagedSave") {
# SPECIAL: virDomain{Destroy|Save|ManagedSave} need to reset # SPECIAL: virDomain{Destroy|Save|ManagedSave} need to reset
# the domain id explicitly on success # the domain id explicitly on success
print " dom->id = -1;\n"; print " dom->id = -1;\n";
} }
......
...@@ -41,14 +41,14 @@ while (<RPCGEN>) { ...@@ -41,14 +41,14 @@ while (<RPCGEN>) {
# We only want to fixup the GLibc rpcgen output # We only want to fixup the GLibc rpcgen output
# So just print data unchanged, if non-Linux # So just print data unchanged, if non-Linux
unless ($fixup) { unless ($fixup) {
print TARGET; print TARGET;
next; next;
} }
if (m/^{/) { if (m/^{/) {
$in_function = 1; $in_function = 1;
print TARGET; print TARGET;
next; next;
} }
s/\t/ /g; s/\t/ /g;
...@@ -64,58 +64,58 @@ while (<RPCGEN>) { ...@@ -64,58 +64,58 @@ while (<RPCGEN>) {
s/(?<!IXDR_GET_INT32 )IXDR_GET_LONG/IXDR_GET_INT32/g; s/(?<!IXDR_GET_INT32 )IXDR_GET_LONG/IXDR_GET_INT32/g;
if (m/^}/) { if (m/^}/) {
$in_function = 0; $in_function = 0;
# Note: The body of the function is in @function. # Note: The body of the function is in @function.
# Remove decl of buf, if buf isn't used in the function. # Remove decl of buf, if buf isn't used in the function.
my @uses = grep /[^.>]\bbuf\b/, @function; my @uses = grep /[^.>]\bbuf\b/, @function;
@function = grep !/[^.>]\bbuf\b/, @function if @uses == 1; @function = grep !/[^.>]\bbuf\b/, @function if @uses == 1;
# Remove decl of i, if i isn't used in the function. # Remove decl of i, if i isn't used in the function.
@uses = grep /[^.>]\bi\b/, @function; @uses = grep /[^.>]\bi\b/, @function;
@function = grep !/[^.>]\bi\b/, @function if @uses == 1; @function = grep !/[^.>]\bi\b/, @function if @uses == 1;
# (char **)&objp->... gives: # (char **)&objp->... gives:
# warning: dereferencing type-punned pointer will break # warning: dereferencing type-punned pointer will break
# strict-aliasing rules # strict-aliasing rules
# so rewrite it. # so rewrite it.
my %uses = (); my %uses = ();
my $i = 0; my $i = 0;
foreach (@function) { foreach (@function) {
$uses{$1} = $i++ if m/\(char \*\*\)\&(objp->[a-z_.]+_val)/i; $uses{$1} = $i++ if m/\(char \*\*\)\&(objp->[a-z_.]+_val)/i;
} }
if (keys %uses >= 1) { if (keys %uses >= 1) {
my $i = 1; my $i = 1;
foreach (keys %uses) { foreach (keys %uses) {
$i = $uses{$_}; $i = $uses{$_};
unshift @function, unshift @function,
(" char **objp_cpp$i = (char **) (void *) &$_;\n"); (" char **objp_cpp$i = (char **) (void *) &$_;\n");
$i++; $i++;
} }
@function = @function =
map { s{\(char \*\*\)\&(objp->[a-z_.]+_val)} map { s{\(char \*\*\)\&(objp->[a-z_.]+_val)}
{objp_cpp$uses{$1}}gi; $_ } @function; {objp_cpp$uses{$1}}gi; $_ } @function;
} }
# The code uses 'IXDR_PUT_{U_,}LONG' but it's wrong in two # The code uses 'IXDR_PUT_{U_,}LONG' but it's wrong in two
# ways: Firstly these functions are deprecated and don't # ways: Firstly these functions are deprecated and don't
# work on 64 bit platforms. Secondly the return value should # work on 64 bit platforms. Secondly the return value should
# be ignored. Correct both these mistakes. # be ignored. Correct both these mistakes.
@function = @function =
map { s/\bIXDR_PUT_((U_)?)LONG\b/(void)IXDR_PUT_$1INT32/; $_ } map { s/\bIXDR_PUT_((U_)?)LONG\b/(void)IXDR_PUT_$1INT32/; $_ }
map { s/\bXDR_INLINE\b/(int32_t*)XDR_INLINE/; $_ } map { s/\bXDR_INLINE\b/(int32_t*)XDR_INLINE/; $_ }
@function; @function;
print TARGET (join ("", @function)); print TARGET (join ("", @function));
@function = (); @function = ();
} }
unless ($in_function) { unless ($in_function) {
print TARGET; print TARGET;
} else { } else {
push @function, $_; push @function, $_;
} }
} }
......
...@@ -37,33 +37,33 @@ my $intype = 0; ...@@ -37,33 +37,33 @@ my $intype = 0;
my $inauth = 0; my $inauth = 0;
while (<>) { while (<>) {
if (/enum\s+virNetMessageType/) { if (/enum\s+virNetMessageType/) {
$intype = 1; $intype = 1;
} elsif (/enum\s+virNetMessageStatus/) { } elsif (/enum\s+virNetMessageStatus/) {
$instatus = 1; $instatus = 1;
} elsif (/enum remote_auth_type/) { } elsif (/enum remote_auth_type/) {
$inauth = 1; $inauth = 1;
} elsif (/}/) { } elsif (/}/) {
$instatus = $intype = $inauth = 0; $instatus = $intype = $inauth = 0;
} elsif ($instatus) { } elsif ($instatus) {
if (/^\s+VIR_NET_(\w+)\s*=\s*(\d+),?$/) { if (/^\s+VIR_NET_(\w+)\s*=\s*(\d+),?$/) {
$status{$2} = lc $1; $status{$2} = lc $1;
} }
} elsif ($intype) { } elsif ($intype) {
if (/^\s+VIR_NET_(\w+)\s*=\s*(\d+),?$/) { if (/^\s+VIR_NET_(\w+)\s*=\s*(\d+),?$/) {
$type{$2} = lc $1; $type{$2} = lc $1;
} }
} elsif ($inauth) { } elsif ($inauth) {
if (/^\s+REMOTE_AUTH_(\w+)\s*=\s*(\d+),?$/) { if (/^\s+REMOTE_AUTH_(\w+)\s*=\s*(\d+),?$/) {
$auth{$2} = lc $1; $auth{$2} = lc $1;
} }
} else { } else {
if (/(\w+)_PROGRAM\s*=\s*0x([a-fA-F0-9]+)\s*;/) { if (/(\w+)_PROGRAM\s*=\s*0x([a-fA-F0-9]+)\s*;/) {
$funcs{lc $1} = { id => hex($2), version => undef, progs => [] }; $funcs{lc $1} = { id => hex($2), version => undef, progs => [] };
} elsif (/(\w+)_PROTOCOL_VERSION\s*=\s*(\d+)\s*;/) { } elsif (/(\w+)_PROTOCOL_VERSION\s*=\s*(\d+)\s*;/) {
$funcs{lc $1}->{version} = $2; $funcs{lc $1}->{version} = $2;
} elsif (/(\w+)_PROC_(.*?)\s+=\s+(\d+)/) { } elsif (/(\w+)_PROC_(.*?)\s+=\s+(\d+)/) {
$funcs{lc $1}->{progs}->[$3] = lc $2; $funcs{lc $1}->{progs}->[$3] = lc $2;
} }
} }
} }
...@@ -172,10 +172,10 @@ foreach my $prog (keys %funcs) { ...@@ -172,10 +172,10 @@ foreach my $prog (keys %funcs) {
my $pfirst = 1; my $pfirst = 1;
for (my $id = 1 ; $id <= $#{$funcs{$prog}->{progs}} ; $id++) { for (my $id = 1 ; $id <= $#{$funcs{$prog}->{progs}} ; $id++) {
my $cond = $pfirst ? "if" : "} else if"; my $cond = $pfirst ? "if" : "} else if";
$pfirst = 0; $pfirst = 0;
print " $cond (proc == $id) {\n"; print " $cond (proc == $id) {\n";
print " procstr = \"", $funcs{$prog}->{progs}->[$id], "\";\n"; print " procstr = \"", $funcs{$prog}->{progs}->[$id], "\";\n";
} }
print " } else {\n"; print " } else {\n";
print " procstr = \"unknown\";\n"; print " procstr = \"unknown\";\n";
......
...@@ -21,7 +21,7 @@ my %lines; ...@@ -21,7 +21,7 @@ my %lines;
foreach (@data) { foreach (@data) {
if (/^\s*TRACE:\s+(\S+?)(?:\(.*\))?\s+\[0x(.*)\]\s*$/ ) { if (/^\s*TRACE:\s+(\S+?)(?:\(.*\))?\s+\[0x(.*)\]\s*$/ ) {
$trace{$2} = $1; $trace{$2} = $1;
} }
} }
...@@ -34,8 +34,8 @@ foreach my $key (keys %trace) { ...@@ -34,8 +34,8 @@ foreach my $key (keys %trace) {
foreach (@data) { foreach (@data) {
if (/^\s*TRACE:\s+(\S+?)(?:\(.*\))?\s+\[0x(.*)\]\s*$/ ) { if (/^\s*TRACE:\s+(\S+?)(?:\(.*\))?\s+\[0x(.*)\]\s*$/ ) {
print $lines{$2}; print $lines{$2};
} else { } else {
print; print;
} }
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册