forked from enlightenment/efl
eina: readdir_r has been deprecated.
So glibc has decided that readdir_r is hard to use safely and deprecated it this summer. They recommand to use readdir, which was in the past unsafe to use in a multi thread scenario, but is now on most system (and all system we care, including our own implementation in evil). It is basically safe as long the same DIRP is not accessed from another thread. This is true in our code base, so we are fine to go with this. For further reading: https://lwn.net/Articles/696474/
This commit is contained in:
parent
60215a5c53
commit
0ef07d6095
|
@ -123,17 +123,6 @@ _eina_name_max(DIR *dirp)
|
|||
return name_max;
|
||||
}
|
||||
|
||||
static size_t
|
||||
_eina_dirent_buffer_size(DIR *dirp)
|
||||
{
|
||||
long name_max = _eina_name_max(dirp);
|
||||
size_t name_end;
|
||||
|
||||
name_end = (size_t) offsetof(struct dirent, d_name) + name_max + 1;
|
||||
|
||||
return (name_end > sizeof (struct dirent) ? name_end : sizeof (struct dirent));
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_eina_file_ls_iterator_next(Eina_File_Iterator *it, void **data)
|
||||
{
|
||||
|
@ -141,12 +130,9 @@ _eina_file_ls_iterator_next(Eina_File_Iterator *it, void **data)
|
|||
char *name;
|
||||
size_t length;
|
||||
|
||||
dp = alloca(_eina_dirent_buffer_size(it->dirp));
|
||||
|
||||
do
|
||||
{
|
||||
if (readdir_r(it->dirp, dp, &dp))
|
||||
return EINA_FALSE;
|
||||
dp = readdir(it->dirp);
|
||||
if (dp == NULL)
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
@ -203,13 +189,10 @@ _eina_file_direct_ls_iterator_next(Eina_File_Direct_Iterator *it, void **data)
|
|||
struct dirent *dp;
|
||||
size_t length;
|
||||
|
||||
dp = alloca(_eina_dirent_buffer_size(it->dirp));
|
||||
|
||||
do
|
||||
{
|
||||
if (readdir_r(it->dirp, dp, &dp))
|
||||
return EINA_FALSE;
|
||||
if (!dp)
|
||||
dp = readdir(it->dirp);
|
||||
if (dp == NULL)
|
||||
return EINA_FALSE;
|
||||
|
||||
#ifdef _DIRENT_HAVE_D_NAMLEN
|
||||
|
|
Loading…
Reference in New Issue