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

tests/open.c

index 6e26cbe68862a32104567fcf7d821ad86abc1d7d..8987c5bf184cd6940dd4398b88ed56f30ac5b459 100644 (file)
@@ -38,25 +38,22 @@ int
 main(void)
 {
        static const char sample[] = "open.sample";
-       int fd = syscall(__NR_open, sample, O_RDONLY|O_CREAT, 0400);
 
-       if (fd < 0) {
-               printf("open(\"%s\", O_RDONLY|O_CREAT, 0400)"
-                      " = %d %s (%m)\n", sample, fd, errno2name());
-       } else {
-               printf("open(\"%s\", O_RDONLY|O_CREAT, 0400) = %d\n",
-                      sample, fd);
+       long fd = syscall(__NR_open, sample, O_RDONLY|O_CREAT, 0400);
+       printf("open(\"%s\", O_RDONLY|O_CREAT, 0400) = %s\n",
+              sample, sprintrc(fd));
+
+       if (fd != -1) {
                close(fd);
                if (unlink(sample))
                        perror_msg_and_fail("unlink");
 
                fd = syscall(__NR_open, sample, O_RDONLY);
-               printf("open(\"%s\", O_RDONLY) = %d %s (%m)\n",
-                      sample, fd, errno2name());
+               printf("open(\"%s\", O_RDONLY) = %s\n", sample, sprintrc(fd));
 
                fd = syscall(__NR_open, sample, O_WRONLY|O_NONBLOCK|0x80000000);
-               printf("open(\"%s\", O_WRONLY|O_NONBLOCK|0x80000000)"
-                      " = %d %s (%m)\n", sample, fd, errno2name());
+               printf("open(\"%s\", O_WRONLY|O_NONBLOCK|0x80000000) = %s\n",
+                      sample, sprintrc(fd));
        }
 
        puts("+++ exited with 0 +++");