Skip to content

Commit 32e4a9d

Browse files
mssolakdave
authored andcommitted
btrfs: define the AUTO_KFREE/AUTO_KVFREE helper macros
These are two simple macros which ensure that a pointer is initialized to NULL and with the proper cleanup attribute for it. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent d37e411 commit 32e4a9d

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

fs/btrfs/misc.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@
1313
#include <linux/rbtree.h>
1414
#include <linux/bio.h>
1515

16+
/*
17+
* Convenience macros to define a pointer with the __free(kfree) and
18+
* __free(kvfree) cleanup attributes and initialized to NULL.
19+
*/
20+
#define AUTO_KFREE(name) *name __free(kfree) = NULL
21+
#define AUTO_KVFREE(name) *name __free(kvfree) = NULL
22+
1623
/*
1724
* Enumerate bits using enum autoincrement. Define the @name as the n-th bit.
1825
*/

0 commit comments

Comments
 (0)