]> git.ipfire.org Git - thirdparty/linux.git/commit
file: add take_fd() cleanup helper
authorChristian Brauner <brauner@kernel.org>
Thu, 27 Jun 2024 14:11:39 +0000 (16:11 +0200)
committerChristian Brauner <brauner@kernel.org>
Fri, 28 Jun 2024 08:36:45 +0000 (10:36 +0200)
commitc6269149cbf7053272d918101981869438ff7c1e
tree56268222b9012639dff71b6a54f5e756a82ed3cc
parentff2c570ef7eaa9ded58e7a02dd7a68874a897508
file: add take_fd() cleanup helper

Add a helper that returns the file descriptor and ensures that the old
variable contains a negative value. This makes it easy to rely on
CLASS(get_unused_fd).

Link: https://lore.kernel.org/r/20240627-work-pidfs-v1-1-7e9ab6cc3bb1@kernel.org
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>
include/linux/cleanup.h
include/linux/file.h