Skip to content

Commit 245d648

Browse files
Fix more warnings on linux
1 parent 70b4496 commit 245d648

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/libproc/proc_pid.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -415,8 +415,7 @@ fn procfile_field(filename: &str, fieldname: &str) -> Result<String, String> {
415415
let lineheader = format!("{}{}", fieldname, SEPARATOR);
416416

417417
// Open the file in read-only mode (ignoring errors).
418-
let file = File::open(filename)
419-
.expect(&format!("Could not open /proc file '{}'", filename));
418+
let file = File::open(filename).unwrap_or_else(|_| panic!("Could not open /proc file '{}'", filename));
420419
let reader = BufReader::new(file);
421420

422421
// Read the file line by line using the lines() iterator from std::io::BufRead.
@@ -428,7 +427,7 @@ fn procfile_field(filename: &str, fieldname: &str) -> Result<String, String> {
428427
}
429428
}
430429

431-
Err(format!("Could not find the field named '{}' in the /proc FS file name '{}'", fieldname, filename).to_owned())
430+
Err(format!("Could not find the field named '{}' in the /proc FS file name '{}'", fieldname, filename) )
432431
}
433432

434433
#[cfg(target_os = "linux")]

0 commit comments

Comments
 (0)