Skip to content

Commit

Permalink
Merge pull request #43 from wezm/num-threads-freebsd
Browse files Browse the repository at this point in the history
Fix build on FreeBSD after refactor
  • Loading branch information
Byron committed Jan 22, 2022
2 parents 3c153ae + f3d31e5 commit 8f10c85
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/freedesktop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -678,13 +678,11 @@ fn get_mount_points() -> Result<Vec<MountPoint>, Error> {
fn get_mount_points() -> Result<Vec<MountPoint>, Error> {
// Avoid potential UB with mount points changing and another thread calling `getmntinfo()`
// after we have called it.
if !num_threads::is_single_threaded() {
if !num_threads::is_single_threaded().unwrap_or(false) {
return Ok(Vec::new());
}
fn c_buf_to_str(buf: &[libc::c_char]) -> Option<&str> {
let buf: &[u8] = unsafe {
std::slice::from_raw_parts(buf.as_ptr() as _, buf.len());
};
let buf: &[u8] = unsafe { std::slice::from_raw_parts(buf.as_ptr() as _, buf.len()) };
if let Some(pos) = buf.iter().position(|x| *x == 0) {
// Shrink buffer to omit the null bytes
std::str::from_utf8(&buf[..pos]).ok()
Expand Down

0 comments on commit 8f10c85

Please sign in to comment.