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 2E0DD9D800 for ; Fri, 24 Nov 2023 10:14:28 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 04C29AD51 for ; Fri, 24 Nov 2023 10:13:58 +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) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Fri, 24 Nov 2023 10:13:56 +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 C3E3B43A94 for ; Fri, 24 Nov 2023 10:13:56 +0100 (CET) Message-ID: <021e8540-f9ca-4847-aab8-d4e010854478@proxmox.com> Date: Fri, 24 Nov 2023 10:13:55 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: Thomas Lamprecht , Proxmox Backup Server development discussion , Dietmar Maurer References: <20231123130935.207013-1-g.goller@proxmox.com> <20231123130935.207013-3-g.goller@proxmox.com> <1138109161.1109.1700756149397@webmail.proxmox.com> <35a714ee-4b61-4abb-bf2c-888aa774e692@proxmox.com> From: Gabriel Goller In-Reply-To: <35a714ee-4b61-4abb-bf2c-888aa774e692@proxmox.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.234 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy 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 T_SCC_BODY_TEXT_LINE -0.01 - Subject: Re: [pbs-devel] [PATCH proxmox-backup 2/2] node: status: declutter kernel-version 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: Fri, 24 Nov 2023 09:14:28 -0000 On 11/23/23 17:29, Thomas Lamprecht wrote: > Am 23/11/2023 um 17:15 schrieb Dietmar Maurer: >>> + let kversion = KernelVersionInformation { >>> + sysname: uname.sysname().to_os_string().into_string().unwrap(), >>> + release: uname.release().to_os_string().into_string().unwrap(), >>> + version: uname.version().to_os_string().into_string().unwrap(), >>> + machine: uname.machine().to_os_string().into_string().unwrap(), >>> + }; >> Is it really safe to use unwrap here? If so, I normally add a short >> comment to the code to explain why. >> > Yeah, I *really* dislike .unwrap() calls, especially if in common code, > i.e., not isolated into it's own function with a clear comment that > states why this never can fail, and IMO it can fail because those strings > are just bytes for the kernel and can be set on boot, so it might be > possible to set them to something that isn't valid unicode.. > > So, please use unwarp_or and maybe it would be better to move this to > an impl on the KernelVersionInformation struct, that could also host > a to_legacy() printing the old unwieldy string, as I'd not just switch > the old variable from string to object, that's an api break. Agree, I will use a `unwrap_or` and return an empty string. Didn't know backwards compat was a thing here, so I will also return the old property with the legacy string :)