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

tests/set_mempolicy.c

index c7364bd711173b3f5180441cee9dbe48459e4086..3802eafa84ea76e56f6a2b8537098faeb50cb9c1 100644 (file)
@@ -58,7 +58,7 @@ print_nodes(const unsigned long maxnode, unsigned int offset)
        memset(nodemask, 0, size);
 
        long rc = syscall(__NR_set_mempolicy, 0, nodemask, maxnode);
-       int saved_errno = errno;
+       const char *errstr = sprintrc(rc);
 
        fputs("set_mempolicy(MPOL_DEFAULT, ", stdout);
 
@@ -88,13 +88,7 @@ print_nodes(const unsigned long maxnode, unsigned int offset)
                        printf("[]");
        }
 
-       printf(", %lu) = ", maxnode);
-       if (rc) {
-               errno = saved_errno;
-               printf("%ld %s (%m)\n", rc, errno2name());
-       } else {
-               puts("0");
-       }
+       printf(", %lu) = %s\n", maxnode, errstr);
 }
 
 static void
@@ -135,8 +129,8 @@ main(void)
        const unsigned long *nodemask = (void *) 0xfacefeedfffffffe;
        const unsigned long maxnode = (unsigned long) 0xcafef00dbadc0ded;
        long rc = syscall(__NR_set_mempolicy, 1, nodemask, maxnode);
-       printf("set_mempolicy(MPOL_PREFERRED, %p, %lu) = %ld %s (%m)\n",
-              nodemask, maxnode, rc, errno2name());
+       printf("set_mempolicy(MPOL_PREFERRED, %p, %lu) = %s\n",
+              nodemask, maxnode, sprintrc(rc));
 
        test_offset(0);
        test_offset(1);