summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2022-04-18 19:15:54 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2022-04-18 19:15:54 +0100
commit79d99c70fa63ce6e6b5ea63f9ece3d22e321e8a7 (patch)
tree72a557aa0bb2a8ff2a88152f9e2b81895686dd1d
parentUse XDG_RUNTIME_DIR for tmp folders (diff)
downloadnetfs-79d99c70fa63ce6e6b5ea63f9ece3d22e321e8a7.tar.bz2
netfs-79d99c70fa63ce6e6b5ea63f9ece3d22e321e8a7.tar.xz
netfs-79d99c70fa63ce6e6b5ea63f9ece3d22e321e8a7.zip
Fix error checking of readdir call
errno set only when readdir returns NULL
-rw-r--r--netfs/daemon/daemonDirectory.cpp20
1 files 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;
}