[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251021142749.642956-3-mssola@mssola.com>
Date: Tue, 21 Oct 2025 16:27:47 +0200
From: Miquel Sabaté Solà <mssola@...ola.com>
To: linux-btrfs@...r.kernel.org
Cc: clm@...com,
dsterba@...e.com,
johannes.thumshirn@....com,
fdmanana@...e.com,
boris@....io,
wqu@...e.com,
neal@...pa.dev,
linux-kernel@...r.kernel.org,
Miquel Sabaté Solà <mssola@...ola.com>,
David Sterba <dsterba@...e.cz>
Subject: [PATCH 2/4] btrfs: define the AUTO_K(V)FREE_PTR helper macros
These are two simple macros which ensure that a pointer is initialized
to NULL and with the proper cleanup attribute for it.
Suggested-by: David Sterba <dsterba@...e.cz>
Signed-off-by: Miquel Sabaté Solà <mssola@...ola.com>
---
fs/btrfs/misc.h | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/fs/btrfs/misc.h b/fs/btrfs/misc.h
index 60f9b000d644..0e33327e70d9 100644
--- a/fs/btrfs/misc.h
+++ b/fs/btrfs/misc.h
@@ -13,6 +13,13 @@
#include <linux/rbtree.h>
#include <linux/bio.h>
+/*
+ * Convenient macros to define a pointer with the __free(kfree) and
+ * __free(kvfree) cleanup attributes and initialized to NULL.
+ */
+#define AUTO_KFREE_PTR(name) *name __free(kfree) = NULL
+#define AUTO_KVFREE_PTR(name) *name __free(kvfree) = NULL
+
/*
* Enumerate bits using enum autoincrement. Define the @name as the n-th bit.
*/
--
2.51.1
Powered by blists - more mailing lists