Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F147823037
D51680.id159580.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D51680.id159580.diff
View Options
diff --git a/contrib/kyua/utils/fs/directory.cpp b/contrib/kyua/utils/fs/directory.cpp
--- a/contrib/kyua/utils/fs/directory.cpp
+++ b/contrib/kyua/utils/fs/directory.cpp
@@ -127,16 +127,9 @@
/// not. A null pointer means an invalid iterator.
::DIR* _dirp;
- /// Raw representation of the system directory entry.
- ///
- /// We need to keep this at the class level so that we can use the
- /// readdir_r(3) function.
- ::dirent _dirent;
-
/// Custom representation of the directory entry.
///
- /// This is separate from _dirent because this is the type we return to the
- /// user. We must keep this as a pointer so that we can support the common
+ /// We must keep this as a pointer so that we can support the common
/// operators (* and ->) over iterators.
std::unique_ptr< directory_entry > _entry;
@@ -192,13 +185,14 @@
/// It is possible to use this function on a new directory_entry object to
/// initialize the first entry.
///
- /// \throw system_error If the call to readdir_r fails.
+ /// \throw system_error If the call to readdir fails.
void
next(void)
{
::dirent* result;
- if (::readdir_r(_dirp, &_dirent, &result) == -1) {
+ errno = 0;
+ if ((result = ::readdir(_dirp)) == NULL && errno != 0) {
const int original_errno = errno;
throw fs::system_error(F("readdir_r(%s) failed") % _path,
original_errno);
@@ -207,7 +201,8 @@
_entry.reset();
close();
} else {
- _entry.reset(new directory_entry(_dirent.d_name));
+ _entry.reset(new directory_entry(result->d_name));
+ ::free(result);
}
}
};
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Mar 14, 10:45 PM (5 h, 52 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29690549
Default Alt Text
D51680.id159580.diff (1 KB)
Attached To
Mode
D51680: kyua: Stop using readdir_r()
Attached
Detach File
Event Timeline
Log In to Comment