diff mbox series

eventfd: add a BUILD_BUG_ON() to ensure consistency between EFD_SEMAPHORE and the uapi

Message ID tencent_0BAA2DEAF9208D49987457E6583F9BE79507@qq.com (mailing list archive)
State New
Headers show
Series eventfd: add a BUILD_BUG_ON() to ensure consistency between EFD_SEMAPHORE and the uapi | expand

Commit Message

Wen Yang Jan. 10, 2024, 3:47 p.m. UTC
From: Wen Yang <wenyang.linux@foxmail.com>

introduce a BUILD_BUG_ON to check that the EFD_SEMAPHORE is equal to its
definition in the uapi file, just like EFD_CLOEXEC and EFD_NONBLOCK.

Signed-off-by: Wen Yang <wenyang.linux@foxmail.com>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Christian Brauner <brauner@kernel.org>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Jan Kara <jack@suse.cz>
Cc: linux-fsdevel@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
---
 fs/eventfd.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Christian Brauner Jan. 11, 2024, 10:43 a.m. UTC | #1
On Wed, 10 Jan 2024 23:47:40 +0800, wenyang.linux@foxmail.com wrote:
> introduce a BUILD_BUG_ON to check that the EFD_SEMAPHORE is equal to its
> definition in the uapi file, just like EFD_CLOEXEC and EFD_NONBLOCK.
> 
> 

This isn't hugely useful tbh but it's not terrible either.

---

Applied to the vfs.misc branch of the vfs/vfs.git tree.
Patches in the vfs.misc branch should appear in linux-next soon.

Please report any outstanding bugs that were missed during review in a
new review to the original patch series allowing us to drop it.

It's encouraged to provide Acked-bys and Reviewed-bys even though the
patch has now been applied. If possible patch trailers will be updated.

Note that commit hashes shown below are subject to change due to rebase,
trailer updates or similar. If in doubt, please check the listed branch.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs.misc

[1/1] eventfd: add a BUILD_BUG_ON() to ensure consistency between EFD_SEMAPHORE and the uapi
      https://git.kernel.org/vfs/vfs/c/c3d48db389b7
diff mbox series

Patch

diff --git a/fs/eventfd.c b/fs/eventfd.c
index 93848573c877..c1f5d71e7197 100644
--- a/fs/eventfd.c
+++ b/fs/eventfd.c
@@ -502,6 +502,7 @@  static int do_eventfd(unsigned int count, int flags)
 	/* Check the EFD_* constants for consistency.  */
 	BUILD_BUG_ON(EFD_CLOEXEC != O_CLOEXEC);
 	BUILD_BUG_ON(EFD_NONBLOCK != O_NONBLOCK);
+	BUILD_BUG_ON(EFD_SEMAPHORE != (1 << 0));
 
 	if (flags & ~EFD_FLAGS_SET)
 		return -EINVAL;