diff options
| author | Miquel Sabaté Solà <mssola@mssola.com> | 2025-10-24 12:21:41 +0200 |
|---|---|---|
| committer | David Sterba <dsterba@suse.com> | 2025-11-24 22:34:51 +0100 |
| commit | d00cbce0a7d5de5fc31bf60abd59b44d36806b6e (patch) | |
| tree | 7683a7044e4ffa0e5889c38e6f2e23db06cff836 /fs | |
| parent | 285c3ab28eed282af70aba02d7708dea245bfc4b (diff) | |
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>
Diffstat (limited to 'fs')
| -rw-r--r-- | fs/btrfs/misc.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/fs/btrfs/misc.h b/fs/btrfs/misc.h index 60f9b000d644..a82032c66ccd 100644 --- a/fs/btrfs/misc.h +++ b/fs/btrfs/misc.h @@ -14,6 +14,13 @@ #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. */ #define ENUM_BIT(name) \ |