summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2016-08-25 15:20:19 -0700
committerCedric BAIL <cedric@osg.samsung.com>2016-08-25 15:23:14 -0700
commit0ef07d609518d3212715ff8e3ed679fbbdab0924 (patch)
treebc7a53698b759bda76391ecec2de3f94a14de76e
parent60215a5c53b8d32d0c7e7da0634b16cb24579178 (diff)
downloadefl-0ef07d609518d3212715ff8e3ed679fbbdab0924.tar.gz
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/
-rw-r--r--src/lib/eina/eina_file.c25
1 files changed, 4 insertions, 21 deletions
diff --git a/src/lib/eina/eina_file.c b/src/lib/eina/eina_file.c
index 08e3a2dc39..b1f9328c1b 100644
--- a/src/lib/eina/eina_file.c
+++ b/src/lib/eina/eina_file.c
@@ -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,14 +189,11 @@ _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)
- return EINA_FALSE;
+ dp = readdir(it->dirp);
+ if (dp == NULL)
+ return EINA_FALSE;
#ifdef _DIRENT_HAVE_D_NAMLEN
length = dp->d_namlen;