]> git.proxmox.com Git - proxmox.git/commitdiff
clippy: collapse/rework nested ifs
authorFabian Grünbichler <f.gruenbichler@proxmox.com>
Fri, 15 Jan 2021 13:10:24 +0000 (14:10 +0100)
committerFabian Grünbichler <f.gruenbichler@proxmox.com>
Wed, 20 Jan 2021 15:22:59 +0000 (16:22 +0100)
no semantic changes (intended).

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
src/rrd/rrd.rs

index c8b164719e75cd8456896247b20350766d87901d..37bdf3b94c42937745eb3a61b3b3c8cd76186bc4 100644 (file)
@@ -128,25 +128,20 @@ impl RRA {
         // derive counter value
         if self.flags.intersects(RRAFlags::DST_DERIVE | RRAFlags::DST_COUNTER) {
             let time_diff = time - self.last_update;
+            let is_counter = self.flags.contains(RRAFlags::DST_COUNTER);
+
             let diff = if self.counter_value.is_nan() {
                 0.0
+            } else if is_counter && value < 0.0 {
+                eprintln!("rrdb update failed - got negative value for counter");
+                return;
+            } else if is_counter && value < self.counter_value {
+                // Note: We do not try automatic overflow corrections
+                self.counter_value = value;
+                eprintln!("rrdb update failed - conter overflow/reset detected");
+                return;
             } else {
-                if self.flags.contains(RRAFlags::DST_COUNTER) { // check for overflow
-                    if value < 0.0 {
-                        eprintln!("rrdb update failed - got negative value for counter");
-                        return;
-                    }
-                    // Note: We do not try automatic overflow corrections
-                    if value < self.counter_value { // overflow or counter reset
-                        self.counter_value = value;
-                        eprintln!("rrdb update failed - conter overflow/reset detected");
-                        return;
-                    } else {
-                        value - self.counter_value
-                    }
-                } else {
-                    value - self.counter_value
-                }
+                value - self.counter_value
             };
             self.counter_value = value;
             value = diff/time_diff;