Skip to content

Commit 913dbae

Browse files
committed
Raise MSRV to 1.69.0
This allows us to use the very useful CStr::from_bytes_until_nul
1 parent 173bde1 commit 913dbae

File tree

5 files changed

+17
-20
lines changed

5 files changed

+17
-20
lines changed

.cirrus.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ env:
99
RUSTFLAGS: -D warnings
1010
RUSTDOCFLAGS: -D warnings
1111
TOOL: cargo
12-
MSRV: 1.65.0
12+
MSRV: 1.69.0
1313
ZFLAGS:
1414

1515
# Tests that don't require executing the build binaries
@@ -146,7 +146,7 @@ task:
146146
matrix:
147147
- name: Linux aarch64
148148
arm_container:
149-
image: rust:1.65.0
149+
image: rust:1.69.0
150150
cpu: 1
151151
depends_on:
152152
- FreeBSD 14 amd64 & i686
@@ -160,13 +160,13 @@ task:
160160
TARGET: aarch64-unknown-linux-gnu
161161
- name: Linux x86_64
162162
container:
163-
image: rust:1.65.0
163+
image: rust:1.69.0
164164
cpu: 1
165165
env:
166166
TARGET: x86_64-unknown-linux-gnu
167167
- name: Linux x86_64 musl
168168
container:
169-
image: rust:1.65.0
169+
image: rust:1.69.0
170170
cpu: 1
171171
depends_on:
172172
- FreeBSD 14 amd64 & i686
@@ -199,7 +199,7 @@ task:
199199
# Tasks for cross-compiling, but no testing
200200
task:
201201
container:
202-
image: rust:1.65.0
202+
image: rust:1.69.0
203203
cpu: 1
204204
depends_on:
205205
- FreeBSD 14 amd64 & i686

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ This project adheres to [Semantic Versioning](https://semver.org/).
1414

1515
### Changed
1616

17+
- The MSRV is now 1.69
18+
([#TODO](https://github.com/nix-rust/nix/pull/TODO))
19+
1720
- The following APIs now take an implementation of `AsFd` rather than a
1821
`RawFd`:
1922

src/mount/bsd.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -396,14 +396,7 @@ impl<'a> Nmount<'a> {
396396
match Errno::result(res) {
397397
Ok(_) => Ok(()),
398398
Err(error) => {
399-
let errmsg = match errmsg.iter().position(|&x| x == 0) {
400-
None => None,
401-
Some(0) => None,
402-
Some(n) => {
403-
let sl = &errmsg[0..n + 1];
404-
Some(CStr::from_bytes_with_nul(sl).unwrap())
405-
}
406-
};
399+
let errmsg = CStr::from_bytes_until_nul(&errmsg[..]).ok();
407400
Err(NmountError::new(error, errmsg))
408401
}
409402
}

src/sys/prctl.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,11 @@ pub fn get_name() -> Result<CString> {
151151

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

154-
let len = buf.iter().position(|&c| c == 0).unwrap_or(buf.len());
155-
let name = CStr::from_bytes_with_nul(&buf[..=len]).map_err(|_| Errno::EINVAL)?;
156-
157-
Errno::result(res).map(|_| name.to_owned())
154+
Errno::result(res).map(|_| {
155+
CStr::from_bytes_until_nul(&buf)
156+
.map(CStr::to_owned)
157+
.map_err(|_| Errno::EINVAL)
158+
}).flatten()
158159
}
159160

160161
/// Sets the timer slack value for the calling thread. Timer slack is used by the kernel to group

src/unistd.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3928,9 +3928,9 @@ pub fn ttyname<F: AsFd>(fd: F) -> Result<PathBuf> {
39283928
return Err(Errno::from_i32(ret));
39293929
}
39303930

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

0 commit comments

Comments
 (0)