aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Ian King <colin.king@canonical.com>2016-08-31 10:21:22 +0100
committerDaniel Lezcano <daniel.lezcano@linaro.org>2016-09-08 12:46:43 +0200
commitf64cdce36e851bdb38b2a9d98f833968aba570bc (patch)
tree37530cb0425c4f9c9006fddee292e3b8dacb73f6
parent7398755f136d551c03ebc1e784625e9e3f77c1de (diff)
downloadidlestat-f64cdce36e851bdb38b2a9d98f833968aba570bc.tar.gz
Replace deprecated readdir_r with readdir
readdir_r is deprecated and should be replaced with readdir. readdir_r is considered unsafe on systems where NAME_MAX is undefined and on some systems it cannot read directory entries with very long names. Fixes build warning: topology.c:357:2: warning: ‘readdir_r’ is deprecated [-Wdeprecated-declarations] while (!readdir_r(dir, &dirent, &direntp)) { ^~~~~ In file included from topology.c:35:0: /usr/include/dirent.h:183:12: note: declared here extern int readdir_r (DIR *__restrict __dirp, Signed-off-by: Colin Ian King <colin.king@canonical.com> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
-rw-r--r--topology.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/topology.c b/topology.c
index 39b07bd..e293a59 100644
--- a/topology.c
+++ b/topology.c
@@ -331,7 +331,7 @@ static struct cpu_topology *topo_folder_scan(char *path, folder_filter_t filter)
{
DIR *dir, *dir_topology;
char *basedir, *newpath;
- struct dirent dirent, *direntp;
+ struct dirent *direntp;
struct stat s;
int ret;
int is_online;
@@ -354,11 +354,7 @@ static struct cpu_topology *topo_folder_scan(char *path, folder_filter_t filter)
return result;
}
- while (!readdir_r(dir, &dirent, &direntp)) {
-
- if (!direntp)
- break;
-
+ while ((direntp = readdir(dir)) != NULL) {
if (direntp->d_name[0] == '.')
continue;