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

tests/move_pages.c

index a5818b0b81ecb086162d04b867e9a8b06adf1147..3be7446ae3814f10a66647b1d1e4fd35791d3902 100644 (file)
@@ -140,25 +140,19 @@ print_stat_pages(const unsigned long pid, const unsigned long count,
 
        long rc = syscall(__NR_move_pages,
                          pid, count, pages, NULL, status, flags);
+       const char *errstr = sprintrc(rc);
+       printf("move_pages(%d, %lu, ", (int) pid, count);
+       print_page_array(pages, count, 0);
+       printf(", NULL, ");
        if (rc) {
-               int saved_errno = errno;
-               printf("move_pages(%d, %lu, ", (int) pid, count);
-               print_page_array(pages, count, 0);
-               printf(", NULL, ");
                if (count)
                        printf("%p", status);
                else
                        printf("[]");
-               errno = saved_errno;
-               printf(", MPOL_MF_MOVE) = %ld %s (%m)\n",
-                      rc, errno2name());
        } else {
-               printf("move_pages(%d, %lu, ", (int) pid, count);
-               print_page_array(pages, count, 0);
-               printf(", NULL, ");
                print_status_array(status, count);
-               printf(", MPOL_MF_MOVE) = 0\n");
        }
+       printf(", MPOL_MF_MOVE) = %s\n", errstr);
 }
 
 static void
@@ -174,7 +168,7 @@ print_move_pages(const unsigned long pid,
 
        long rc = syscall(__NR_move_pages,
                          pid, count, pages, nodes, status, flags);
-       int saved_errno = errno;
+       const char *errstr = sprintrc(rc);
        printf("move_pages(%d, %lu, ", (int) pid, count);
        print_page_array(pages, count, offset);
        printf(", ");
@@ -184,13 +178,7 @@ print_move_pages(const unsigned long pid,
                printf("%p", status);
        else
                printf("[]");
-       printf(", MPOL_MF_MOVE_ALL) = ");
-       if (rc) {
-               errno = saved_errno;
-               printf("%ld %s (%m)\n", rc, errno2name());
-       } else {
-               puts("0");
-       }
+       printf(", MPOL_MF_MOVE_ALL) = %s\n", errstr);
 }
 
 int