Fix cppcheck warning "Non reentrant function 'readdir' called"

This commit is contained in:
Philippe Teuwen 2013-03-08 23:50:03 +01:00
parent 8e2effdc53
commit 262555d568

View file

@ -271,7 +271,10 @@ spi_list_ports(void)
DIR *pdDir = opendir("/dev");
struct dirent *pdDirEnt;
while ((pdDirEnt = readdir(pdDir)) != NULL) {
struct dirent entry;
struct dirent *result;
while ((readdir_r(pdDir, &entry, &result) == 0) && (result != NULL)) {
pdDirEnt = &entry;
#if !defined(__APPLE__)
if (!isdigit(pdDirEnt->d_name[strlen(pdDirEnt->d_name) - 1]))
continue;