From 262555d56859d8f88022c0a9c92e4116ac33fc44 Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Fri, 8 Mar 2013 23:50:03 +0100 Subject: [PATCH] Fix cppcheck warning "Non reentrant function 'readdir' called" --- libnfc/buses/spi_posix.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libnfc/buses/spi_posix.c b/libnfc/buses/spi_posix.c index fdf000a..e862bdf 100644 --- a/libnfc/buses/spi_posix.c +++ b/libnfc/buses/spi_posix.c @@ -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;