From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 6ADFE71244 for ; Wed, 8 Sep 2021 13:27:26 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 620AA257A8 for ; Wed, 8 Sep 2021 13:26:56 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id BDB602579A for ; Wed, 8 Sep 2021 13:26:55 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 7CC3F4462A for ; Wed, 8 Sep 2021 13:26:55 +0200 (CEST) From: Fabian Ebner To: pve-devel@lists.proxmox.com Date: Wed, 8 Sep 2021 13:26:50 +0200 Message-Id: <20210908112651.126237-1-f.ebner@proxmox.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.130 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URI_NOVOWEL 0.5 URI hostname has long non-vowel sequence Subject: [pve-devel] [PATCH storage 1/2] btrfs: avoid undef warnings with format X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Sep 2021 11:27:26 -0000 which is only set by parse_volname when the volume is a VM or container image, but not for other content types. Signed-off-by: Fabian Ebner --- PVE/Storage/BTRFSPlugin.pm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/PVE/Storage/BTRFSPlugin.pm b/PVE/Storage/BTRFSPlugin.pm index fe42082..a1e5b98 100644 --- a/PVE/Storage/BTRFSPlugin.pm +++ b/PVE/Storage/BTRFSPlugin.pm @@ -180,13 +180,13 @@ sub filesystem_path { $path .= "/$vmid" if $vtype eq 'images'; - if ($format eq 'raw') { + if (defined($format) && $format eq 'raw') { my $dir = raw_name_to_dir($name); if ($snapname) { $dir .= "\@$snapname"; } $path .= "/$dir/disk.raw"; - } elsif ($format eq 'subvol') { + } elsif (defined($format) && $format eq 'subvol') { $path .= "/$name"; if ($snapname) { $path .= "\@$snapname"; @@ -409,7 +409,7 @@ sub free_image { my (undef, undef, $vmid, undef, undef, undef, $format) = $class->parse_volname($volname); - if ($format ne 'subvol' && $format ne 'raw') { + if (!defined($format) || ($format ne 'subvol' && $format ne 'raw')) { return PVE::Storage::DirPlugin->free_image($storeid, $scfg, $volname, $isBase, $_format); } @@ -465,7 +465,7 @@ sub volume_size_info { my $format = ($class->parse_volname($volname))[6]; - if ($format eq 'subvol') { + if (defined($format) && $format eq 'subvol') { my $ctime = (stat($path))[10]; my ($used, $size) = (0, 0); #my ($used, $size) = btrfs_subvol_quota($class, $path); # uses wantarray -- 2.30.2