Skip to content

Commit

Permalink
Raise MSRV to 1.69.0
Browse files Browse the repository at this point in the history
This allows us to use the very useful CStr::from_bytes_until_nul
  • Loading branch information
asomers committed Oct 1, 2023
1 parent 173bde1 commit 5fc7d92
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 20 deletions.
10 changes: 5 additions & 5 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ env:
RUSTFLAGS: -D warnings
RUSTDOCFLAGS: -D warnings
TOOL: cargo
MSRV: 1.65.0
MSRV: 1.69.0
ZFLAGS:

# Tests that don't require executing the build binaries
Expand Down Expand Up @@ -146,7 +146,7 @@ task:
matrix:
- name: Linux aarch64
arm_container:
image: rust:1.65.0
image: rust:1.69.0
cpu: 1
depends_on:
- FreeBSD 14 amd64 & i686
Expand All @@ -160,13 +160,13 @@ task:
TARGET: aarch64-unknown-linux-gnu
- name: Linux x86_64
container:
image: rust:1.65.0
image: rust:1.69.0
cpu: 1
env:
TARGET: x86_64-unknown-linux-gnu
- name: Linux x86_64 musl
container:
image: rust:1.65.0
image: rust:1.69.0
cpu: 1
depends_on:
- FreeBSD 14 amd64 & i686
Expand Down Expand Up @@ -199,7 +199,7 @@ task:
# Tasks for cross-compiling, but no testing
task:
container:
image: rust:1.65.0
image: rust:1.69.0
cpu: 1
depends_on:
- FreeBSD 14 amd64 & i686
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ This project adheres to [Semantic Versioning](https://semver.org/).

### Changed

- The MSRV is now 1.69
([#2144](https://github.com/nix-rust/nix/pull/2144))

- The following APIs now take an implementation of `AsFd` rather than a
`RawFd`:

Expand Down
9 changes: 1 addition & 8 deletions src/mount/bsd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,14 +396,7 @@ impl<'a> Nmount<'a> {
match Errno::result(res) {
Ok(_) => Ok(()),
Err(error) => {
let errmsg = match errmsg.iter().position(|&x| x == 0) {
None => None,
Some(0) => None,
Some(n) => {
let sl = &errmsg[0..n + 1];
Some(CStr::from_bytes_with_nul(sl).unwrap())
}
};
let errmsg = CStr::from_bytes_until_nul(&errmsg[..]).ok();
Err(NmountError::new(error, errmsg))
}
}
Expand Down
9 changes: 5 additions & 4 deletions src/sys/prctl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,11 @@ pub fn get_name() -> Result<CString> {

let res = unsafe { libc::prctl(libc::PR_GET_NAME, &buf, 0, 0, 0) };

let len = buf.iter().position(|&c| c == 0).unwrap_or(buf.len());
let name = CStr::from_bytes_with_nul(&buf[..=len]).map_err(|_| Errno::EINVAL)?;

Errno::result(res).map(|_| name.to_owned())
Errno::result(res).map(|_| {
CStr::from_bytes_until_nul(&buf)
.map(CStr::to_owned)
.map_err(|_| Errno::EINVAL)
}).flatten()
}

/// Sets the timer slack value for the calling thread. Timer slack is used by the kernel to group
Expand Down
6 changes: 3 additions & 3 deletions src/unistd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3928,9 +3928,9 @@ pub fn ttyname<F: AsFd>(fd: F) -> Result<PathBuf> {
return Err(Errno::from_i32(ret));
}

let nul = buf.iter().position(|c| *c == b'\0').unwrap();
buf.truncate(nul);
Ok(OsString::from_vec(buf).into())
CStr::from_bytes_until_nul(&buf[..])
.map(|s| OsStr::from_bytes(s.to_bytes()).into())
.map_err(|_| Errno::EINVAL)
}
}

Expand Down

0 comments on commit 5fc7d92

Please sign in to comment.