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

tests/openat.c

index 3bd6b000455db30b6a014555c78aad4b46443e54..1d6765cf6a0a022b450c4964a2dd20db987a04d8 100644 (file)
@@ -38,20 +38,19 @@ int
 main(void)
 {
        static const char sample[] = "openat.sample";
-       int fd = syscall(__NR_openat, -100, sample, O_RDONLY|O_CREAT, 0400);
-       if (fd == -1) {
-               printf("openat(AT_FDCWD, \"%s\", O_RDONLY|O_CREAT, 0400)"
-                      " = -1 %s (%m)\n", sample, errno2name());
-       } else {
-               printf("openat(AT_FDCWD, \"%s\", O_RDONLY|O_CREAT, 0400)"
-                      " = %d\n", sample, fd);
+
+       long fd = syscall(__NR_openat, -100, sample, O_RDONLY|O_CREAT, 0400);
+       printf("openat(AT_FDCWD, \"%s\", O_RDONLY|O_CREAT, 0400) = %s\n",
+              sample, sprintrc(fd));
+
+       if (fd != -1) {
                close(fd);
                if (unlink(sample) == -1)
                        perror_msg_and_fail("unlink");
 
                fd = syscall(__NR_openat, -100, sample, O_RDONLY);
-               printf("openat(AT_FDCWD, \"%s\", O_RDONLY) = %d %s (%m)\n",
-                      sample, fd, errno2name());
+               printf("openat(AT_FDCWD, \"%s\", O_RDONLY) = %s\n",
+                      sample, sprintrc(fd));
        }
 
        puts("+++ exited with 0 +++");