summaryrefslogtreecommitdiff
path: root/test/misc
diff options
context:
space:
mode:
authorCarmelo Amoroso <carmelo.amoroso@st.com>2008-10-06 15:04:46 +0000
committerCarmelo Amoroso <carmelo.amoroso@st.com>2008-10-06 15:04:46 +0000
commitab490047099069aadbb0c30d7765d4dd00318b85 (patch)
tree1666d7b16b94a4431cec10c12af5bf0a882793a9 /test/misc
parentacbd962f90dfe3d5a7cb5614e39bb814310ab86b (diff)
Fix scandir function to reset the errno when the
selector returns zero(no entries) modifying the errno. The attached test case implements a dummy filter that returns alway no entries, but change the errno. scandir is not expected to fail, just returning 0 entries. Signed-off-by: Filippo Arcidiacono <filippo.arcidiacono@st.com> Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com> Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
Diffstat (limited to 'test/misc')
-rw-r--r--test/misc/tst-scandir.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/misc/tst-scandir.c b/test/misc/tst-scandir.c
new file mode 100644
index 000000000..6e4646142
--- /dev/null
+++ b/test/misc/tst-scandir.c
@@ -0,0 +1,21 @@
+#include <dirent.h>
+#include <errno.h>
+
+int skip_all(const struct dirent *dirbuf)
+{
+ __set_errno(EBADF);
+ return 0;
+}
+
+int main()
+{
+ struct dirent **namelist;
+ int n;
+
+ n = scandir(".", &namelist, skip_all, 0);
+ if (n < 0) {
+ perror("scandir");
+ return 1;
+ }
+ return 0;
+}