summaryrefslogtreecommitdiff
path: root/src/lib/eina/eina_file.c
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 /src/lib/eina/eina_file.c
parent60215a5c53b8d32d0c7e7da0634b16cb24579178 (diff)
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/
Diffstat (limited to 'src/lib/eina/eina_file.c')
-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 08e3a2d..b1f9328 100644
--- a/src/lib/eina/eina_file.c
+++ b/src/lib/eina/eina_file.c
@@ -123,17 +123,6 @@ _eina_name_max(DIR *dirp)
123 return name_max; 123 return name_max;
124} 124}
125 125
126static size_t
127_eina_dirent_buffer_size(DIR *dirp)
128{
129 long name_max = _eina_name_max(dirp);
130 size_t name_end;
131
132 name_end = (size_t) offsetof(struct dirent, d_name) + name_max + 1;
133
134 return (name_end > sizeof (struct dirent) ? name_end : sizeof (struct dirent));
135}
136
137static Eina_Bool 126static Eina_Bool
138_eina_file_ls_iterator_next(Eina_File_Iterator *it, void **data) 127_eina_file_ls_iterator_next(Eina_File_Iterator *it, void **data)
139{ 128{
@@ -141,12 +130,9 @@ _eina_file_ls_iterator_next(Eina_File_Iterator *it, void **data)
141 char *name; 130 char *name;
142 size_t length; 131 size_t length;
143 132
144 dp = alloca(_eina_dirent_buffer_size(it->dirp));
145
146 do 133 do
147 { 134 {
148 if (readdir_r(it->dirp, dp, &dp)) 135 dp = readdir(it->dirp);
149 return EINA_FALSE;
150 if (dp == NULL) 136 if (dp == NULL)
151 return EINA_FALSE; 137 return EINA_FALSE;
152 } 138 }
@@ -203,14 +189,11 @@ _eina_file_direct_ls_iterator_next(Eina_File_Direct_Iterator *it, void **data)
203 struct dirent *dp; 189 struct dirent *dp;
204 size_t length; 190 size_t length;
205 191
206 dp = alloca(_eina_dirent_buffer_size(it->dirp));
207
208 do 192 do
209 { 193 {
210 if (readdir_r(it->dirp, dp, &dp)) 194 dp = readdir(it->dirp);
211 return EINA_FALSE; 195 if (dp == NULL)
212 if (!dp) 196 return EINA_FALSE;
213 return EINA_FALSE;
214 197
215#ifdef _DIRENT_HAVE_D_NAMLEN 198#ifdef _DIRENT_HAVE_D_NAMLEN
216 length = dp->d_namlen; 199 length = dp->d_namlen;