[pbs-devel] applied: [PATCH proxmox-backup] rrd: use saturating_sub to avoid underflow
Wolfgang Bumiller
w.bumiller at proxmox.com
Thu Oct 28 12:56:45 CEST 2021
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 at 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
More information about the pbs-devel
mailing list