public inbox for pbs-devel@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
  2026-04-16 10:20 ` applied: " Fabian Grünbichler
  0 siblings, 1 reply; 2+ messages 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] 2+ messages in thread

* applied: [PATCH proxmox-backup] config: lock guard: label BackupLockGuard by must_use attribute
  2026-04-15  8:31 [PATCH proxmox-backup] config: lock guard: label BackupLockGuard by must_use attribute Christian Ebner
@ 2026-04-16 10:20 ` Fabian Grünbichler
  0 siblings, 0 replies; 2+ messages in thread
From: Fabian Grünbichler @ 2026-04-16 10:20 UTC (permalink / raw)
  To: pbs-devel, Christian Ebner


On Wed, 15 Apr 2026 10:31:45 +0200, Christian Ebner wrote:
> 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.
> 
> [...]

Applied, thanks!

[1/1] config: lock guard: label BackupLockGuard by must_use attribute
      commit: 0ab2cc729e7e95f13b6d9a0b9caf174dd0d2d1c6

Best regards,
-- 
Fabian Grünbichler <f.gruenbichler@proxmox.com>




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-04-16 10:20 UTC | newest]

Thread overview: 2+ messages (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
2026-04-16 10:20 ` applied: " Fabian Grünbichler

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal