From 653b1ca10e588dc609460e3827df89147c6f1b7e Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Wed, 11 Sep 2019 12:06:59 +0200 Subject: [PATCH] some clippy fixups Signed-off-by: Wolfgang Bumiller --- src/api_schema/config.rs | 2 +- src/api_schema/schema.rs | 19 +++++++++---------- src/backup/catalog_blob.rs | 2 +- src/backup/chunker.rs | 4 ++-- src/backup/data_chunk.rs | 4 ++-- src/backup/dynamic_index.rs | 6 +++--- src/backup/fixed_index.rs | 4 ++-- src/buildcfg.rs | 2 +- src/cli/command.rs | 2 +- src/pxar/decoder.rs | 8 ++++---- src/pxar/encoder.rs | 10 +++++----- src/section_config.rs | 2 +- src/server/worker_task.rs | 2 +- src/tools/process_locker.rs | 2 +- 14 files changed, 34 insertions(+), 35 deletions(-) diff --git a/src/api_schema/config.rs b/src/api_schema/config.rs index 77bc528c..e210066b 100644 --- a/src/api_schema/config.rs +++ b/src/api_schema/config.rs @@ -17,7 +17,7 @@ impl ApiConfig { pub fn new>(basedir: B, router: &'static Router, env_type: RpcEnvironmentType) -> Self { Self { basedir: basedir.into(), - router: router, + router, aliases: HashMap::new(), env_type, } diff --git a/src/api_schema/schema.rs b/src/api_schema/schema.rs index 3d8a3347..38d9a44b 100644 --- a/src/api_schema/schema.rs +++ b/src/api_schema/schema.rs @@ -61,7 +61,7 @@ impl BooleanSchema { pub fn new(description: &'static str) -> Self { BooleanSchema { - description: description, + description, default: None, } } @@ -84,7 +84,7 @@ impl IntegerSchema { pub fn new(description: &'static str) -> Self { IntegerSchema { - description: description, + description, default: None, minimum: None, maximum: None, @@ -138,7 +138,7 @@ impl StringSchema { pub fn new(description: &'static str) -> Self { StringSchema { - description: description, + description, default: None, min_length: None, max_length: None, @@ -225,7 +225,7 @@ impl ArraySchema { pub fn new(description: &'static str, item_schema: Arc) -> Self { ArraySchema { - description: description, + description, items: item_schema, min_length: None, max_length: None, @@ -273,9 +273,9 @@ impl ObjectSchema { pub fn new(description: &'static str) -> Self { let properties = HashMap::new(); ObjectSchema { - description: description, + description, additional_properties: false, - properties: properties, + properties, default_key: None, } } @@ -426,8 +426,8 @@ fn parse_property_string(value_str: &str, schema: &Schema) -> Result { @@ -440,13 +440,12 @@ fn parse_property_string(value_str: &str, schema: &Schema) -> Result { bail!("Got unexpetec schema type.") } } - } pub fn parse_simple_value(value_str: &str, schema: &Schema) -> Result { diff --git a/src/backup/catalog_blob.rs b/src/backup/catalog_blob.rs index ecf35bd6..88c4d4e5 100644 --- a/src/backup/catalog_blob.rs +++ b/src/backup/catalog_blob.rs @@ -162,7 +162,7 @@ impl CatalogBlobReader { write!(out, " {} {}", size, dt.to_rfc3339_opts(chrono::SecondsFormat::Secs, false))?; } - write!(out, "\n")?; + writeln!(out)?; std::io::stdout().write_all(&out)?; Ok(()) diff --git a/src/backup/chunker.rs b/src/backup/chunker.rs index 4ef7d0bf..abc3ab78 100644 --- a/src/backup/chunker.rs +++ b/src/backup/chunker.rs @@ -99,8 +99,8 @@ impl Chunker { chunk_size_max: chunk_size_avg << 2, _chunk_size_avg: chunk_size_avg, _discriminator: discriminator, - break_test_mask: break_test_mask, - break_test_minimum: break_test_minimum, + break_test_mask, + break_test_minimum, window: [0u8; CA_CHUNKER_WINDOW_SIZE], } } diff --git a/src/backup/data_chunk.rs b/src/backup/data_chunk.rs index 700f914d..cc2f6321 100644 --- a/src/backup/data_chunk.rs +++ b/src/backup/data_chunk.rs @@ -217,12 +217,12 @@ impl DataChunk { bail!("encrypted chunk too small ({} bytes).", data.len()); } - let chunk = DataChunk { digest: digest, raw_data: data }; + let chunk = DataChunk { digest, raw_data: data }; Ok(chunk) } else if magic == COMPRESSED_CHUNK_MAGIC_1_0 || magic == UNCOMPRESSED_CHUNK_MAGIC_1_0 { - let chunk = DataChunk { digest: digest, raw_data: data }; + let chunk = DataChunk { digest, raw_data: data }; Ok(chunk) } else { diff --git a/src/backup/dynamic_index.rs b/src/backup/dynamic_index.rs index a2a9a1e0..d4cb6eb6 100644 --- a/src/backup/dynamic_index.rs +++ b/src/backup/dynamic_index.rs @@ -275,8 +275,8 @@ impl BufferedDynamicReader { let archive_size = index.chunk_end(index.index_entries - 1); Self { store, - index: index, - archive_size: archive_size, + index, + archive_size, read_buffer: Vec::with_capacity(1024*1024), buffered_chunk_idx: 0, buffered_chunk_start: 0, @@ -456,7 +456,7 @@ impl DynamicIndexWriter { Ok(Self { store, _lock: shared_lock, - writer: writer, + writer, closed: false, filename: full_path, tmp_filename: tmp_path, diff --git a/src/backup/fixed_index.rs b/src/backup/fixed_index.rs index 4c1d18e3..6df68a8b 100644 --- a/src/backup/fixed_index.rs +++ b/src/backup/fixed_index.rs @@ -453,8 +453,8 @@ impl BufferedFixedReader { let archive_size = index.size; Self { store, - index: index, - archive_size: archive_size, + index, + archive_size, read_buffer: Vec::with_capacity(1024*1024), buffered_chunk_idx: 0, buffered_chunk_start: 0, diff --git a/src/buildcfg.rs b/src/buildcfg.rs index 847e1d4c..3d951bfb 100644 --- a/src/buildcfg.rs +++ b/src/buildcfg.rs @@ -1,7 +1,7 @@ //! Exports configuration data from the build system /// The configured configuration directory -pub const CONFIGDIR: &'static str = "/etc/proxmox-backup"; +pub const CONFIGDIR: &str = "/etc/proxmox-backup"; pub const JS_DIR: &str = "/usr/share/javascript/proxmox-backup"; /// Prepend configuration directory to a file name diff --git a/src/cli/command.rs b/src/cli/command.rs index a8c791b8..05e5092f 100644 --- a/src/cli/command.rs +++ b/src/cli/command.rs @@ -344,7 +344,7 @@ fn print_property_completion( return; } } - println!(""); + println!(); } fn record_done_argument(done: &mut HashMap, parameters: &ObjectSchema, key: &str, value: &str) { diff --git a/src/pxar/decoder.rs b/src/pxar/decoder.rs index 9db26e21..64668019 100644 --- a/src/pxar/decoder.rs +++ b/src/pxar/decoder.rs @@ -39,7 +39,7 @@ impl Result<(), Error>> Decoder { Ok(Self { inner: SequentialDecoder::new(reader, super::flags::DEFAULT, callback), root_start: 0, - root_end: root_end, + root_end, }) } @@ -52,7 +52,7 @@ impl Result<(), Error>> Decoder { start: self.root_start, end: self.root_end, filename: OsString::new(), // Empty - entry: entry, + entry, }) } @@ -106,8 +106,8 @@ impl Result<(), Error>> Decoder { Ok(DirectoryEntry { start: entry_start, - end: end, - filename: filename, + end, + filename, entry, }) } diff --git a/src/pxar/encoder.rs b/src/pxar/encoder.rs index 34c0dc06..bb337436 100644 --- a/src/pxar/encoder.rs +++ b/src/pxar/encoder.rs @@ -115,7 +115,7 @@ impl<'a, W: Write, C: BackupCatalogWriter> Encoder<'a, W, C> { let mut me = Self { base_path: path, relative_path: PathBuf::new(), - writer: writer, + writer, writer_pos: 0, catalog, _size: 0, @@ -192,7 +192,7 @@ impl<'a, W: Write, C: BackupCatalogWriter> Encoder<'a, W, C> { } let entry = PxarEntry { - mode: mode, + mode, flags: 0, uid: stat.st_uid, gid: stat.st_gid, @@ -303,7 +303,7 @@ impl<'a, W: Write, C: BackupCatalogWriter> Encoder<'a, W, C> { } else if self.has_features(flags::WITH_XATTRS) { xattrs.push(PxarXAttr { name: name.to_vec(), - value: value, + value, }); } } @@ -374,13 +374,13 @@ impl<'a, W: Write, C: BackupCatalogWriter> Encoder<'a, W, C> { acl::ACL_USER => { acl_user.push(PxarACLUser { uid: entry.get_qualifier()?, - permissions: permissions, + permissions, }); } acl::ACL_GROUP => { acl_group.push(PxarACLGroup { gid: entry.get_qualifier()?, - permissions: permissions, + permissions, }); } _ => bail!("Unexpected ACL tag encountered!"), diff --git a/src/section_config.rs b/src/section_config.rs index 6c3ea7db..7b2b15eb 100644 --- a/src/section_config.rs +++ b/src/section_config.rs @@ -78,7 +78,7 @@ impl SectionConfig { pub fn new(id_schema: Arc) -> Self { Self { plugins: HashMap::new(), - id_schema: id_schema, + id_schema, parse_section_header: SectionConfig::default_parse_section_header, parse_section_content: SectionConfig::default_parse_section_content, format_section_header: SectionConfig::default_format_section_header, diff --git a/src/server/worker_task.rs b/src/server/worker_task.rs index 6a55755a..abb2d47a 100644 --- a/src/server/worker_task.rs +++ b/src/server/worker_task.rs @@ -382,7 +382,7 @@ impl WorkerTask { update_active_workers(Some(&upid))?; let worker = Arc::new(Self { - upid: upid, + upid, abort_requested: AtomicBool::new(false), data: Mutex::new(WorkerTaskData { logger, diff --git a/src/tools/process_locker.rs b/src/tools/process_locker.rs index e60992d6..8f384d96 100644 --- a/src/tools/process_locker.rs +++ b/src/tools/process_locker.rs @@ -104,7 +104,7 @@ impl ProcessLocker { .open(lockfile)?; Ok(Arc::new(Mutex::new(Self { - file: file, + file, exclusive: false, writers: 0, next_guard_id: 0,