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 F097E1FF16B for <inbox@lore.proxmox.com>; Thu, 6 Mar 2025 13:44:59 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 7D43E6025; Thu, 6 Mar 2025 13:44:50 +0100 (CET) From: Shannon Sterz <s.sterz@proxmox.com> To: pbs-devel@lists.proxmox.com Date: Thu, 6 Mar 2025 13:43:33 +0100 Message-Id: <20250306124349.288370-4-s.sterz@proxmox.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250306124349.288370-1-s.sterz@proxmox.com> References: <20250306124349.288370-1-s.sterz@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL -1.446 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 FSL_BULK_SIG 0.001 Bulk signature with no Unsubscribe KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RAZOR2_CF_RANGE_51_100 1.886 Razor2 gives confidence level above 50% RAZOR2_CHECK 0.922 Listed in Razor2 (http://razor.sf.net/) SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_SBL_A 0.1 Contains URL's A record listed in the Spamhaus SBL blocklist [185.199.111.153, 185.199.110.153] Subject: [pbs-devel] [PATCH proxmox 03/19] tree-wide: remove clone calls on types that are `Copy` 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> this resolves a clippy lint that checks that `clone()` isn't called on `Copy` types as that is unnecessary [1]. [1]: https://rust-lang.github.io/rust-clippy/master/index.html#clone_on_copy Signed-off-by: Shannon Sterz <s.sterz@proxmox.com> --- proxmox-log/src/file_logger.rs | 3 +-- proxmox-rest-server/src/worker_task.rs | 9 ++------- proxmox-rrd/src/cache.rs | 8 ++------ proxmox-rrd/src/cache/journal.rs | 18 ++++-------------- proxmox-rrd/src/cache/rrd_map.rs | 6 +++--- proxmox-shared-cache/src/lib.rs | 18 ++++-------------- proxmox-sys/src/logrotate.rs | 2 +- 7 files changed, 17 insertions(+), 47 deletions(-) diff --git a/proxmox-log/src/file_logger.rs b/proxmox-log/src/file_logger.rs index 1e67b450..39d16857 100644 --- a/proxmox-log/src/file_logger.rs +++ b/proxmox-log/src/file_logger.rs @@ -93,8 +93,7 @@ impl FileLogger { flags |= OFlag::O_EXCL; } - let file = - atomic_open_or_create_file(&file_name, flags, &[], options.file_opts.clone(), false)?; + let file = 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 24e2676e..9351bbee 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 9dd85a16..29d46ed5 100644 --- a/proxmox-rrd/src/cache.rs +++ b/proxmox-rrd/src/cache.rs @@ -66,12 +66,8 @@ impl Cache { let file_options = file_options.unwrap_or_default(); let dir_options = dir_options.unwrap_or_default(); - create_path( - &basedir, - Some(dir_options.clone()), - Some(dir_options.clone()), - ) - .map_err(|err: Error| format_err!("unable to create rrdb stat dir - {}", err))?; + create_path(&basedir, Some(dir_options), Some(dir_options)) + .map_err(|err: Error| format_err!("unable to create rrdb stat dir - {}", err))?; let config = Arc::new(CacheConfig { basedir, diff --git a/proxmox-rrd/src/cache/journal.rs b/proxmox-rrd/src/cache/journal.rs index c196b342..fe48f23b 100644 --- a/proxmox-rrd/src/cache/journal.rs +++ b/proxmox-rrd/src/cache/journal.rs @@ -112,13 +112,8 @@ impl JournalState { journal_path.push(RRD_JOURNAL_NAME); let flags = OFlag::O_CLOEXEC | OFlag::O_RDONLY; - let journal = atomic_open_or_create_file( - &journal_path, - flags, - &[], - self.config.file_options.clone(), - false, - )?; + let journal = + atomic_open_or_create_file(&journal_path, flags, &[], self.config.file_options, false)?; Ok(BufReader::new(journal)) } @@ -127,13 +122,8 @@ impl JournalState { journal_path.push(RRD_JOURNAL_NAME); let flags = OFlag::O_CLOEXEC | OFlag::O_WRONLY | OFlag::O_APPEND; - let journal = atomic_open_or_create_file( - &journal_path, - flags, - &[], - config.file_options.clone(), - false, - )?; + let journal = + atomic_open_or_create_file(&journal_path, flags, &[], 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 0ef61cfa..27ea8e6e 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-shared-cache/src/lib.rs b/proxmox-shared-cache/src/lib.rs index d0b2148a..65abc1ac 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(()) } @@ -145,12 +145,7 @@ impl SharedCache { fn lock(&self, lock_timeout: Duration) -> Result<File, Error> { let mut lockfile_path = self.path.clone(); lockfile_path.set_extension("lock"); - proxmox_sys::fs::open_file_locked( - lockfile_path, - lock_timeout, - true, - self.create_options.clone(), - ) + proxmox_sys::fs::open_file_locked(lockfile_path, lock_timeout, true, self.create_options) } } @@ -178,12 +173,7 @@ mod tests { .group(nix::unistd::Gid::effective()) .perm(nix::sys::stat::Mode::from_bits_truncate(0o700)); - proxmox_sys::fs::create_path( - &path, - Some(dir_options.clone()), - Some(dir_options.clone()), - ) - .unwrap(); + proxmox_sys::fs::create_path(&path, Some(dir_options), Some(dir_options)).unwrap(); let cache = SharedCache::new(path.join("somekey"), options, keep_old).unwrap(); Self { diff --git a/proxmox-sys/src/logrotate.rs b/proxmox-sys/src/logrotate.rs index 704a18ce..cb96974a 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, -- 2.39.5 _______________________________________________ pbs-devel mailing list pbs-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel