Skip to content

Commit

Permalink
fix: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Yato202010 committed Jan 12, 2025
1 parent c131bef commit 7d38108
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
6 changes: 2 additions & 4 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::fs::remove_dir_all;

fn main() {
println!("cargo:rerun-if-changed=vendor");

Expand All @@ -21,7 +19,7 @@ fn main() {
if !srcdir.exists() {
std::fs::create_dir(&srcdir).unwrap();
}
remove_dir_all(&srcdir).unwrap();
std::fs::remove_dir_all(&srcdir).unwrap();
fs_extra::dir::copy(
&d,
&srcdir,
Expand Down Expand Up @@ -129,7 +127,7 @@ mod vendored {

check_dir(&mut hashed, src.as_ref(), &exception);

if !cache.is_some_and(|x| x.new_or_edited == hashed) {
if cache.is_none_or(|x| x.new_or_edited != hashed) {
println!("Detected changes in vendored dependency. Updating cache.");

let new_cache = Cache {
Expand Down
8 changes: 4 additions & 4 deletions src/os/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ pub mod overlay;
#[cfg(feature = "overlayfs")]
pub use overlay::OverlayFs;

#[allow(unused_imports)]
pub(crate) use option::set_option_helper;
pub use option::{FsOption, LinuxFilesystem, MountOption};
#[allow(unused_imports)]
pub(crate) use recover_state::{restore_fsdata, FsData};

/// Provide utility to recover filesystem state from the information provided by the system
Expand Down Expand Up @@ -41,10 +43,7 @@ mod recover_state {
pub(crate) fn restore_fsdata<P: AsRef<Path>, O: FsOption>(
path: P,
) -> Result<Option<FsData<O>>> {
let fd = unsafe {
let mtab = CStr::from_bytes_with_nul_unchecked(b"/etc/mtab\0");
setmntent(mtab.as_ptr(), "r".as_ptr() as *const i8)
};
let fd = unsafe { setmntent(c"/etc/mtab".as_ptr(), "r".as_ptr() as *const i8) };
if fd.is_null() {
return Err(std::io::Error::new(
std::io::ErrorKind::Other,
Expand Down Expand Up @@ -92,6 +91,7 @@ mod option {
fn options(&self) -> &[MountOption<O>];
}

#[allow(dead_code)]
pub(crate) fn set_option_helper<T, O>(
options: &mut Vec<MountOption<T>>,
option: O,
Expand Down
6 changes: 3 additions & 3 deletions src/os/linux/overlay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use nix::{
unistd::getuid,
};
use std::{
ffi::{CStr, CString},
ffi::CString,
io::{Error, ErrorKind, Result},
path::{Path, PathBuf},
};
Expand Down Expand Up @@ -173,9 +173,9 @@ impl Filesystem for OverlayFs {
let mut args = options.as_bytes().to_vec();
args.push(b'\0');
mount(
Some(unsafe { CStr::from_bytes_with_nul(b"overlay\0").unwrap_unchecked() }),
Some(c"overlay"),
&*self.target,
Some(unsafe { CStr::from_bytes_with_nul(b"overlay\0").unwrap_unchecked() }),
Some(c"overlay"),
flags,
Some(unsafe { CString::from_vec_with_nul_unchecked(args).as_bytes() }),
)
Expand Down

0 comments on commit 7d38108

Please sign in to comment.