avoid some clippy warnings

This commit is contained in:
Dietmar Maurer 2019-10-25 18:44:51 +02:00
parent f58f426e86
commit 834a2f95a0
13 changed files with 71 additions and 80 deletions

View File

@ -67,8 +67,7 @@ impl CryptConfig {
let mut hasher = openssl::sha::Sha256::new();
hasher.update(&self.id_key);
hasher.update(data);
let digest = hasher.finish();
digest
hasher.finish()
}
pub fn data_signer(&self) -> openssl::sign::Signer {

View File

@ -67,25 +67,23 @@ impl <R: BufRead> Read for CryptReader<R> {
if count > buf.len() {
buf.copy_from_slice(&outbuf[..buf.len()]);
self.small_read_buf = outbuf[buf.len()..count].to_vec();
return Ok(buf.len());
Ok(buf.len())
} else {
buf[..count].copy_from_slice(&outbuf[..count]);
return Ok(count);
Ok(count)
}
} else if data.len() == 0 { // EOF
let rest = self.crypter.finalize(buf)?;
self.finalized = true;
Ok(rest)
} else {
if data.len() == 0 { // EOF
let rest = self.crypter.finalize(buf)?;
self.finalized = true;
return Ok(rest)
} else {
let mut read_size = buf.len() - self.block_size;
if read_size > data.len() {
read_size = data.len();
}
let count = self.crypter.update(&data[..read_size], buf)?;
self.reader.consume(read_size);
return Ok(count)
let mut read_size = buf.len() - self.block_size;
if read_size > data.len() {
read_size = data.len();
}
let count = self.crypter.update(&data[..read_size], buf)?;
self.reader.consume(read_size);
Ok(count)
}
}
}

View File

@ -176,16 +176,15 @@ pub fn load_and_decrtypt_key(path: &std::path::Path, passphrase: &dyn Fn() -> Re
let cipher = openssl::symm::Cipher::aes_256_gcm();
let decr_data = openssl::symm::decrypt_aead(
openssl::symm::decrypt_aead(
cipher,
&derived_key,
Some(&iv),
b"", //??
&enc_data,
&tag,
).map_err(|err| format_err!("Unable to decrypt key - {}", err))?;
).map_err(|err| format_err!("Unable to decrypt key - {}", err))?
decr_data
} else {
raw_data
};

View File

