From: Dmitry V. Levin Date: Thu, 21 Apr 2016 21:20:31 +0000 (+0000) Subject: tests/seccomp-strict.c: cleanup X-Git-Tag: v4.12~325 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4483f628ab91ecafb7d5c2b8116d2f78a6f4af23;p=strace tests/seccomp-strict.c: cleanup * tests/seccomp-strict.c (main): Use errno2name, stop using assert. --- diff --git a/tests/seccomp-strict.c b/tests/seccomp-strict.c index f615aa18..c06f05aa 100644 --- a/tests/seccomp-strict.c +++ b/tests/seccomp-strict.c @@ -44,23 +44,25 @@ main(void) "seccomp(SECCOMP_SET_MODE_STRICT, 0, NULL) = 0\n"; static const char text2[] = "+++ exited with 0 +++\n"; const unsigned long addr = (unsigned long) 0xfacefeeddeadbeef; - int rc = 0; + long rc; - assert(syscall(__NR_seccomp, -1L, -1L, addr) == -1); - printf("seccomp(%#x /* SECCOMP_SET_MODE_??? */, %u, %#lx) = -1 %s (%m)\n", - -1, -1, addr, ENOSYS == errno ? "ENOSYS" : "EINVAL"); + rc = syscall(__NR_seccomp, -1L, -1L, addr); + printf("seccomp(%#x /* SECCOMP_SET_MODE_??? */, %u, %#lx)" + " = %ld %s (%m)\n", -1, -1, addr, rc, errno2name()); fflush(stdout); - if (syscall(__NR_seccomp, 0, 0, 0)) { - printf("seccomp(SECCOMP_SET_MODE_STRICT, 0, NULL) = -1 %s (%m)\n", - ENOSYS == errno ? "ENOSYS" : "EINVAL"); + rc = syscall(__NR_seccomp, 0, 0, 0); + if (rc) { + printf("seccomp(SECCOMP_SET_MODE_STRICT, 0, NULL)" + " = %ld %s (%m)\n", rc, errno2name()); fflush(stdout); + rc = 0; } else { /* * If kernel implementaton of SECCOMP_MODE_STRICT is buggy, * the following syscall will result to SIGKILL. */ - rc += write(1, text1, LENGTH_OF(text1)) != LENGTH_OF(text1); + rc = write(1, text1, LENGTH_OF(text1)) != LENGTH_OF(text1); } rc += write(1, text2, LENGTH_OF(text2)) != LENGTH_OF(text2);