summaryrefslogtreecommitdiff
path: root/tests/gpt-header-munge
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2011-11-11 09:50:51 +0100
committerJim Meyering <meyering@redhat.com>2011-11-11 09:50:51 +0100
commiteec497c07caaff5ef297f75ee87f5dff88cacd27 (patch)
tree29450bbab47b161b4058d57045705b7d445172de /tests/gpt-header-munge
parentc52cf0b120b0767009dd13be1e90dd12b4198641 (diff)
downloadparted-eec497c07caaff5ef297f75ee87f5dff88cacd27.tar.gz
maint: a little defensive programming in a test script
* tests/gpt-header-munge: Use "local *F;" to limit scope of file handles.
Diffstat (limited to 'tests/gpt-header-munge')
-rwxr-xr-xtests/gpt-header-munge3
1 files changed, 2 insertions, 1 deletions
diff --git a/tests/gpt-header-munge b/tests/gpt-header-munge
index 9b869dd..e7d3d43 100755
--- a/tests/gpt-header-munge
+++ b/tests/gpt-header-munge
@@ -64,6 +64,7 @@ sub partition_array_start_offset ($$)
sub partition_array_crc ($$$)
{
my ($pri_or_backup, $n_pe, $in) = @_;
+ local *F;
open F, '<', $in
or die "$ME: failed to open $in: $!\n";
@@ -78,7 +79,6 @@ sub partition_array_crc ($$$)
my $n = $n_pe * $pe_size;
($p = sysread F, $pe_buf, $n) && $p == $n
or die "$ME: $in: failed to read $pri_or_backup partition array:($p:$n) $!\n";
- close F;
return crc32 $pe_buf;
}
@@ -220,6 +220,7 @@ EOF
or (warn "$ME: no file specified\n"), usage 1;
my $in = $ARGV[0];
+ local *F;
open F, '<', $in
or die "$ME: failed to open $in: $!\n";