safe-path: fix clippy warning

fix clippy warnings in safe-path lib to make clippy happy.

fixes: #4443

Signed-off-by: Chao Wu <chaowu@linux.alibaba.com>
This commit is contained in:
Chao Wu 2022-06-11 20:51:54 +08:00
parent aefe11b9ba
commit bb26bd73b1
2 changed files with 5 additions and 3 deletions

View File

@ -253,7 +253,7 @@ mod tests {
fs::write(rootfs_path.join("endpoint"), "test").unwrap(); fs::write(rootfs_path.join("endpoint"), "test").unwrap();
// Pin the target and validate the path/content. // Pin the target and validate the path/content.
let path = PinnedPathBuf::new(rootfs_path.to_path_buf(), "symlink_dir/endpoint").unwrap(); let path = PinnedPathBuf::new(rootfs_path, "symlink_dir/endpoint").unwrap();
assert!(!path.is_dir()); assert!(!path.is_dir());
let path_ref = path.deref(); let path_ref = path.deref();
let target = fs::read_link(path_ref).unwrap(); let target = fs::read_link(path_ref).unwrap();
@ -344,6 +344,7 @@ mod tests {
PinnedPathBuf::new(rootfs_path, "does_not_exist").unwrap_err(); PinnedPathBuf::new(rootfs_path, "does_not_exist").unwrap_err();
} }
#[allow(clippy::zero_prefixed_literal)]
#[test] #[test]
fn test_new_pinned_path_buf_without_read_perm() { fn test_new_pinned_path_buf_without_read_perm() {
let rootfs_dir = tempfile::tempdir().expect("failed to create tmpdir"); let rootfs_dir = tempfile::tempdir().expect("failed to create tmpdir");

View File

@ -87,7 +87,7 @@ impl ScopedDirBuilder {
) )
})?; })?;
self.do_mkdir(&stripped_path) self.do_mkdir(stripped_path)
} }
/// Creates sub-directory with the options configured in this builder. /// Creates sub-directory with the options configured in this builder.
@ -134,7 +134,7 @@ impl ScopedDirBuilder {
if !self.recursive && idx != levels { if !self.recursive && idx != levels {
return Err(Error::new( return Err(Error::new(
ErrorKind::NotFound, ErrorKind::NotFound,
format!("parent directory does not exist"), "parent directory does not exist".to_string(),
)); ));
} }
dir = dir.mkdir(comp, self.mode)?; dir = dir.mkdir(comp, self.mode)?;
@ -146,6 +146,7 @@ impl ScopedDirBuilder {
} }
} }
#[allow(clippy::zero_prefixed_literal)]
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;