aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott Lawrence <scott+git@ineffectivetheory.com>2024-11-28 11:56:49 -0700
committerScott Lawrence <scott+git@ineffectivetheory.com>2024-11-28 11:56:49 -0700
commit391862c82d331ee25a8e520d7c4ef0fe370b3819 (patch)
tree70a618984bc25c2cf629ae29af8dd5be97167bdd
parent027cd739765ba7bde027c32df2e2246314df9e88 (diff)
downloadvaranus-391862c82d331ee25a8e520d7c4ef0fe370b3819.tar.gz
varanus-391862c82d331ee25a8e520d7c4ef0fe370b3819.tar.bz2
varanus-391862c82d331ee25a8e520d7c4ef0fe370b3819.zip
Potential crash-bug fixed
-rw-r--r--src/main.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs
index 2a72d18..11662e7 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -286,7 +286,7 @@ fn human(k: u64) -> String {
let mut x: f64 = k as f64;
let mut i = 0;
let cs = ["", "K", "M", "G", "T", "P"];
- while x >= 1000. && i < cs.len() {
+ while x >= 1000. && i < cs.len()-1 {
x /= 1000.;
i += 1;
}
@@ -295,11 +295,11 @@ fn human(k: u64) -> String {
}
fn display_power(state: &State) {
+ let pow = &state.power;
}
fn display_memory(state: &State) {
let mem = &state.memory;
- let fs = human(mem.free);
let us = human(mem.total - mem.free);
let ts = human(mem.total);
let per = 100. * (mem.total - mem.free) as f64 / mem.total as f64;