]> granicus.if.org Git - strace/blobdiff - tests/seccomp-filter-v.c
tests: extend TEST_NETLINK_OBJECT macro
[strace] / tests / seccomp-filter-v.c
index ef69c0dcac7b272c182e309804544de51c1b29af..e419c6cb74262912d14d3e0963ab0a2153b88717 100644 (file)
@@ -2,6 +2,7 @@
  * Check verbose decoding of seccomp SECCOMP_SET_MODE_FILTER.
  *
  * Copyright (c) 2015-2016 Dmitry V. Levin <ldv@altlinux.org>
+ * Copyright (c) 2016-2017 The strace developers.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -32,7 +33,7 @@
 #include <errno.h>
 #include <stddef.h>
 #include <stdio.h>
-#include <sys/syscall.h>
+#include <asm/unistd.h>
 #include <unistd.h>
 
 #ifdef HAVE_PRCTL
@@ -41,9 +42,7 @@
 #ifdef HAVE_LINUX_SECCOMP_H
 # include <linux/seccomp.h>
 #endif
-#ifdef HAVE_LINUX_FILTER_H
-# include <linux/filter.h>
-#endif
+#include <linux/filter.h>
 
 #if defined __NR_seccomp \
  && defined PR_SET_NO_NEW_PRIVS \
@@ -90,10 +89,6 @@ static const struct sock_filter filter_c[] = {
        SOCK_FILTER_KILL_PROCESS
 };
 
-#ifndef BPF_MAXINSNS
-# define BPF_MAXINSNS 4096
-#endif
-
 int
 main(void)
 {
@@ -105,7 +100,7 @@ main(void)
                tail_memdup(filter_c, sizeof(filter_c));
        struct sock_filter *const big_filter =
                tail_alloc(sizeof(*big_filter) * (BPF_MAXINSNS + 1));
-       struct sock_fprog *const prog = tail_alloc(sizeof(*prog));
+       TAIL_ALLOC_OBJECT_CONST_PTR(struct sock_fprog, prog);
 
        int fds[2];
        if (pipe(fds))
@@ -145,7 +140,7 @@ main(void)
        for (i = 0; i < BPF_MAXINSNS; ++i) {
                if (i)
                        tprintf(", ");
-               switch(BPF_CLASS(i)) {
+               switch (BPF_CLASS(i)) {
                case BPF_LD:
                        tprintf("BPF_STMT(BPF_LD|BPF_W|BPF_IMM, %#x)", i << 16);
                        break;