From: Wen Yang Date: Wed, 10 Jan 2024 15:47:40 +0000 (+0800) Subject: eventfd: add a BUILD_BUG_ON() to ensure consistency between EFD_SEMAPHORE and the... X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=6b6ec4ca4e33d797f887cb2d7ecf365b652b338c;p=linux.git eventfd: add a BUILD_BUG_ON() to ensure consistency between EFD_SEMAPHORE and the uapi 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 Link: https://lore.kernel.org/r/tencent_0BAA2DEAF9208D49987457E6583F9BE79507@qq.com Cc: Alexander Viro Cc: Christian Brauner Cc: Jens Axboe Cc: Jan Kara Cc: Cc: Signed-off-by: Christian Brauner --- diff --git a/fs/eventfd.c b/fs/eventfd.c index ad8186d47ba76..0252b71099fbc 100644 --- a/fs/eventfd.c +++ b/fs/eventfd.c @@ -383,6 +383,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;