Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

flag parameters: check magic constants

This patch adds test that ensure the boundary conditions for the various
constants introduced in the previous patches is met. No code is generated.

[akpm@linux-foundation.org: fix alpha]
Signed-off-by: Ulrich Drepper <drepper@redhat.com>
Acked-by: Davide Libenzi <davidel@xmailserver.org>
Cc: Michael Kerrisk <mtk.manpages@googlemail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Ulrich Drepper and committed by
Linus Torvalds
e38b36f3 510df2dd

+25
+4
fs/eventfd.c
··· 203 203 int fd; 204 204 struct eventfd_ctx *ctx; 205 205 206 + /* Check the EFD_* constants for consistency. */ 207 + BUILD_BUG_ON(EFD_CLOEXEC != O_CLOEXEC); 208 + BUILD_BUG_ON(EFD_NONBLOCK != O_NONBLOCK); 209 + 206 210 if (flags & ~(EFD_CLOEXEC | EFD_NONBLOCK)) 207 211 return -EINVAL; 208 212
+3
fs/eventpoll.c
··· 1051 1051 int error, fd = -1; 1052 1052 struct eventpoll *ep; 1053 1053 1054 + /* Check the EPOLL_* constant for consistency. */ 1055 + BUILD_BUG_ON(EPOLL_CLOEXEC != O_CLOEXEC); 1056 + 1054 1057 if (flags & ~EPOLL_CLOEXEC) 1055 1058 return -EINVAL; 1056 1059
+4
fs/inotify_user.c
··· 574 574 struct file *filp; 575 575 int fd, ret; 576 576 577 + /* Check the IN_* constants for consistency. */ 578 + BUILD_BUG_ON(IN_CLOEXEC != O_CLOEXEC); 579 + BUILD_BUG_ON(IN_NONBLOCK != O_NONBLOCK); 580 + 577 581 if (flags & ~(IN_CLOEXEC | IN_NONBLOCK)) 578 582 return -EINVAL; 579 583
+4
fs/signalfd.c
··· 211 211 sigset_t sigmask; 212 212 struct signalfd_ctx *ctx; 213 213 214 + /* Check the SFD_* constants for consistency. */ 215 + BUILD_BUG_ON(SFD_CLOEXEC != O_CLOEXEC); 216 + BUILD_BUG_ON(SFD_NONBLOCK != O_NONBLOCK); 217 + 214 218 if (flags & ~(SFD_CLOEXEC | SFD_NONBLOCK)) 215 219 return -EINVAL; 216 220
+4
fs/timerfd.c
··· 184 184 int ufd; 185 185 struct timerfd_ctx *ctx; 186 186 187 + /* Check the TFD_* constants for consistency. */ 188 + BUILD_BUG_ON(TFD_CLOEXEC != O_CLOEXEC); 189 + BUILD_BUG_ON(TFD_NONBLOCK != O_NONBLOCK); 190 + 187 191 if (flags & ~(TFD_CLOEXEC | TFD_NONBLOCK)) 188 192 return -EINVAL; 189 193 if (clockid != CLOCK_MONOTONIC &&
+6
net/socket.c
··· 1222 1222 struct socket *sock; 1223 1223 int flags; 1224 1224 1225 + /* Check the SOCK_* constants for consistency. */ 1226 + BUILD_BUG_ON(SOCK_CLOEXEC != O_CLOEXEC); 1227 + BUILD_BUG_ON((SOCK_MAX | SOCK_TYPE_MASK) != SOCK_TYPE_MASK); 1228 + BUILD_BUG_ON(SOCK_CLOEXEC & SOCK_TYPE_MASK); 1229 + BUILD_BUG_ON(SOCK_NONBLOCK & SOCK_TYPE_MASK); 1230 + 1225 1231 flags = type & ~SOCK_TYPE_MASK; 1226 1232 if (flags & ~(SOCK_CLOEXEC | SOCK_NONBLOCK)) 1227 1233 return -EINVAL;