From 9a673842e77e73913b59902b194b7f8983df75e2 Mon Sep 17 00:00:00 2001 From: Daniel Walker Date: Fri, 24 Mar 2023 20:25:02 -0400 Subject: [PATCH] removed an unnecessary while loop from vasqFdHandlerCreate --- source/logger.c | 12 +++--------- tests/test_logger.c | 9 ++++----- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/source/logger.c b/source/logger.c index c6abee0..036f8bd 100644 --- a/source/logger.c +++ b/source/logger.c @@ -241,15 +241,9 @@ vasqFdHandlerCreate(int fd, unsigned int flags, vasqHandler *handler) return -1; } - while ((new_fd = dup(fd)) < 0) { - switch (errno) { -#ifdef EBUSY - case EBUSY: -#endif - case EINTR: break; - - default: return -1; - } + new_fd = dup(fd); + if (new_fd < 0) { + return -1; } if (flags & VASQ_LOGGER_FLAG_CLOEXEC) { diff --git a/tests/test_logger.c b/tests/test_logger.c index 4c5c671..d0395ff 100644 --- a/tests/test_logger.c +++ b/tests/test_logger.c @@ -667,7 +667,7 @@ test_logger_fd_handler(void) void test_logger_fd_handler_cloexec(void) { - int fd_flags, handler_fd; + int fd_flags; vasqHandler handler; int fds[2]; @@ -676,14 +676,13 @@ test_logger_fd_handler_cloexec(void) } SCR_ASSERT_EQ(vasqFdHandlerCreate(fds[1], VASQ_LOGGER_FLAG_CLOEXEC, &handler), 0); - handler_fd = (intptr_t)handler.user; - fd_flags = fcntl(handler_fd, F_GETFD); + fd_flags = fcntl((intptr_t)handler.user, F_GETFD); if (fd_flags == -1) { - SCR_FAIL("fcntl (F_GETFD): %s", strerror(errno)); + SCR_FAIL("fcntl: %s", strerror(errno)); } SCR_ASSERT(fd_flags & FD_CLOEXEC); - close(handler_fd); + handler.cleanup(handler.user); close(fds[0]); close(fds[1]); }