From 037ab86e9a6d9d3a1215d4dc7de1756c1ca8bcb5 Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Thu, 21 Apr 2016 21:12:41 +0000 Subject: [PATCH] tests/openat.c: use errno2name --- tests/openat.c | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/tests/openat.c b/tests/openat.c index f769f6e9..e7f9fbed 100644 --- a/tests/openat.c +++ b/tests/openat.c @@ -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 +++"); -- 2.40.0