gcc 7.3.1 provides the following warning when compiling affinity.c:
affinity.c: In function ‘affinity_file’:
affinity.c:158:2: warning: ‘readdir_r’ is deprecated [-Wdeprecated-declarations]
while (readdir_r(dir, &de, &dep) == 0 && dep) {
^~~~~
In file included from affinity.c:39:0:
/usr/include/dirent.h:183:12: note: declared here
extern int readdir_r (DIR *__restrict __dirp,
^~~~~~~~~
According to the man page for readdir_r(3), calls this function should be
fixed to instead use readdir(3).
One interesting note: I had to move the affinity_class() call above the
closedir(dir) call in affinity_file() because with readdir(3) the string
stored in 'name' is cleared on closedir(). This doesn't happen with
readdir_r() for some reason.
Signed-off-by: Ross Zwisler <[email protected]>
---
affinity.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/affinity.c b/affinity.c
index 85597fc..06784f7 100644
--- a/affinity.c
+++ b/affinity.c
@@ -131,7 +131,7 @@ static int affinity_file(struct bitmask *mask, char *cls,
const char *file)
int n;
unsigned maj = 0, min = 0;
dev_t d;
- struct dirent de, *dep;
+ struct dirent *dep;
cls = "block";
char fn[sizeof("/sys/class/") + strlen(cls)];
@@ -155,8 +155,10 @@ static int affinity_file(struct bitmask *mask, char *cls,
const char *file)
cls);
return -1;
}
- while (readdir_r(dir, &de, &dep) == 0 && dep) {
+ while ((dep = readdir(dir)) != NULL) {
char *name = dep->d_name;
+ int ret;
+
if (*name == '.')
continue;
char *dev;
@@ -179,8 +181,9 @@ static int affinity_file(struct bitmask *mask, char *cls,
const char *file)
if (major(d) != maj || minor(d) != min)
continue;
+ ret = affinity_class(mask, "block", name);
closedir(dir);
- return affinity_class(mask, "block", name);
+ return ret;
}
closedir(dir);
numa_warn(W_blockdev5, "Cannot find block device %x:%x in sysfs for
`%s'",
--
2.14.3
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm