Skip to content

Commit b44f971

Browse files
committed
fix: remove result, always a float
1 parent 0b83481 commit b44f971

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

bottlecap/src/proc/mod.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,11 @@ fn get_fd_max_data_from_path(path: &str, pids: &[i64]) -> f64 {
244244
fd_max
245245
}
246246

247-
pub fn get_fd_use_data(pids: &[i64]) -> Result<f64, io::Error> {
247+
pub fn get_fd_use_data(pids: &[i64]) -> f64 {
248248
get_fd_use_data_from_path(PROC_PATH, pids)
249249
}
250250

251-
fn get_fd_use_data_from_path(path: &str, pids: &[i64]) -> Result<f64, io::Error> {
251+
fn get_fd_use_data_from_path(path: &str, pids: &[i64]) -> f64 {
252252
let mut fd_use = 0;
253253

254254
for &pid in pids {
@@ -265,7 +265,7 @@ fn get_fd_use_data_from_path(path: &str, pids: &[i64]) -> Result<f64, io::Error>
265265
fd_use += count;
266266
}
267267

268-
Ok(fd_use as f64)
268+
return fd_use as f64;
269269
}
270270

271271
#[must_use]
@@ -475,14 +475,8 @@ mod tests {
475475
fn test_get_fd_use_data() {
476476
let path = "./tests/proc/process/valid";
477477
let pids = get_pid_list_from_path(path_from_root(path).as_str());
478-
let fd_use_result = get_fd_use_data_from_path(path, &pids);
479-
assert!(fd_use_result.is_ok());
480-
let fd_use = fd_use_result.unwrap();
478+
let fd_use = get_fd_use_data_from_path(path, &pids);
481479
assert!((fd_use - 5.0).abs() < f64::EPSILON);
482-
483-
let path = "./tests/proc/process/invalid_missing";
484-
let fd_use_result = get_fd_use_data_from_path(path, &pids);
485-
assert!(fd_use_result.is_err());
486480
}
487481

488482
#[test]

0 commit comments

Comments
 (0)