summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorChristian Brauner <brauner@kernel.org>2026-09-17 11:09:43 +0200
committerChristian Brauner <brauner@kernel.org>2026-09-23 09:27:44 +0200
commitcba449b765b39c0f71914bf81c04d96dd457248c (patch)
treec6fdbaf3b568b154c8e708dba7219b93565d9a15 /include/linux
parent30ce4b073efc0ac77fe017b1e7cb49658c62a09d (diff)
file: declare the FD_PREPARE() variable with __cleanup() directly
The whole CLASS_INIT() detour isn't needed. Use __cleanup() directly and give the destructor a private name. No functional changes. Link: https://patch.msgid.link/20260917-work-file-fd_prepare-v1-2-b87534ca49f3@kernel.org Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/file.h9
1 files changed, 3 insertions, 6 deletions
diff --git a/include/linux/file.h b/include/linux/file.h
index 2b864f457211..926cc58d0b7f 100644
--- a/include/linux/file.h
+++ b/include/linux/file.h
@@ -146,9 +146,6 @@ struct fd_prepare {
struct file *__file; /* do not access directly */
};
-/* Typedef for fd_prepare cleanup guards. */
-typedef struct fd_prepare class_fd_prepare_t;
-
/*
* Accessors for fd_prepare class members.
* _Generic() is used for zero-cost type safety.
@@ -160,7 +157,7 @@ typedef struct fd_prepare class_fd_prepare_t;
(_Generic((_fdf), struct fd_prepare: (_fdf).__file))
/* Do not use directly. */
-static __always_inline void class_fd_prepare_destructor(const struct fd_prepare *fdf)
+static __always_inline void __fd_prepare_cleanup(const struct fd_prepare *fdf)
{
if (unlikely(fdf->__fd >= 0)) {
put_unused_fd(fdf->__fd);
@@ -199,10 +196,10 @@ static __always_inline struct fd_prepare __fd_prepare(int fd, struct file *file)
* @_file_owned: struct file to take ownership of (can be expression)
*/
#define FD_PREPARE(_fdf, _fd_flags, _file_owned) \
- CLASS_INIT(fd_prepare, _fdf, ({ \
+ struct fd_prepare _fdf __cleanup(__fd_prepare_cleanup) = ({ \
int __fd = get_unused_fd_flags(_fd_flags); \
__fd_prepare(__fd, __fd < 0 ? NULL : (_file_owned)); \
- }))
+ })
/* Do not use directly. */
static __always_inline int __fd_publish(struct fd_prepare *fdf)