From: Wolfgang Bumiller <w.bumiller@proxmox.com>
To: Dominik Csapak <d.csapak@proxmox.com>
Cc: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] applied: [PATCH proxmox-backup] rrd: use saturating_sub to avoid underflow
Date: Thu, 28 Oct 2021 12:56:45 +0200 [thread overview]
Message-ID: <20211028105645.7uefb73mu4cq374k@olga.proxmox.com> (raw)
In-Reply-To: <20211028094044.2905513-1-d.csapak@proxmox.com>
applied
On Thu, Oct 28, 2021 at 11:40:44AM +0200, Dominik Csapak wrote:
> Without this, the tests fail in debug mode.
> Also having start (u64) underflow to a value greater than end does
> not really make sense
>
> Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
> ---
> proxmox-rrd/src/rrd.rs | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/proxmox-rrd/src/rrd.rs b/proxmox-rrd/src/rrd.rs
> index 20bf6ae3..2fab9df3 100644
> --- a/proxmox-rrd/src/rrd.rs
> +++ b/proxmox-rrd/src/rrd.rs
> @@ -469,7 +469,7 @@ impl RRD {
> match rra {
> Some(rra) => {
> let end = end.unwrap_or_else(|| proxmox_time::epoch_f64() as u64);
> - let start = start.unwrap_or(end - 10*rra.resolution);
> + let start = start.unwrap_or(end.saturating_sub(10*rra.resolution));
> Ok(rra.extract_data(start, end, self.source.last_update))
> }
> None => bail!("unable to find RRA suitable ({:?}:{})", cf, resolution),
> --
> 2.30.2
prev parent reply other threads:[~2021-10-28 10:57 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-28 9:40 [pbs-devel] " Dominik Csapak
2021-10-28 10:56 ` Wolfgang Bumiller [this message]
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=20211028105645.7uefb73mu4cq374k@olga.proxmox.com \
--to=w.bumiller@proxmox.com \
--cc=d.csapak@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