[Tools 1/2] winetest: Standardize handling of winetest.cgi's arguments and add prototypes.
Francois Gouget
fgouget at codeweavers.com
Fri Jul 25 03:20:00 CDT 2014
The prototypes let Perl detect when the wrong number of parameters is passed to these functions.
---
Note that test_reportfile() did not actually use the parameter it was
given. move_file() does though it could just as well use the global
$name variable given its current usage. But just in case we find other
uses for it later on I kept the parameter.
winetest/winetest.cgi | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/winetest/winetest.cgi b/winetest/winetest.cgi
index 2cc1190..2daf5cc 100755
--- a/winetest/winetest.cgi
+++ b/winetest/winetest.cgi
@@ -33,7 +33,8 @@ $CGI::POST_MAX = $maxfilesize + 1024;
my $name = param ("reportfile");
my $error = cgi_error ();
-sub test_reportfile {
+sub test_reportfile()
+{
my $buffer;
my $fh = upload "reportfile";
read $fh, $buffer, 1024;
@@ -41,15 +42,17 @@ sub test_reportfile {
return $1;
}
-sub move_file {
- my $orig = tmpFileName (shift);
+sub move_file($)
+{
+ my ($filename) = @_;
+ my $orig = tmpFileName($filename);
my $tmpdir = tempdir ("repXXXXX", DIR=>$ENV{TMPDIR});
chmod 0777, $tmpdir;
chmod 0666&~umask, $orig;
my $size = -s $orig;
(rename $orig, "$tmpdir/report")?
- "Received $name ($size bytes).\n":
- "Error: can't store $name: $!\n";
+ "Received $filename ($size bytes).\n":
+ "Error: can't store $filename: $!\n";
}
# Invoked by winetest
@@ -59,13 +62,13 @@ if (user_agent ("Winetest Shell")) {
if ($error) {
print "Error: $error\n";
} elsif ($name) {
- my $build = test_reportfile $name;
+ my $build = test_reportfile();
if (!defined $build) {
print "Error: submission corrupted";
} elsif ($build eq "-") {
print "Error: build ID unset";
} else {
- print move_file $name;
+ print move_file($name);
}
} else {
print "Error: empty request\n";
@@ -90,13 +93,13 @@ if ($error) {
print h2 ("Error during file upload ($name)"),
strong ($error);
} elsif ($name) {
- my $build = test_reportfile $name;
+ my $build = test_reportfile();
if (!defined $build) {
print h2 ("Error: submission corrupted");
} elsif ($build eq "-") {
print h2 ("Error: build ID unset");
} else {
- print h2 (move_file $name);
+ print h2 (move_file($name));
}
}
print end_html;
--
2.0.1
More information about the wine-patches
mailing list