From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <pbs-devel-bounces@lists.proxmox.com> Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 815781FF168 for <inbox@lore.proxmox.com>; Tue, 4 Mar 2025 15:41:59 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id E78461DEB; Tue, 4 Mar 2025 15:41:55 +0100 (CET) From: Maximiliano Sandoval <m.sandoval@proxmox.com> To: pbs-devel@lists.proxmox.com Date: Tue, 4 Mar 2025 15:40:50 +0100 Message-Id: <20250304144051.585163-8-m.sandoval@proxmox.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250304144051.585163-1-m.sandoval@proxmox.com> References: <20250304144051.585163-1-m.sandoval@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.100 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pbs-devel] [PATCH proxmox 8/9] run cargo clippy --fix X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion <pbs-devel.lists.proxmox.com> List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pbs-devel>, <mailto:pbs-devel-request@lists.proxmox.com?subject=unsubscribe> List-Archive: <http://lists.proxmox.com/pipermail/pbs-devel/> List-Post: <mailto:pbs-devel@lists.proxmox.com> List-Help: <mailto:pbs-devel-request@lists.proxmox.com?subject=help> List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel>, <mailto:pbs-devel-request@lists.proxmox.com?subject=subscribe> Reply-To: Proxmox Backup Server development discussion <pbs-devel@lists.proxmox.com> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pbs-devel-bounces@lists.proxmox.com Sender: "pbs-devel" <pbs-devel-bounces@lists.proxmox.com> Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com> --- proxmox-access-control/src/acl.rs | 10 ++-------- proxmox-acme/src/types.rs | 6 ++++++ proxmox-auth-api/src/auth_key.rs | 6 ++++++ proxmox-compression/src/zip.rs | 2 +- proxmox-io/src/sparse_copy.rs | 3 +-- proxmox-log/src/file_logger.rs | 2 +- proxmox-rest-server/src/worker_task.rs | 9 ++------- proxmox-rrd/src/cache.rs | 4 ++-- proxmox-rrd/src/cache/journal.rs | 4 ++-- proxmox-rrd/src/cache/rrd_map.rs | 6 +++--- proxmox-schema/src/upid.rs | 2 +- proxmox-shared-cache/src/lib.rs | 10 +++++----- proxmox-sys/src/logrotate.rs | 2 +- proxmox-sys/src/systemd.rs | 2 +- proxmox-systemd/src/escape.rs | 2 +- proxmox-uuid/src/lib.rs | 12 ++++++------ 16 files changed, 41 insertions(+), 41 deletions(-) diff --git a/proxmox-access-control/src/acl.rs b/proxmox-access-control/src/acl.rs index 2e5df932..48a096aa 100644 --- a/proxmox-access-control/src/acl.rs +++ b/proxmox-access-control/src/acl.rs @@ -208,10 +208,7 @@ impl AclTree { let mut node = &self.root; for outer in path { for comp in outer.split('/') { - node = match node.children.get(comp) { - Some(n) => n, - None => return None, - }; + node = node.children.get(comp)?; } } Some(node) @@ -221,10 +218,7 @@ impl AclTree { let mut node = &mut self.root; for outer in path { for comp in outer.split('/') { - node = match node.children.get_mut(comp) { - Some(n) => n, - None => return None, - }; + node = node.children.get_mut(comp)?; } } Some(node) diff --git a/proxmox-acme/src/types.rs b/proxmox-acme/src/types.rs index e5a6b34d..0ec2deeb 100644 --- a/proxmox-acme/src/types.rs +++ b/proxmox-acme/src/types.rs @@ -38,6 +38,12 @@ pub enum AccountStatus { Revoked, } +impl Default for AccountStatus { + fn default() -> Self { + Self::new() + } +} + impl AccountStatus { /// Create a new instance with state New. #[inline] diff --git a/proxmox-auth-api/src/auth_key.rs b/proxmox-auth-api/src/auth_key.rs index 98684853..b7515b75 100644 --- a/proxmox-auth-api/src/auth_key.rs +++ b/proxmox-auth-api/src/auth_key.rs @@ -237,6 +237,12 @@ pub struct Keyring { public_keys: Vec<VerificationKey>, } +impl Default for Keyring { + fn default() -> Self { + Self::new() + } +} + impl Keyring { pub fn generate_new_rsa() -> Result<Self, Error> { PrivateKey::generate_rsa().map(Self::with_private_key) diff --git a/proxmox-compression/src/zip.rs b/proxmox-compression/src/zip.rs index d074be5a..415e2cf8 100644 --- a/proxmox-compression/src/zip.rs +++ b/proxmox-compression/src/zip.rs @@ -360,7 +360,7 @@ impl ZipEntry { comment_len: 0, start_disk: 0, internal_flags: 0, - external_flags: (self.mode as u32) << 16 | (!self.is_file as u32) << 4, + external_flags: ((self.mode as u32) << 16) | ((!self.is_file as u32) << 4), offset, }, ) diff --git a/proxmox-io/src/sparse_copy.rs b/proxmox-io/src/sparse_copy.rs index 9d09e6ad..fad1a51a 100644 --- a/proxmox-io/src/sparse_copy.rs +++ b/proxmox-io/src/sparse_copy.rs @@ -14,8 +14,7 @@ const BUF_SIZE: usize = 8192; /// This is implemented in a way which allows the compiler to utilize SIMD instructions. pub fn buffer_is_zero(buf: &[u8]) -> bool { !buf.chunks(128) - .map(|aa| aa.iter().fold(0, |a, b| a | b) != 0) - .any(|a| a) + .any(|aa| aa.iter().fold(0, |a, b| a | b) != 0) } /// Result of a sparse copy call. diff --git a/proxmox-log/src/file_logger.rs b/proxmox-log/src/file_logger.rs index b5d28ace..e33bd09f 100644 --- a/proxmox-log/src/file_logger.rs +++ b/proxmox-log/src/file_logger.rs @@ -94,7 +94,7 @@ impl FileLogger { } let file = - atomic_open_or_create_file(&file_name, flags, &[], options.file_opts.clone(), false)?; + atomic_open_or_create_file(&file_name, flags, &[], options.file_opts, false)?; Ok(file) } diff --git a/proxmox-rest-server/src/worker_task.rs b/proxmox-rest-server/src/worker_task.rs index 6f0fcab2..88d79776 100644 --- a/proxmox-rest-server/src/worker_task.rs +++ b/proxmox-rest-server/src/worker_task.rs @@ -136,7 +136,6 @@ impl WorkerTaskSetup { fn lock_task_list_files(&self, exclusive: bool) -> Result<TaskListLockGuard, Error> { let options = self .file_opts - .clone() .perm(nix::sys::stat::Mode::from_bits_truncate(0o660)); let timeout = std::time::Duration::new(15, 0); @@ -163,7 +162,6 @@ impl WorkerTaskSetup { let mut path = self.log_directory(upid); let dir_opts = self .file_opts - .clone() .perm(nix::sys::stat::Mode::from_bits_truncate(0o755)); create_path(&path, None, Some(dir_opts))?; @@ -222,7 +220,6 @@ impl WorkerTaskSetup { let options = self .file_opts - .clone() .perm(nix::sys::stat::Mode::from_bits_truncate(0o660)); replace_file(&self.active_tasks_fn, active_raw.as_bytes(), options, false)?; @@ -237,7 +234,6 @@ impl WorkerTaskSetup { if !finish_list.is_empty() { let options = self .file_opts - .clone() .perm(nix::sys::stat::Mode::from_bits_truncate(0o660)); let mut writer = atomic_open_or_create_file( @@ -268,10 +264,9 @@ impl WorkerTaskSetup { try_block!({ let dir_opts = self .file_opts - .clone() .perm(nix::sys::stat::Mode::from_bits_truncate(0o755)); - create_path(&self.taskdir, Some(dir_opts.clone()), Some(dir_opts))?; + create_path(&self.taskdir, Some(dir_opts), Some(dir_opts))?; // fixme:??? create_path(pbs_buildcfg::PROXMOX_BACKUP_RUN_DIR, None, Some(opts))?; Ok(()) }) @@ -901,7 +896,7 @@ impl WorkerTask { exclusive: true, prefix_time: true, read: true, - file_opts: setup.file_opts.clone(), + file_opts: setup.file_opts, ..Default::default() }; let logger = FileLogger::new(path, logger_options)?; diff --git a/proxmox-rrd/src/cache.rs b/proxmox-rrd/src/cache.rs index e1c574c8..092a3626 100644 --- a/proxmox-rrd/src/cache.rs +++ b/proxmox-rrd/src/cache.rs @@ -68,8 +68,8 @@ impl Cache { create_path( &basedir, - Some(dir_options.clone()), - Some(dir_options.clone()), + Some(dir_options), + Some(dir_options), ) .map_err(|err: Error| format_err!("unable to create rrdb stat dir - {}", err))?; diff --git a/proxmox-rrd/src/cache/journal.rs b/proxmox-rrd/src/cache/journal.rs index 67796a46..9e9f34d4 100644 --- a/proxmox-rrd/src/cache/journal.rs +++ b/proxmox-rrd/src/cache/journal.rs @@ -116,7 +116,7 @@ impl JournalState { &journal_path, flags, &[], - self.config.file_options.clone(), + self.config.file_options, false, )?; Ok(BufReader::new(journal)) @@ -131,7 +131,7 @@ impl JournalState { &journal_path, flags, &[], - config.file_options.clone(), + config.file_options, false, )?; Ok(journal) diff --git a/proxmox-rrd/src/cache/rrd_map.rs b/proxmox-rrd/src/cache/rrd_map.rs index 9fa0d44e..bac60a4a 100644 --- a/proxmox-rrd/src/cache/rrd_map.rs +++ b/proxmox-rrd/src/cache/rrd_map.rs @@ -51,8 +51,8 @@ impl RRDMap { None => { create_path( path.parent().unwrap(), - Some(self.config.dir_options.clone()), - Some(self.config.dir_options.clone()), + Some(self.config.dir_options), + Some(self.config.dir_options), )?; (self.create_rrd_cb)(dst) @@ -82,7 +82,7 @@ impl RRDMap { if let Some(rrd) = self.map.get(rel_path) { let mut path = self.config.basedir.clone(); path.push(rel_path); - rrd.save(&path, self.config.file_options.clone(), true) + rrd.save(&path, self.config.file_options, true) } else { bail!("rrd file {} not loaded", rel_path); } diff --git a/proxmox-schema/src/upid.rs b/proxmox-schema/src/upid.rs index bbd4b0b3..ce51bf1e 100644 --- a/proxmox-schema/src/upid.rs +++ b/proxmox-schema/src/upid.rs @@ -191,7 +191,7 @@ fn unescape_id(text: &str) -> Result<String, Error> { } let h1 = hex_digit(i[2])?; let h0 = hex_digit(i[3])?; - data.push(h1 << 4 | h0); + data.push((h1 << 4) | h0); i = &i[4..] } else if next == b'-' { data.push(b'/'); diff --git a/proxmox-shared-cache/src/lib.rs b/proxmox-shared-cache/src/lib.rs index 893808f5..71a82cc9 100644 --- a/proxmox-shared-cache/src/lib.rs +++ b/proxmox-shared-cache/src/lib.rs @@ -127,7 +127,7 @@ impl SharedCache { proxmox_sys::fs::replace_file( &self.path, new_content.as_bytes(), - self.create_options.clone(), + self.create_options, true, )?; @@ -137,7 +137,7 @@ impl SharedCache { /// Removes all items from the cache. pub fn delete(&self, lock_timeout: Duration) -> Result<(), Error> { let _lock = self.lock(lock_timeout)?; - proxmox_sys::fs::replace_file(&self.path, &[], self.create_options.clone(), true)?; + proxmox_sys::fs::replace_file(&self.path, &[], self.create_options, true)?; Ok(()) } @@ -149,7 +149,7 @@ impl SharedCache { lockfile_path, lock_timeout, true, - self.create_options.clone(), + self.create_options, ) } } @@ -180,8 +180,8 @@ mod tests { proxmox_sys::fs::create_path( &path, - Some(dir_options.clone()), - Some(dir_options.clone()), + Some(dir_options), + Some(dir_options), ) .unwrap(); diff --git a/proxmox-sys/src/logrotate.rs b/proxmox-sys/src/logrotate.rs index 8759325c..a995fab1 100644 --- a/proxmox-sys/src/logrotate.rs +++ b/proxmox-sys/src/logrotate.rs @@ -64,7 +64,7 @@ impl LogRotate { options: &CreateOptions, ) -> Result<(), Error> { let mut source = File::open(source_path)?; - let (fd, tmp_path) = make_tmp_file(target_path, options.clone())?; + let (fd, tmp_path) = make_tmp_file(target_path, *options)?; let target = unsafe { File::from_raw_fd(fd.into_raw_fd()) }; let mut encoder = match zstd::stream::write::Encoder::new(target, 0) { Ok(encoder) => encoder, diff --git a/proxmox-sys/src/systemd.rs b/proxmox-sys/src/systemd.rs index 002b27a9..6fe11e16 100644 --- a/proxmox-sys/src/systemd.rs +++ b/proxmox-sys/src/systemd.rs @@ -90,7 +90,7 @@ fn unescape_unit_do(text: &str) -> Result<Vec<u8>, Error> { } let h1 = parse_hex_digit(i[2])?; let h0 = parse_hex_digit(i[3])?; - data.push(h1 << 4 | h0); + data.push((h1 << 4) | h0); i = &i[4..] } else if next == b'-' { data.push(b'/'); diff --git a/proxmox-systemd/src/escape.rs b/proxmox-systemd/src/escape.rs index f73beed3..392907bc 100644 --- a/proxmox-systemd/src/escape.rs +++ b/proxmox-systemd/src/escape.rs @@ -97,7 +97,7 @@ fn unescape_unit_do(text: &str) -> Result<Vec<u8>, UnescapeError> { } let h1 = parse_hex_digit(i[2])?; let h0 = parse_hex_digit(i[3])?; - data.push(h1 << 4 | h0); + data.push((h1 << 4) | h0); i = &i[4..] } else if next == b'-' { data.push(b'/'); diff --git a/proxmox-uuid/src/lib.rs b/proxmox-uuid/src/lib.rs index 968f3878..5fa635d4 100644 --- a/proxmox-uuid/src/lib.rs +++ b/proxmox-uuid/src/lib.rs @@ -103,25 +103,25 @@ impl Uuid { return Err(UuidError); } for i in 0..4 { - uuid[i] = hex_digit(src[2 * i])? << 4 | hex_digit(src[2 * i + 1])?; + uuid[i] = (hex_digit(src[2 * i])? << 4) | hex_digit(src[2 * i + 1])?; } for i in 4..6 { - uuid[i] = hex_digit(src[2 * i + 1])? << 4 | hex_digit(src[2 * i + 2])?; + uuid[i] = (hex_digit(src[2 * i + 1])? << 4) | hex_digit(src[2 * i + 2])?; } for i in 6..8 { - uuid[i] = hex_digit(src[2 * i + 2])? << 4 | hex_digit(src[2 * i + 3])?; + uuid[i] = (hex_digit(src[2 * i + 2])? << 4) | hex_digit(src[2 * i + 3])?; } for i in 8..10 { - uuid[i] = hex_digit(src[2 * i + 3])? << 4 | hex_digit(src[2 * i + 4])?; + uuid[i] = (hex_digit(src[2 * i + 3])? << 4) | hex_digit(src[2 * i + 4])?; } for i in 10..16 { - uuid[i] = hex_digit(src[2 * i + 4])? << 4 | hex_digit(src[2 * i + 5])?; + uuid[i] = (hex_digit(src[2 * i + 4])? << 4) | hex_digit(src[2 * i + 5])?; } } else if src.len() == 32 { let uuid: &mut [u8] = unsafe { &mut (*uuid)[..] }; let src = src.as_bytes(); for i in 0..16 { - uuid[i] = hex_digit(src[2 * i])? << 4 | hex_digit(src[2 * i + 1])?; + uuid[i] = (hex_digit(src[2 * i])? << 4) | hex_digit(src[2 * i + 1])?; } } else { return Err(UuidError); -- 2.39.5 _______________________________________________ pbs-devel mailing list pbs-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel