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 25F258D712 for ; Tue, 8 Nov 2022 18:10:12 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 05F87AA19 for ; Tue, 8 Nov 2022 18:09:42 +0100 (CET) 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 for ; Tue, 8 Nov 2022 18:09:41 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 3AA9042E32 for ; Tue, 8 Nov 2022 18:09:41 +0100 (CET) Message-ID: <7e8a5b3e-e33c-f029-130e-c3de1153043e@proxmox.com> Date: Tue, 8 Nov 2022 18:09:40 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:107.0) Gecko/20100101 Thunderbird/107.0 Content-Language: en-GB To: Proxmox VE development discussion , Stefan Hrdlicka References: <20220912152507.3498492-1-s.hrdlicka@proxmox.com> <20220912152507.3498492-2-s.hrdlicka@proxmox.com> From: Thomas Lamprecht In-Reply-To: <20220912152507.3498492-2-s.hrdlicka@proxmox.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.033 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 NICE_REPLY_A -0.001 Looks like a legit reply (A) SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [storage.pm] Subject: Re: [pve-devel] [PATCH V2 pve-storage 1/8] add a storage_exists function 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: Tue, 08 Nov 2022 17:10:12 -0000 Am 12/09/2022 um 17:25 schrieb Stefan Hrdlicka: > adds a function that can take a volume id and return the relevant > storage config > > Signed-off-by: Stefan Hrdlicka > --- > PVE/Storage.pm | 9 +++++++++ > 1 file changed, 9 insertions(+) > > diff --git a/PVE/Storage.pm b/PVE/Storage.pm > index b9c53a1..9e95e3d 100755 > --- a/PVE/Storage.pm > +++ b/PVE/Storage.pm > @@ -158,6 +158,15 @@ my $convert_maxfiles_to_prune_backups = sub { > } > }; > > +sub storage_exists { slightly odd interface name IMO, as it's a bit more of a "get storage config from volid", so adapt the method name in that direction, e.g.: # extract the storage ID from a volume ID and returns it config or undef if storage could not be # found (i.e., got removed) sub storage_config_from_volid { > + my ($cfg, $volid) = @_; > + > + my ($storeid, $volname) = parse_volume_id($volid); > + my $scfg = storage_config($cfg, $storeid, 1); > + > + return $scfg; couldn't we avoid the useless intermediate variable and directly return storage_config($cfg, $storeid, 1); At which point the question arises if we really want a common helper "just" for this, no hard feelings against, but is IMO a bit close to thinking that not much would be lost in terms of code beauty or maintenance if we'd just program those two lines out on the few call sites. > +} > + > sub storage_config { > my ($cfg, $storeid, $noerr) = @_; >