Skip to content

Commit

Permalink
removed an unnecessary while loop from vasqFdHandlerCreate
Browse files Browse the repository at this point in the history
  • Loading branch information
nickeldan committed Mar 25, 2023
1 parent 0214fb3 commit 9a67384
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
12 changes: 3 additions & 9 deletions source/logger.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
9 changes: 4 additions & 5 deletions tests/test_logger.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand All @@ -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]);
}

0 comments on commit 9a67384

Please sign in to comment.