summaryrefslogtreecommitdiff
path: root/nuttx
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2008-10-09 20:22:21 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2008-10-09 20:22:21 +0000
commitc77db25e7652c2ebdc4f8b9d429ff97e5201f588 (patch)
tree8310fa3b83c7ee1037a0efc0d451ed109cf8925b /nuttx
parentfd55042e823c1d6816caf1df68a57f4ae55491c3 (diff)
downloadpx4-nuttx-c77db25e7652c2ebdc4f8b9d429ff97e5201f588.tar.gz
px4-nuttx-c77db25e7652c2ebdc4f8b9d429ff97e5201f588.tar.bz2
px4-nuttx-c77db25e7652c2ebdc4f8b9d429ff97e5201f588.zip
Not setting error on driver errors
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1014 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx')
-rw-r--r--nuttx/ChangeLog1
-rw-r--r--nuttx/Documentation/NuttX.html1
-rw-r--r--nuttx/fs/fs_read.c15
3 files changed, 15 insertions, 2 deletions
diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog
index 181967a05..3ceb813c5 100644
--- a/nuttx/ChangeLog
+++ b/nuttx/ChangeLog
@@ -492,6 +492,7 @@
* Added USB device side driver for the DM320 (untested at initial checkin)
* Fixed an error in a previous (post 0.3.15) check-in that broke the LPC214x system timer.
* Fixed serial drive bugs related to (1) open counts and (2) recognizing O_NONBLOCK on read.
+ * Fixed an error in read(); it was not setting the errno on errors returned from the driver.
diff --git a/nuttx/Documentation/NuttX.html b/nuttx/Documentation/NuttX.html
index 09f2b465c..7445634d0 100644
--- a/nuttx/Documentation/NuttX.html
+++ b/nuttx/Documentation/NuttX.html
@@ -1082,6 +1082,7 @@ nuttx-0.3.16 2008-xx-xx Gregory Nutt &lt;spudmonkey@racsa.co.cr&gt;
* Added USB device side driver for the DM320 (untested at initial checkin)
* Fixed an error in a previous (post 0.3.15) check-in that broke the LPC214x system timer.
* Fixed serial drive bugs related to (1) open counts and (2) recognizing O_NONBLOCK on read.
+ * Fixed an error in read(); it was not setting the errno on errors returned from the driver.
pascal-0.1.3 2008-xx-xx Gregory Nutt &lt;spudmonkey@racsa.co.cr&gt;
diff --git a/nuttx/fs/fs_read.c b/nuttx/fs/fs_read.c
index 9f171a316..6deb674b1 100644
--- a/nuttx/fs/fs_read.c
+++ b/nuttx/fs/fs_read.c
@@ -52,14 +52,14 @@
ssize_t read(int fd, FAR void *buf, size_t nbytes)
{
FAR struct filelist *list;
- int ret = EBADF;
+ int ret = -EBADF;
/* Get the thread-specific file list */
list = sched_getfiles();
if (!list)
{
- *get_errno_ptr() = EMFILE;
+ errno = EMFILE;
return ERROR;
}
@@ -90,6 +90,17 @@ ssize_t read(int fd, FAR void *buf, size_t nbytes)
}
}
}
+
+ /* If an error occurred, set errno and return -1 (ERROR) */
+
+ if (ret < 0)
+ {
+ errno = -ret;
+ return ERROR;
+ }
+
+ /* Otherwise, return the number of bytes read */
+
return ret;
}