From bc12c9c088e1c615a290228cff7ca3be8659cfb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= Date: Wed, 26 Jun 2024 10:56:17 +0200 Subject: [PATCH] style: remove goto statements MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Fiona Ebner --- src/PVE/Storage/Plugin.pm | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/PVE/Storage/Plugin.pm b/src/PVE/Storage/Plugin.pm index b5a54c1..b85d935 100644 --- a/src/PVE/Storage/Plugin.pm +++ b/src/PVE/Storage/Plugin.pm @@ -1586,13 +1586,14 @@ sub read_common_header($) { # Export a volume into a file handle as a stream of desired format. sub volume_export { 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)) { - my $file = $class->path($scfg, $volname, $storeid) - or goto unsupported; + my $file = $class->path($scfg, $volname, $storeid) or die $err_msg; my ($size, $file_format) = file_size_info($file); 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); if ($file_format eq 'raw') { run_command(['dd', "if=$file", "bs=4k", "status=progress"], output => '>&'.fileno($fh)); @@ -1603,20 +1604,19 @@ sub volume_export { return; } elsif ($format =~ /^(qcow2|vmdk)\+size$/) { 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); run_command(['dd', "if=$file", "bs=4k", "status=progress"], output => '>&'.fileno($fh)); return; } 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); run_command(['tar', @COMMON_TAR_FLAGS, '-cf', '-', '-C', $file, '.'], output => '>&'.fileno($fh)); return; } } - unsupported: - die "volume export format $format not available for $class"; + die $err_msg; } sub volume_export_formats {