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 AA380C5F6 for ; Tue, 29 Nov 2022 13:03:34 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 8C3A37A2D for ; Tue, 29 Nov 2022 13:03:34 +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, 29 Nov 2022 13:03:33 +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 B86BA43C8B for ; Tue, 29 Nov 2022 13:03:33 +0100 (CET) Message-ID: <905b8db3-60a7-1746-bf66-597096a706b8@proxmox.com> Date: Tue, 29 Nov 2022 13:03:32 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:108.0) Gecko/20100101 Thunderbird/108.0 Content-Language: en-GB To: Proxmox Backup Server development discussion , Dominik Csapak References: <20221129105127.1969525-1-d.csapak@proxmox.com> From: Thomas Lamprecht In-Reply-To: <20221129105127.1969525-1-d.csapak@proxmox.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.099 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.257 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. [drive.rs, inventory.rs, media.rs] Subject: Re: [pbs-devel] [PATCH proxmox-backup 1/2] tape: refactor uuid of empty media set into constant X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Nov 2022 12:03:34 -0000 Am 29/11/2022 um 11:51 schrieb Dominik Csapak: > so that we have a easily recognizable name for it and can see > instantly what it does > > make the 'let is_empty' unnecessary as it's clear now what the check is > > Signed-off-by: Dominik Csapak > --- > src/api2/tape/drive.rs | 8 ++++---- > src/api2/tape/media.rs | 5 ++--- > src/tape/inventory.rs | 16 +++++++++------- > src/tape/media_pool.rs | 4 ++-- > 4 files changed, 17 insertions(+), 16 deletions(-) > > diff --git a/src/api2/tape/drive.rs b/src/api2/tape/drive.rs > index 107bcfd8..4bb9ade9 100644 > --- a/src/api2/tape/drive.rs > +++ b/src/api2/tape/drive.rs > @@ -42,7 +42,7 @@ use crate::{ > }, > file_formats::{MediaLabel, MediaSetLabel}, > lock_media_pool, lock_media_set, lock_unassigned_media_pool, Inventory, MediaCatalog, > - MediaId, TAPE_STATUS_DIR, > + MediaId, EMPTY_MEDIA_SET_UUID, TAPE_STATUS_DIR, > }, > }; > > @@ -528,7 +528,7 @@ fn write_media_label( > label.label_text, > pool > ); > - let set = MediaSetLabel::with_data(pool, [0u8; 16].into(), 0, label.ctime, None); > + let set = MediaSetLabel::with_data(pool, EMPTY_MEDIA_SET_UUID.into(), 0, label.ctime, None); > > drive.write_media_set_label(&set, None)?; > > @@ -575,7 +575,7 @@ fn write_media_label( > if let Some(ref pool) = pool { > match info.media_set_label { > Some(set) => { > - if set.uuid != [0u8; 16].into() { > + if set.uuid != EMPTY_MEDIA_SET_UUID.into() { Did not looked to closely, but why not impl a method on MediaSetLabel instead, avoiding leaking out of that internal detail in the first place?