Skip to content

Commit cd8644d

Browse files
authored
Merge pull request #840 from memorysafety/fix-clippy
Fix clippy diagnostics
2 parents ebd3e60 + 266d07c commit cd8644d

File tree

5 files changed

+14
-7
lines changed

5 files changed

+14
-7
lines changed

src/exec/use_pty/pipe/ring_buffer.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ impl RingBuffer {
2525
self.len == self.storage.len()
2626
}
2727

28+
// rustc 1.77.1 clippy gives false diagnostics, https://github.com/rust-lang/rust-clippy/issues/12519
29+
#[allow(clippy::unused_io_amount)]
2830
pub(super) fn insert<R: Read>(&mut self, read: &mut R) -> io::Result<usize> {
2931
let inserted_len = if self.is_empty() {
3032
// Case 1.1. The buffer is empty, meaning that there are two unfilled slices in
@@ -61,6 +63,8 @@ impl RingBuffer {
6163
self.len == 0
6264
}
6365

66+
// rustc 1.77.1 clippy gives false diagnostics, https://github.com/rust-lang/rust-clippy/issues/12519
67+
#[allow(clippy::unused_io_amount)]
6468
pub(super) fn remove<W: Write>(&mut self, write: &mut W) -> io::Result<usize> {
6569
let removed_len = if self.is_full() {
6670
// Case 2.1. The buffer is full, meaning that there are two filled slices in `storage`:

src/su/cli.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ impl SuAction {
2222
}
2323

2424
#[cfg(test)]
25+
#[allow(clippy::result_large_err)]
2526
pub fn try_into_run(self) -> Result<SuRunOptions, Self> {
2627
if let Self::Run(v) = self {
2728
Ok(v)

src/sudo/cli/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ impl SudoAction {
8080
}
8181

8282
#[cfg(test)]
83+
#[allow(clippy::result_large_err)]
8384
pub fn try_into_run(self) -> Result<SudoRunOptions, Self> {
8485
if let Self::Run(v) = self {
8586
Ok(v)

src/system/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,13 @@ pub fn escape_os_str_lossy(s: &std::ffi::OsStr) -> String {
672672
s.to_string_lossy().escape_default().collect()
673673
}
674674

675+
pub fn make_zeroed_sigaction() -> libc::sigaction {
676+
// SAFETY: since sigaction is a C struct, all-zeroes is a valid representation
677+
// We cannot use a "literal struct" initialization method since the exact representation
678+
// of libc::sigaction is not fixed, see e.g. https://github.com/memorysafety/sudo-rs/issues/829
679+
unsafe { std::mem::zeroed() }
680+
}
681+
675682
#[cfg(test)]
676683
mod tests {
677684
use std::{
@@ -894,10 +901,3 @@ mod tests {
894901
assert_eq!(status.exit_status(), Some(0));
895902
}
896903
}
897-
898-
pub fn make_zeroed_sigaction() -> libc::sigaction {
899-
// SAFETY: since sigaction is a C struct, all-zeroes is a valid representation
900-
// We cannot use a "literal struct" initialization method since the exact representation
901-
// of libc::sigaction is not fixed, see e.g. https://github.com/memorysafety/sudo-rs/issues/829
902-
unsafe { std::mem::zeroed() }
903-
}

src/visudo/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ fn run(file_arg: Option<&str>, perms: bool, owner: bool) -> io::Result<()> {
172172
.read(true)
173173
.write(true)
174174
.create(true)
175+
.truncate(true)
175176
.open(&tmp_path)?;
176177

177178
tmp_file.set_permissions(Permissions::from_mode(0o700))?;

0 commit comments

Comments
 (0)