From: Miquel Sabaté Solà Date: Fri, 24 Oct 2025 10:21:41 +0000 (+0200) Subject: btrfs: define the AUTO_KFREE/AUTO_KVFREE helper macros X-Git-Tag: v6.19-rc1~167^2~69 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d00cbce0a7d5de5fc31bf60abd59b44d36806b6e;p=thirdparty%2Fkernel%2Flinux.git 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à Reviewed-by: David Sterba Signed-off-by: David Sterba --- diff --git a/fs/btrfs/misc.h b/fs/btrfs/misc.h index 60f9b000d644b..a82032c66ccd3 100644 --- a/fs/btrfs/misc.h +++ b/fs/btrfs/misc.h @@ -13,6 +13,13 @@ #include #include +/* + * 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. */