From 4e3da6e96f841ca938afa47dbd88cba0abf6f056 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Tue, 1 Aug 2017 17:39:44 -0700 Subject: [PATCH] Move off deprecated readdir_r. Bug: http://b/32678321 Test: builds Change-Id: I2d6e995d5eed3e72e12ce8b8f82a10143a256cd4 --- CommandListener.cpp | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/CommandListener.cpp b/CommandListener.cpp index b548a91..acdff7d 100644 --- a/CommandListener.cpp +++ b/CommandListener.cpp @@ -358,18 +358,8 @@ void CommandListener::AsecCmd::listAsecsInDirectory(SocketClient *cli, const cha return; } - size_t dirent_len = offsetof(struct dirent, d_name) + - fpathconf(dirfd(d), _PC_NAME_MAX) + 1; - - struct dirent *dent = (struct dirent *) malloc(dirent_len); - if (dent == NULL) { - cli->sendMsg(ResponseCode::OperationFailed, "Failed to allocate memory", true); - return; - } - - struct dirent *result; - - while (!readdir_r(d, dent, &result) && result != NULL) { + dirent* dent; + while ((dent = readdir(d)) != NULL) { if (dent->d_name[0] == '.') continue; if (dent->d_type != DT_REG) @@ -384,8 +374,6 @@ void CommandListener::AsecCmd::listAsecsInDirectory(SocketClient *cli, const cha } } closedir(d); - - free(dent); } int CommandListener::AsecCmd::runCommand(SocketClient *cli,