]> granicus.if.org Git - strace/commitdiff
tests: use sprintrc in mlock.test
authorDmitry V. Levin <ldv@altlinux.org>
Sun, 4 Sep 2016 22:22:37 +0000 (22:22 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Mon, 5 Sep 2016 15:58:35 +0000 (15:58 +0000)
* tests/mlock.c (main): Use sprintrc.

tests/mlock.c

index a47879a7556f6889ac0ba1a579e945799e8173a6..be962e241a9cbb3709259ffc2e757c15c183767b 100644 (file)
@@ -6,25 +6,17 @@
 # include <stdio.h>
 # include <unistd.h>
 
-const int size = 1024;
-
 int
 main(void)
 {
+       const int size = 1024;
        const char *addr = tail_alloc(size);
-       if (syscall(__NR_mlock, addr, size) == 0) {
-               printf("mlock(%p, %d) = 0\n", addr, size);
-       } else {
-               printf("mlock(%p, %d) = -1 %s (%m)\n",
-                      addr, size, errno2name());
-       }
-
-       if (syscall(__NR_munlock, addr, size) == 0) {
-               printf("munlock(%p, %d) = 0\n", addr, size);
-       } else {
-               printf("munlock(%p, %d) = -1 %s (%m)\n",
-                      addr, size, errno2name());
-       }
+
+       long rc = syscall(__NR_mlock, addr, size);
+       printf("mlock(%p, %d) = %s\n", addr, size, sprintrc(rc));
+
+       rc = syscall(__NR_munlock, addr, size);
+       printf("munlock(%p, %d) = %s\n", addr, size, sprintrc(rc));
 
        puts("+++ exited with 0 +++");
        return 0;