* [PATCH] readdir_r() is deprecated, use readdir().
@ 2017-01-01 0:00 Mark Wielaard
2017-01-01 0:00 ` Dodji Seketeli
0 siblings, 1 reply; 2+ messages in thread
From: Mark Wielaard @ 2017-01-01 0:00 UTC (permalink / raw)
To: libabigail; +Cc: Mark Wielaard
Since glibc 2.24 readdir_r() is deprecated.
Applications are recommended to use readdir which is thread-safe when
using different directory streams (we explicitly create a new one here).
* src/abg-tools-utils.cc (dir_is_empty): Use readdir() instead
of readdir_r().
Signed-off-by: Mark Wielaard <mark@klomp.org>
---
src/abg-tools-utils.cc | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/abg-tools-utils.cc b/src/abg-tools-utils.cc
index d6a89b6..254c963 100644
--- a/src/abg-tools-utils.cc
+++ b/src/abg-tools-utils.cc
@@ -29,6 +29,7 @@
#include <cstdlib>
#include <cstring>
#include <ctype.h>
+#include <errno.h>
#include <libgen.h>
#include <ext/stdio_filebuf.h> // For __gnu_cxx::stdio_filebuf
#include <fstream>
@@ -209,13 +210,14 @@ dir_is_empty(const string &path)
if (!dir)
return false;
- dirent entry, *result = 0;
- if (readdir_r(dir, &entry, &result))
+ errno = 0;
+ dirent *result = readdir(dir);
+ if (result == NULL && errno != 0)
return false;
closedir(dir);
- return result == 0;
+ return result == NULL;
}
/// Test if path is a path to a regular file or a symbolic link to a
--
2.13.5
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-09-04 8:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-01 0:00 [PATCH] readdir_r() is deprecated, use readdir() Mark Wielaard
2017-01-01 0:00 ` Dodji Seketeli
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).