all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Gabriel Goller <g.goller@proxmox.com>
To: Thomas Lamprecht <t.lamprecht@proxmox.com>,
	Proxmox Backup Server development discussion
	<pbs-devel@lists.proxmox.com>,
	Dietmar Maurer <dietmar@proxmox.com>
Subject: Re: [pbs-devel] [PATCH proxmox-backup 2/2] node: status: declutter kernel-version
Date: Fri, 24 Nov 2023 10:13:55 +0100	[thread overview]
Message-ID: <021e8540-f9ca-4847-aab8-d4e010854478@proxmox.com> (raw)
In-Reply-To: <35a714ee-4b61-4abb-bf2c-888aa774e692@proxmox.com>

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 :)




  parent reply	other threads:[~2023-11-24  9:14 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-23 13:09 [pbs-devel] [PATCH proxmox-backup 0/2] Add bootmode, improve kernel version Gabriel Goller
2023-11-23 13:09 ` [pbs-devel] [PATCH proxmox-backup 1/2] node: status: added bootmode Gabriel Goller
2023-11-23 16:32   ` Thomas Lamprecht
2023-11-24  9:04     ` Gabriel Goller
2023-11-24  9:11       ` Thomas Lamprecht
2023-11-23 13:09 ` [pbs-devel] [PATCH proxmox-backup 2/2] node: status: declutter kernel-version Gabriel Goller
2023-11-23 16:15   ` Dietmar Maurer
2023-11-23 16:29     ` Thomas Lamprecht
2023-11-23 16:35       ` Thomas Lamprecht
2023-11-24  9:13       ` Gabriel Goller [this message]
2023-11-23 16:28   ` Thomas Lamprecht
2023-11-24 12:02 ` [pbs-devel] [PATCH proxmox-backup 0/2] Add bootmode, improve kernel version Gabriel Goller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=021e8540-f9ca-4847-aab8-d4e010854478@proxmox.com \
    --to=g.goller@proxmox.com \
    --cc=dietmar@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    --cc=t.lamprecht@proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal