]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
btrfs: define the AUTO_KFREE/AUTO_KVFREE helper macros
authorMiquel Sabaté Solà <mssola@mssola.com>
Fri, 24 Oct 2025 10:21:41 +0000 (12:21 +0200)
committerDavid Sterba <dsterba@suse.com>
Mon, 24 Nov 2025 21:34:51 +0000 (22:34 +0100)
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>
fs/btrfs/misc.h

index 60f9b000d644bb33344433eb5627153648566009..a82032c66ccd3a9f31daf38eecf896a1b665e889 100644 (file)
 #include <linux/rbtree.h>
 #include <linux/bio.h>
 
+/*
+ * Convenience macros to define a pointer with the __free(kfree) and
+ * __free(kvfree) cleanup attributes and initialized to NULL.
+ */
+#define AUTO_KFREE(name)       *name __free(kfree) = NULL
+#define AUTO_KVFREE(name)      *name __free(kvfree) = NULL
+
 /*
  * Enumerate bits using enum autoincrement. Define the @name as the n-th bit.
  */