style: remove goto statements
these can just as well be `die` statements right there, there is no complicated cleanup that would warrant a goto statement.. Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com> Reviewed-by: Fiona Ebner <f.ebner@proxmox.com>
This commit is contained in:
@ -1586,13 +1586,14 @@ sub read_common_header($) {
|
|||||||
# Export a volume into a file handle as a stream of desired format.
|
# Export a volume into a file handle as a stream of desired format.
|
||||||
sub volume_export {
|
sub volume_export {
|
||||||
my ($class, $scfg, $storeid, $fh, $volname, $format, $snapshot, $base_snapshot, $with_snapshots) = @_;
|
my ($class, $scfg, $storeid, $fh, $volname, $format, $snapshot, $base_snapshot, $with_snapshots) = @_;
|
||||||
|
|
||||||
|
my $err_msg = "volume export format $format not available for $class\n";
|
||||||
if ($scfg->{path} && !defined($snapshot) && !defined($base_snapshot)) {
|
if ($scfg->{path} && !defined($snapshot) && !defined($base_snapshot)) {
|
||||||
my $file = $class->path($scfg, $volname, $storeid)
|
my $file = $class->path($scfg, $volname, $storeid) or die $err_msg;
|
||||||
or goto unsupported;
|
|
||||||
my ($size, $file_format) = file_size_info($file);
|
my ($size, $file_format) = file_size_info($file);
|
||||||
|
|
||||||
if ($format eq 'raw+size') {
|
if ($format eq 'raw+size') {
|
||||||
goto unsupported if $with_snapshots || $file_format eq 'subvol';
|
die $err_msg if $with_snapshots || $file_format eq 'subvol';
|
||||||
write_common_header($fh, $size);
|
write_common_header($fh, $size);
|
||||||
if ($file_format eq 'raw') {
|
if ($file_format eq 'raw') {
|
||||||
run_command(['dd', "if=$file", "bs=4k", "status=progress"], output => '>&'.fileno($fh));
|
run_command(['dd', "if=$file", "bs=4k", "status=progress"], output => '>&'.fileno($fh));
|
||||||
@ -1603,20 +1604,19 @@ sub volume_export {
|
|||||||
return;
|
return;
|
||||||
} elsif ($format =~ /^(qcow2|vmdk)\+size$/) {
|
} elsif ($format =~ /^(qcow2|vmdk)\+size$/) {
|
||||||
my $data_format = $1;
|
my $data_format = $1;
|
||||||
goto unsupported if !$with_snapshots || $file_format ne $data_format;
|
die $err_msg if !$with_snapshots || $file_format ne $data_format;
|
||||||
write_common_header($fh, $size);
|
write_common_header($fh, $size);
|
||||||
run_command(['dd', "if=$file", "bs=4k", "status=progress"], output => '>&'.fileno($fh));
|
run_command(['dd', "if=$file", "bs=4k", "status=progress"], output => '>&'.fileno($fh));
|
||||||
return;
|
return;
|
||||||
} elsif ($format eq 'tar+size') {
|
} elsif ($format eq 'tar+size') {
|
||||||
goto unsupported if $file_format ne 'subvol';
|
die $err_msg if $file_format ne 'subvol';
|
||||||
write_common_header($fh, $size);
|
write_common_header($fh, $size);
|
||||||
run_command(['tar', @COMMON_TAR_FLAGS, '-cf', '-', '-C', $file, '.'],
|
run_command(['tar', @COMMON_TAR_FLAGS, '-cf', '-', '-C', $file, '.'],
|
||||||
output => '>&'.fileno($fh));
|
output => '>&'.fileno($fh));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unsupported:
|
die $err_msg;
|
||||||
die "volume export format $format not available for $class";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub volume_export_formats {
|
sub volume_export_formats {
|
||||||
|
|||||||
Reference in New Issue
Block a user