[pbs-devel] [PATCH proxmox-backup v2 07/11] tools/systemd/time: fix selection for multiple options

Dietmar Maurer dietmar at proxmox.com
Fri Sep 4 15:38:19 CEST 2020


already applied, but I wonder if we have a test case for this?

> On 09/04/2020 2:33 PM Dominik Csapak <d.csapak at proxmox.com> wrote:
> 
>  
> if we give multiple options/ranges for a value, e.g.
> 2,4,8
> we always choose the biggest, instead of the smallest that is next
> 
> this happens because in DateTimeValue::find_next(value)
> 'next' can be set multiple times and we set it when the new
> value was *bigger* than the last found 'next' value, when in reality
> we have to choose the *smallest* next we can find
> 
> reverse the comparison operator to fix this
> 
> Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
> ---
>  src/tools/systemd/time.rs | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/tools/systemd/time.rs b/src/tools/systemd/time.rs
> index c8cc8468..69f5f5fb 100644
> --- a/src/tools/systemd/time.rs
> +++ b/src/tools/systemd/time.rs
> @@ -54,7 +54,7 @@ impl DateTimeValue {
>          let mut next: Option<u32> = None;
>          let mut set_next = |v: u32| {
>              if let Some(n) = next {
> -                if v > n { next = Some(v); }
> +                if v < n { next = Some(v); }
>              } else {
>                  next = Some(v);
>              }
> -- 
> 2.20.1
> 
> 
> 
> _______________________________________________
> pbs-devel mailing list
> pbs-devel at lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel





More information about the pbs-devel mailing list