aboutsummaryrefslogtreecommitdiffstats
path: root/extension/readdir.c
diff options
context:
space:
mode:
authorAndrew J. Schorr <aschorr@telemetry-investments.com>2012-07-27 12:22:50 -0400
committerAndrew J. Schorr <aschorr@telemetry-investments.com>2012-07-27 12:22:50 -0400
commit913a0f88f5cfff1f139bb05ffd4a0a9a516ebdde (patch)
treefe245ad552f2f802ae0106a2bb671f01a723ffbd /extension/readdir.c
parentfbff497e69139d7cd8434112d6f0a36a46350da1 (diff)
downloadegawk-913a0f88f5cfff1f139bb05ffd4a0a9a516ebdde.tar.gz
egawk-913a0f88f5cfff1f139bb05ffd4a0a9a516ebdde.tar.bz2
egawk-913a0f88f5cfff1f139bb05ffd4a0a9a516ebdde.zip
The readdir extension should set the error code if readdir fails.
Diffstat (limited to 'extension/readdir.c')
-rw-r--r--extension/readdir.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/extension/readdir.c b/extension/readdir.c
index c2b6cbda..f8580568 100644
--- a/extension/readdir.c
+++ b/extension/readdir.c
@@ -130,10 +130,8 @@ dir_get_record(char **out, struct iobuf_public *iobuf, int *errcode)
/*
* The caller sets *errcode to 0, so we should set it only if an
- * error occurs. Except that the compiler complains that it
- * is unused, so we set it anyways.
+ * error occurs.
*/
- *errcode = 0; /* keep the compiler happy */
if (out == NULL || iobuf == NULL || iobuf->opaque == NULL)
return EOF;
@@ -142,8 +140,10 @@ dir_get_record(char **out, struct iobuf_public *iobuf, int *errcode)
the_dir = (open_directory_t *) iobuf->opaque;
dp = the_dir->dp;
dirent = readdir(dp);
- if (dirent == NULL)
+ if (dirent == NULL) {
+ *errcode = errno; /* in case there was an error */
return EOF;
+ }
if (do_ftype)
sprintf(the_dir->buf, "%ld/%s/%s",