public inbox for libabigail@sourceware.org
 help / color / mirror / Atom feed
From: Mark Wielaard <mark@klomp.org>
To: libabigail@sourceware.org
Cc: Mark Wielaard <mark@klomp.org>
Subject: [PATCH] readdir_r() is deprecated, use readdir().
Date: Sun, 01 Jan 2017 00:00:00 -0000	[thread overview]
Message-ID: <20170902130336.28277-1-mark@klomp.org> (raw)

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

             reply	other threads:[~2017-09-02 13:05 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-01  0:00 Mark Wielaard [this message]
2017-01-01  0:00 ` Dodji Seketeli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170902130336.28277-1-mark@klomp.org \
    --to=mark@klomp.org \
    --cc=libabigail@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).