The old code incorrectly assumed that readdir_r updates errno.
for (;;) {
struct dirent *de;
- union dirent_storage buf;
- int k;
- k = readdir_r(d, &buf.de, &de);
- if (k != 0) {
+ errno = 0;
+ de = readdir(d);
+ if (!de && errno != 0) {
r = -errno;
break;
}
}
for (;;) {
- int k;
struct dirent *de;
- union dirent_storage buf;
- k = readdir_r(d, &buf.de, &de);
- if (k != 0)
+ errno = 0;
+ de = readdir(d);
+ if (!de && errno != 0)
return -errno;
if (!de)
for (;;) {
struct dirent *de;
- union dirent_storage buffer;
_cleanup_unitfilelist_free_ UnitFileList *f = NULL;
- r = readdir_r(d, &buffer.de, &de);
- if (r != 0)
- return -r;
+ errno = 0;
+ de = readdir(d);
+ if (!de && errno != 0)
+ return -errno;
if (!de)
break;