@ -471,12 +471,12 @@ impl<'a, W: Write, C: BackupCatalogWriter> Encoder<'a, W, C> {
let projid = fsxattr.fsx_projid as u64;
if projid == 0 {
return Ok(None);
Ok(None)
} else {
return Ok(Some(PxarQuotaProjID { projid }));
Ok(Some(PxarQuotaProjID { projid }))
}
}
_ => return Ok(None),
_ => Ok(None),
}
}
@ -680,12 +680,10 @@ impl<'a, W: Write, C: BackupCatalogWriter> Encoder<'a, W, C> {
let include_children;
if is_virtual_file_system(magic) {
include_children = false;
} else if let Some(set) = &self.device_set {
include_children = set.contains(&dir_stat.st_dev);
} else {
if let Some(set) = &self.device_set {
include_children = set.contains(&dir_stat.st_dev);
} else {
include_children = true;
}
include_children = true;
}
// Expand the exclude match pattern inherited from the parent by local entries, if present
@ -1036,12 +1034,10 @@ impl<'a, W: Write, C: BackupCatalogWriter> Encoder<'a, W, C> {
let include_payload;
if is_virtual_file_system(magic) {
include_payload = false;
} else if let Some(ref set) = &self.device_set {
include_payload = set.contains(&stat.st_dev);
} else {
if let Some(ref set) = &self.device_set {
include_payload = set.contains(&stat.st_dev);
} else {
include_payload = true;
}
include_payload = true;
}
if !include_payload {
@ -1178,12 +1174,10 @@ impl<'a, W: Write, C: BackupCatalogWriter> Encoder<'a, W, C> {
let include_payload;
if is_virtual_file_system(magic) {
include_payload = false;
} else if let Some(set) = &self.device_set {
include_payload = set.contains(&stat.st_dev);
} else {
if let Some(set) = &self.device_set {
include_payload = set.contains(&stat.st_dev);
} else {
include_payload = true;
}
include_payload = true;
}
if !include_payload {

View File

@ -35,42 +35,42 @@ pub const WITH_FLAG_COMPR: u64 = 0x40000;
/// Linux file attribute `NOCOW`
pub const WITH_FLAG_NOCOW: u64 = 0x80000;
/// Linux file attribute `NODUMP`
pub const WITH_FLAG_NODUMP: u64 = 0x100000;
pub const WITH_FLAG_NODUMP: u64 = 0x0010_0000;
/// Linux file attribute `DIRSYNC`
pub const WITH_FLAG_DIRSYNC: u64 = 0x200000;
pub const WITH_FLAG_DIRSYNC: u64 = 0x0020_0000;
/// Linux file attribute `IMMUTABLE`
pub const WITH_FLAG_IMMUTABLE: u64 = 0x400000;
pub const WITH_FLAG_IMMUTABLE: u64 = 0x0040_0000;
/// Linux file attribute `SYNC`
pub const WITH_FLAG_SYNC: u64 = 0x800000;
pub const WITH_FLAG_SYNC: u64 = 0x0080_0000;
/// Linux file attribute `NOCOMP`
pub const WITH_FLAG_NOCOMP: u64 = 0x1000000;
pub const WITH_FLAG_NOCOMP: u64 = 0x0100_0000;
/// Linux file attribute `PROJINHERIT`
pub const WITH_FLAG_PROJINHERIT: u64 = 0x2000000;
pub const WITH_FLAG_PROJINHERIT: u64 = 0x0200_0000;
/// Preserve BTRFS subvolume flag
pub const WITH_SUBVOLUME: u64 = 0x4000000;
pub const WITH_SUBVOLUME: u64 = 0x0400_0000;
/// Preserve BTRFS read-only subvolume flag
pub const WITH_SUBVOLUME_RO: u64 = 0x8000000;
pub const WITH_SUBVOLUME_RO: u64 = 0x0800_0000;
/// Preserve Extended Attribute metadata
pub const WITH_XATTRS: u64 = 0x10000000;
pub const WITH_XATTRS: u64 = 0x1000_0000;
/// Preserve Access Control List metadata
pub const WITH_ACL: u64 = 0x20000000;
pub const WITH_ACL: u64 = 0x2000_0000;
/// Preserve SELinux security context
pub const WITH_SELINUX: u64 = 0x40000000;
pub const WITH_SELINUX: u64 = 0x4000_0000;
/// Preserve "security.capability" xattr
pub const WITH_FCAPS: u64 = 0x80000000;
pub const WITH_FCAPS: u64 = 0x8000_0000;
/// Preserve XFS/ext4/ZFS project quota ID
pub const WITH_QUOTA_PROJID: u64 = 0x100000000;
pub const WITH_QUOTA_PROJID: u64 = 0x0001_0000_0000;
/// Support ".pxarexclude" files
pub const EXCLUDE_FILE: u64 = 0x1000000000000000;
pub const EXCLUDE_FILE: u64 = 0x1000_0000_0000_0000;
/// Exclude submounts
pub const EXCLUDE_SUBMOUNTS: u64 = 0x4000000000000000;
pub const EXCLUDE_SUBMOUNTS: u64 = 0x4000_0000_0000_0000;
/// Exclude entries with chattr flag NODUMP
pub const EXCLUDE_NODUMP: u64 = 0x8000000000000000;
pub const EXCLUDE_NODUMP: u64 = 0x8000_0000_0000_0000;
/// Definitions of typical feature flags for the *pxar* encoder/decoder.
/// By this expensive syscalls for unsupported features are avoided.
@ -138,16 +138,16 @@ pub const DEFAULT: u64 =
EXCLUDE_FILE;
// form /usr/include/linux/fs.h
const FS_APPEND_FL: u32 = 0x00000020;
const FS_NOATIME_FL: u32 = 0x00000080;
const FS_COMPR_FL: u32 = 0x00000004;
const FS_NOCOW_FL: u32 = 0x00800000;
const FS_NODUMP_FL: u32 = 0x00000040;
const FS_DIRSYNC_FL: u32 = 0x00010000;
const FS_IMMUTABLE_FL: u32 = 0x00000010;
const FS_SYNC_FL: u32 = 0x00000008;
const FS_NOCOMP_FL: u32 = 0x00000400;
const FS_PROJINHERIT_FL: u32 = 0x20000000;
const FS_APPEND_FL: u32 = 0x0000_0020;
const FS_NOATIME_FL: u32 = 0x0000_0080;
const FS_COMPR_FL: u32 = 0x0000_0004;
const FS_NOCOW_FL: u32 = 0x0080_0000;
const FS_NODUMP_FL: u32 = 0x0000_0040;
const FS_DIRSYNC_FL: u32 = 0x0001_0000;
const FS_IMMUTABLE_FL: u32 = 0x0000_0010;
const FS_SYNC_FL: u32 = 0x0000_0008;
const FS_NOCOMP_FL: u32 = 0x0000_0400;
const FS_PROJINHERIT_FL: u32 = 0x2000_0000;
static CHATTR_MAP: [(u64, u32); 10] = [
( WITH_FLAG_APPEND, FS_APPEND_FL ),

View File

@ -10,6 +10,7 @@ use endian_trait::Endian;
use failure::{bail, Error};
use siphasher::sip::SipHasher24;
/// Header types identifying items stored in the archive
pub const PXAR_ENTRY: u64 = 0x1396fabcea5bbb51;
pub const PXAR_FILENAME: u64 = 0x6dbb6ebcb3161f0b;

View File

@ -233,7 +233,7 @@ impl Session {
Ok(Self {
ptr: session_ptr,
verbose: verbose,
verbose,
})
}

View File

@ -1196,13 +1196,13 @@ fn nsec_to_update_timespec(mtime_nsec: u64) -> [libc::timespec; 2] {
}
fn mode_user_to_acl_permissions(mode: u64) -> u64 {
return (mode >> 6) & 7;
(mode >> 6) & 7
}
fn mode_group_to_acl_permissions(mode: u64) -> u64 {
return (mode >> 3) & 7;
(mode >> 3) & 7
}
fn mode_other_to_acl_permissions(mode: u64) -> u64 {
return mode & 7;
mode & 7
}

View File

@ -54,15 +54,15 @@ impl <E: RpcEnvironment + Clone> H2Service<E> {
match self.router.find_method(&components, method, &mut uri_param) {
MethodDefinition::None => {
let err = http_err!(NOT_FOUND, "Path not found.".to_string());
return Box::new(future::ok((formatter.format_error)(err)));
Box::new(future::ok((formatter.format_error)(err)))
}
MethodDefinition::Simple(api_method) => {
return crate::server::rest::handle_sync_api_request(
self.rpcenv.clone(), api_method, formatter, parts, body, uri_param);
crate::server::rest::handle_sync_api_request(
self.rpcenv.clone(), api_method, formatter, parts, body, uri_param)
}
MethodDefinition::Async(async_method) => {
return crate::server::rest::handle_async_api_request(
self.rpcenv.clone(), async_method, formatter, parts, body, uri_param);
crate::server::rest::handle_async_api_request(
self.rpcenv.clone(), async_method, formatter, parts, body, uri_param)
}
}
}

View File

@ -484,7 +484,7 @@ fn handle_static_file_download(filename: PathBuf) -> BoxFut {
}
});
return Box::new(response);
Box::new(response)
}
fn extract_auth_data(headers: &http::HeaderMap) -> (Option<String>, Option<String>) {

View File

@ -95,7 +95,7 @@ impl std::str::FromStr for UPID {
if let Some(cap) = REGEX.captures(s) {
return Ok(UPID {
Ok(UPID {
pid: i32::from_str_radix(&cap["pid"], 16).unwrap(),
pstart: u64::from_str_radix(&cap["pstart"], 16).unwrap(),
starttime: i64::from_str_radix(&cap["starttime"], 16).unwrap(),
@ -104,7 +104,7 @@ impl std::str::FromStr for UPID {
worker_id: if cap["wid"].is_empty() { None } else { Some(cap["wid"].to_string()) },
username: cap["username"].to_string(),
node: cap["node"].to_string(),
});
})
} else {
bail!("unable to parse UPID '{}'", s);
}

View File

@ -79,7 +79,7 @@ impl ACL {
return Err(Errno::last());
}
Ok(ACL { ptr: ptr })
Ok(ACL { ptr })
}
pub fn get_file<P: AsRef<Path>>(path: P, acl_type: ACLType) -> Result<ACL, nix::errno::Errno> {
@ -89,7 +89,7 @@ impl ACL {
return Err(Errno::last());
}
Ok(ACL { ptr: ptr })
Ok(ACL { ptr })
}
pub fn set_file<P: AsRef<Path>>(&self, path: P, acl_type: ACLType) -> Result<(), nix::errno::Errno> {
@ -108,7 +108,7 @@ impl ACL {
return Err(Errno::last());
}
Ok(ACL { ptr: ptr })
Ok(ACL { ptr })
}
pub fn create_entry<'a>(&'a mut self) -> Result<ACLEntry<'a>, nix::errno::Errno> {
@ -119,7 +119,7 @@ impl ACL {
}
Ok(ACLEntry {
ptr: ptr,
ptr,
_phantom: PhantomData,
})
}

View File

@ -155,7 +155,7 @@ mod tests {
}
let invalid_name_length = PxarXAttr {
name: name,
name,
value: b"err".to_vec(),
};