all lists on lists.proxmox.com
 help / color / mirror / Atom feed
* [PATCH proxmox-backup] config: lock guard: label BackupLockGuard by must_use attribute
@ 2026-04-15  8:31 Christian Ebner
  0 siblings, 0 replies; only message in thread
From: Christian Ebner @ 2026-04-15  8:31 UTC (permalink / raw)
  To: pbs-devel

The BackupLockGuard is used to store the open file descriptor of a
flocked file. Once dropped, the file lock is release.

Since not binding the BackupLockGuard to a variable will result in
dropping of the struct and therefore immediate unlocking of the file,
set the must_use attribute with a meaningful description to get
clippy warnings for this.

Suggested-by: Daniel Kral <d.kral@proxmox.com>
Suggested-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
---
 pbs-config/src/lib.rs | 1 +
 1 file changed, 1 insertion(+)

diff --git a/pbs-config/src/lib.rs b/pbs-config/src/lib.rs
index 18b27d23a..88a31904f 100644
--- a/pbs-config/src/lib.rs
+++ b/pbs-config/src/lib.rs
@@ -59,6 +59,7 @@ pub fn priv_user() -> Result<nix::unistd::User, Error> {
     }
 }
 
+#[must_use = "lock guard must be used to keep file locked"]
 pub struct BackupLockGuard {
     file: Option<std::fs::File>,
     // TODO: Remove `_legacy_dir` with PBS 5
-- 
2.47.3





^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-04-15  8:32 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-04-15  8:31 [PATCH proxmox-backup] config: lock guard: label BackupLockGuard by must_use attribute Christian Ebner

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal