From 79d99c70fa63ce6e6b5ea63f9ece3d22e321e8a7 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Mon, 18 Apr 2022 19:15:54 +0100 Subject: Fix error checking of readdir call errno set only when readdir returns NULL --- netfs/daemon/daemonDirectory.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/netfs/daemon/daemonDirectory.cpp b/netfs/daemon/daemonDirectory.cpp index 7b8905d..5412bbe 100644 --- a/netfs/daemon/daemonDirectory.cpp +++ b/netfs/daemon/daemonDirectory.cpp @@ -27,13 +27,13 @@ DirectoryServer::readdir(const Ice::Current &) errno = 0; NetFS::NameList list; while (dirent * d = ::readdir(od)) { - if (errno) { - // LCOV_EXCL_START - throw NetFS::SystemError(errno); - // LCOV_EXCL_STOP - } list.emplace_back(d->d_name); } + if (errno) { + // LCOV_EXCL_START + throw NetFS::SystemError(errno); + // LCOV_EXCL_STOP + } return list; } @@ -44,11 +44,6 @@ DirectoryServer::listdir(const Ice::Current &) NetFS::DirectoryContents list; int fd = dirfd(od); while (dirent * d = ::readdir(od)) { - if (errno) { - // LCOV_EXCL_START - throw NetFS::SystemError(errno); - // LCOV_EXCL_STOP - } struct stat s { }; if (::fstatat(fd, d->d_name, &s, AT_SYMLINK_NOFOLLOW) != 0) { // LCOV_EXCL_START @@ -57,5 +52,10 @@ DirectoryServer::listdir(const Ice::Current &) } list.emplace(d->d_name, convert(s)); } + if (errno) { + // LCOV_EXCL_START + throw NetFS::SystemError(errno); + // LCOV_EXCL_STOP + } return list; } -- cgit v1.2.3