public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Thomas Lamprecht <t.lamprecht@proxmox.com>
To: Proxmox Backup Server development discussion
	<pbs-devel@lists.proxmox.com>,
	Dietmar Maurer <dietmar@proxmox.com>,
	Gabriel Goller <g.goller@proxmox.com>
Subject: Re: [pbs-devel] [PATCH proxmox-backup 2/2] node: status: declutter kernel-version
Date: Thu, 23 Nov 2023 17:29:09 +0100	[thread overview]
Message-ID: <35a714ee-4b61-4abb-bf2c-888aa774e692@proxmox.com> (raw)
In-Reply-To: <1138109161.1109.1700756149397@webmail.proxmox.com>

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.




  reply	other threads:[~2023-11-23 16:29 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 [this message]
2023-11-23 16:35       ` Thomas Lamprecht
2023-11-24  9:13       ` Gabriel Goller
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=35a714ee-4b61-4abb-bf2c-888aa774e692@proxmox.com \
    --to=t.lamprecht@proxmox.com \
    --cc=dietmar@proxmox.com \
    --cc=g.goller@proxmox.com \
    --cc=pbs-devel@lists.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal