Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

misc: update toolchain to 1.68.2 and fix clippy warnings #1227

Merged
merged 1 commit into from
Apr 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion misc/musl-static/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM clux/muslrust:1.66.1
FROM clux/muslrust:1.68.2

ARG RUST_TARGET=x86_64-unknown-linux-musl

Expand Down
2 changes: 1 addition & 1 deletion misc/nydus-smoke/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM rust:1.66.1
FROM rust:1.68.2
ARG RUST_TARGET=x86_64-unknown-linux-musl

RUN mkdir /root/.cargo/
Expand Down
2 changes: 1 addition & 1 deletion rafs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ pub trait RafsIoWrite: Write + Seek + 'static {

fn validate_alignment(&mut self, size: usize, alignment: usize) -> Result<usize> {
if alignment != 0 {
let cur = self.seek(SeekFrom::Current(0))?;
let cur = self.stream_position()?;

if (size & (alignment - 1) != 0) || (cur & (alignment as u64 - 1) != 0) {
return Err(einval!("unaligned data"));
Expand Down
8 changes: 4 additions & 4 deletions rafs/src/metadata/direct_v6.rs
Original file line number Diff line number Diff line change
Expand Up @@ -479,9 +479,9 @@ impl OndiskInodeWrapper {
// 3 - inode compression D: inode, [xattrs], map_header, extents ... | ...
// 4 - inode chunk-based E: inode, [xattrs], chunk indexes ... | ...
// 5~7 - reserved
fn data_block_offset<'a>(
fn data_block_offset(
&self,
state: &'a Guard<Arc<DirectMappingState>>,
state: &Guard<Arc<DirectMappingState>>,
inode: &dyn RafsV6OndiskInode,
index: usize,
) -> RafsResult<usize> {
Expand Down Expand Up @@ -713,9 +713,9 @@ impl OndiskInodeWrapper {
Ok(())
}

fn get_entry_count<'a>(
fn get_entry_count(
&self,
state: &'a Guard<Arc<DirectMappingState>>,
state: &Guard<Arc<DirectMappingState>>,
inode: &dyn RafsV6OndiskInode,
block_index: usize,
) -> Result<usize> {
Expand Down
18 changes: 4 additions & 14 deletions rafs/src/metadata/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -569,20 +569,15 @@ impl Default for RafsSuperMeta {
}

/// RAFS filesystem versions.
#[derive(Clone, Copy, Debug, PartialEq)]
#[derive(Clone, Copy, Debug, Default, PartialEq)]
pub enum RafsVersion {
/// RAFS v5
#[default]
V5,
/// RAFS v6
V6,
}

impl Default for RafsVersion {
fn default() -> Self {
RafsVersion::V5
}
}

impl TryFrom<u32> for RafsVersion {
type Error = Error;

Expand Down Expand Up @@ -618,20 +613,15 @@ impl RafsVersion {
}

/// Rafs metadata working mode.
#[derive(Clone, Debug, Eq, PartialEq)]
#[derive(Clone, Debug, Default, Eq, PartialEq)]
pub enum RafsMode {
/// Directly mapping and accessing metadata into process by mmap().
#[default]
Direct,
/// Read metadata into memory before using, for RAFS v5.
Cached,
}

impl Default for RafsMode {
fn default() -> Self {
RafsMode::Direct
}
}

impl FromStr for RafsMode {
type Err = Error;

Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.66.1
1.68.2
2 changes: 1 addition & 1 deletion storage/src/factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ struct BlobCacheMgrKey {
config: Arc<ConfigV2>,
}

#[allow(clippy::derive_hash_xor_eq)]
#[allow(clippy::derived_hash_with_manual_eq)]
impl Hash for BlobCacheMgrKey {
fn hash<H: Hasher>(&self, state: &mut H) {
self.config.id.hash(state);
Expand Down
2 changes: 1 addition & 1 deletion storage/src/meta/toc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl TryFrom<compress::Algorithm> for TocEntryFlags {
compress::Algorithm::None => Ok(Self::COMPRESSION_NONE),
compress::Algorithm::Zstd => Ok(Self::COMPRESSION_ZSTD),
compress::Algorithm::Lz4Block => Ok(Self::COMPRESSION_LZ4_BLOCK),
_ => return Err(eother!(format!("unsupported compressor {}", c,))),
_ => Err(eother!(format!("unsupported compressor {}", c,))),
}
}
}
Expand Down
9 changes: 2 additions & 7 deletions utils/src/compress/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,15 @@ const COMPRESSION_MINIMUM_RATIO: usize = 100;

/// Supported compression algorithms.
#[repr(u32)]
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
#[derive(Clone, Copy, Debug, Default, Eq, Hash, PartialEq)]
pub enum Algorithm {
#[default]
None = 0,
Lz4Block = 1,
GZip = 2,
Zstd = 3,
}

impl Default for Algorithm {
fn default() -> Self {
Self::None
}
}

impl fmt::Display for Algorithm {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{:?}", self)
Expand Down
17 changes: 4 additions & 13 deletions utils/src/crypt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ use openssl::symm;

/// Supported cipher algorithms.
#[repr(u32)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub enum Algorithm {
#[default]
None = 0,
Aes128Xts = 1,
Aes256Xts = 2,
Expand Down Expand Up @@ -67,12 +68,6 @@ impl Algorithm {
}
}

impl Default for Algorithm {
fn default() -> Self {
Algorithm::None
}
}

impl fmt::Display for Algorithm {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{:?}", self)
Expand Down Expand Up @@ -130,19 +125,15 @@ impl TryFrom<u64> for Algorithm {
}

/// Cipher object to encrypt/decrypt data.
#[derive(Default)]
pub enum Cipher {
#[default]
None,
Aes128Xts(symm::Cipher),
Aes256Xts(symm::Cipher),
Aes256Gcm(symm::Cipher),
}

impl Default for Cipher {
fn default() -> Self {
Cipher::None
}
}

impl Debug for Cipher {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
match self {
Expand Down
9 changes: 2 additions & 7 deletions utils/src/digest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,13 @@ pub const RAFS_DIGEST_LENGTH: usize = 32;
pub type DigestData = [u8; RAFS_DIGEST_LENGTH];

#[repr(u32)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub enum Algorithm {
#[default]
Blake3 = 0,
Sha256 = 1,
}

impl Default for Algorithm {
fn default() -> Self {
Self::Blake3
}
}

impl fmt::Display for Algorithm {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{:?}", self)
Expand Down