]> granicus.if.org Git - strace/commitdiff
tests/pwritev.c: use errno2name
authorDmitry V. Levin <ldv@altlinux.org>
Thu, 21 Apr 2016 21:16:02 +0000 (21:16 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Thu, 21 Apr 2016 22:05:56 +0000 (22:05 +0000)
tests/pwritev.c

index b0ecfe64765a46f16764d0bfb731965e054e3e0a..6bfd58ed9a95d8e63830986c3b48f52fb0079a30 100644 (file)
@@ -99,6 +99,7 @@ main(void)
        tail_alloc(1);
 
        const off_t offset = 0xdefaceddeadbeefLL;
+       long rc;
        int written = 0;
        for (i = 0; i < LEN; ++i) {
                written += iov[i].iov_len;
@@ -112,33 +113,30 @@ main(void)
 
        for (i = 0; i <= LEN; ++i) {
                unsigned int n = LEN + 1 - i;
-               if (pwritev(0, iov + i, n, offset + LEN + i) != -1)
-                       perror_msg_and_fail("pwritev");
                fputs("pwritev(0, ", stdout);
                print_iovec(iov + i, n, LEN - i);
-               printf(", %u, %lld) = -1 %s (%m)\n",
-                      n, (long long) offset + LEN + i,
-                      errno2name());
+               rc = pwritev(0, iov + i, n, offset + LEN + i);
+               printf(", %u, %lld) = %ld %s (%m)\n",
+                      n, (long long) offset + LEN + i, rc, errno2name());
        }
 
        iov->iov_base = iov + LEN * 2;
-       if (pwritev(0, iov, 1, -1) != -1)
-               perror_msg_and_fail("pwritev");
-       printf("pwritev(0, [{%p, %d}], 1, -1) = -1 EINVAL (%m)\n",
-              iov->iov_base, LEN);
+       rc = pwritev(0, iov, 1, -1);
+       printf("pwritev(0, [{%p, %d}], 1, -1) = %ld %s (%m)\n",
+              iov->iov_base, LEN, rc, errno2name());
 
        iov += LEN;
-       if (pwritev(0, iov, 42, -2) != -1)
-               perror_msg_and_fail("pwritev");
-       printf("pwritev(0, %p, 42, -2) = -1 EINVAL (%m)\n", iov);
+       rc = pwritev(0, iov, 42, -2);
+       printf("pwritev(0, %p, 42, -2) = %ld %s (%m)\n",
+              iov, rc, errno2name());
 
-       if (pwritev(0, NULL, 1, -3) != -1)
-               perror_msg_and_fail("pwritev");
-       printf("pwritev(0, NULL, 1, -3) = -1 EINVAL (%m)\n");
+       rc = pwritev(0, NULL, 1, -3);
+       printf("pwritev(0, NULL, 1, -3) = %ld %s (%m)\n",
+              rc, errno2name());
 
-       if (pwritev(0, NULL, 0, -4) != -1)
-               perror_msg_and_fail("pwritev");
-       printf("pwritev(0, [], 0, -4) = -1 EINVAL (%m)\n");
+       rc = pwritev(0, NULL, 0, -4);
+       printf("pwritev(0, [], 0, -4) = %ld %s (%m)\n",
+              rc, errno2name());
 
        puts("+++ exited with 0 +++");
        return 0;