mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
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>
This commit is contained in:
parent
510df2dd48
commit
e38b36f325
6 changed files with 25 additions and 0 deletions
|
@ -1222,6 +1222,12 @@ asmlinkage long sys_socket(int family, int type, int protocol)
|
|||
struct socket *sock;
|
||||
int flags;
|
||||
|
||||
/* Check the SOCK_* constants for consistency. */
|
||||
BUILD_BUG_ON(SOCK_CLOEXEC != O_CLOEXEC);
|
||||
BUILD_BUG_ON((SOCK_MAX | SOCK_TYPE_MASK) != SOCK_TYPE_MASK);
|
||||
BUILD_BUG_ON(SOCK_CLOEXEC & SOCK_TYPE_MASK);
|
||||
BUILD_BUG_ON(SOCK_NONBLOCK & SOCK_TYPE_MASK);
|
||||
|
||||
flags = type & ~SOCK_TYPE_MASK;
|
||||
if (flags & ~(SOCK_CLOEXEC | SOCK_NONBLOCK))
|
||||
return -EINVAL;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue