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

index f769f6e978fe256d9175ea9850632f10ee5b0bbf..e7f9fbedae38e9d80014c9adb4ddc5f65cded57d 100644 (file)
@@ -39,29 +39,20 @@ int
 main(void)
 {
        static const char sample[] = "openat.sample";
-       int fd;
-
-       fd = syscall(__NR_openat, -100, sample, O_RDONLY|O_CREAT, 0400);
+       int fd = syscall(__NR_openat, -100, sample, O_RDONLY|O_CREAT, 0400);
        if (fd == -1) {
-               if (errno == ENOSYS) {
-                       printf("openat(AT_FDCWD, \"%s\", O_RDONLY|O_CREAT"
-                              ", 0400) = -1 ENOSYS (%m)\n", sample);
-               } else {
-                       perror_msg_and_fail("openat");
-               }
+               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);
+               printf("openat(AT_FDCWD, \"%s\", O_RDONLY|O_CREAT, 0400)"
+                      " = %d\n", sample, fd);
                close(fd);
                if (unlink(sample) == -1)
                        perror_msg_and_fail("unlink");
+
                fd = syscall(__NR_openat, -100, sample, O_RDONLY);
-               if (fd == -1 && errno == ENOENT) {
-                       printf("openat(AT_FDCWD, \"%s\", O_RDONLY) = %d ENOENT"
-                              " (%m)\n", sample, fd);
-               } else {
-                       perror_msg_and_fail("openat");
-               }
+               printf("openat(AT_FDCWD, \"%s\", O_RDONLY) = %d %s (%m)\n",
+                      sample, fd, errno2name());
        }
 
        puts("+++ exited with 0 +++");