tree-wide: remove clone calls on types that are Copy

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>
This commit is contained in:
Shannon Sterz 2025-03-06 13:43:33 +01:00 committed by Wolfgang Bumiller
parent 2c07729ff3
commit d980c2229b
7 changed files with 17 additions and 47 deletions

View File

@ -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)
}

View File

@ -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)?;

View File

@ -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,

View File

@ -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)
}

View File

@ -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);
}

View File

@ -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 {

View File

@ -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,