Skip to content

Commit

Permalink
Stop open-coding read_to_string
Browse files Browse the repository at this point in the history
  • Loading branch information
workingjubilee committed Jul 6, 2023
1 parent 9df8ebb commit 3ad33ff
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions src/symbolize/gimli/parse_running_mmaps_unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// in `mod libs_dl_iterate_phdr` (e.g. linux, freebsd, ...); it may be more
// general purpose, but it hasn't been tested elsewhere.

use super::mystd::fs::File;
use super::mystd::fs::{self, File};
use super::mystd::io::Read;
use super::mystd::str::FromStr;
use super::{OsString, String, Vec};
Expand Down Expand Up @@ -54,18 +54,9 @@ pub(super) struct MapsEntry {
}

pub(super) fn parse_maps() -> Result<Vec<MapsEntry>, &'static str> {
let mut v = Vec::new();
let mut proc_self_maps =
File::open("/proc/self/maps").map_err(|_| "Couldn't open /proc/self/maps")?;
let mut buf = String::new();
let _bytes_read = proc_self_maps
.read_to_string(&mut buf)
.map_err(|_| "Couldn't read /proc/self/maps")?;
for line in buf.lines() {
v.push(line.parse()?);
}
let buf = fs::read_to_string("/proc/self/maps").map_err(|_| "")?;

Ok(v)
buf.lines().map(|line| line.parse()).collect()
}

impl MapsEntry {
Expand Down

0 comments on commit 3ad33ff

Please sign in to comment.