Package: ltrace
Version: 0.7.3
ltrace's website says the bug reports are handled via Debian bug tracker.
When compiled against glibc-2.24 headers, ltrace produces the following
error:
proc.c: In function 'process_tasks':
proc.c:245:3: error: 'readdir_r' is deprecated
[-Werror=deprecated-declarations]
if (readdir_r(d, &entry, &result) != 0) {
^~
In file included from proc.c:31:0:
/home/aneyman/work/ctng-testing/install/arm-cortex_a8-linux-gnueabi/arm-cortex_a8-linux-gnueabi/sysroot/usr/include/dirent.h:183:12:
note: declared here
extern int readdir_r (DIR *__restrict __dirp,
^~~~~~~~~
cc1: all warnings being treated as errors
Makefile:362: recipe for target 'proc.lo' failed
readdir_r(3) suggests to use readdir(3) instead, mentioning that it is
also thread-safe in GNU libc. I checked, it is also thread-safe in
uClibc-ng.
Patch attached.
Regards,
Alexey.
diff -urpN ltrace-0.7.3.orig/sysdeps/linux-gnu/proc.c ltrace-0.7.3/sysdeps/linux-gnu/proc.c
--- ltrace-0.7.3.orig/sysdeps/linux-gnu/proc.c 2013-01-02 06:24:46.000000000 -0800
+++ ltrace-0.7.3/sysdeps/linux-gnu/proc.c 2016-11-13 11:24:32.760365875 -0800
@@ -240,14 +240,18 @@ process_tasks(pid_t pid, pid_t **ret_tas
size_t alloc = 0;
while (1) {
- struct dirent entry;
struct dirent *result;
- if (readdir_r(d, &entry, &result) != 0) {
- free(tasks);
- return -1;
- }
- if (result == NULL)
+
+ errno = 0;
+ result = readdir(d);
+ if (result == NULL) {
+ if (errno) {
+ free(tasks);
+ closedir(d);
+ return -1;
+ }
break;
+ }
if (result->d_type == DT_DIR && all_digits(result->d_name)) {
pid_t npid = atoi(result->d_name);
if (n >= alloc) {