Not setting error on driver errors

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1014 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2008-10-09 20:22:21 +00:00
parent fed5871039
commit 24aff819a4
3 changed files with 15 additions and 2 deletions

View File

@ -492,6 +492,7 @@
* Added USB device side driver for the DM320 (untested at initial checkin) * 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 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 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.

View File

@ -1082,6 +1082,7 @@ nuttx-0.3.16 2008-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr>
* Added USB device side driver for the DM320 (untested at initial checkin) * 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 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 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 <spudmonkey@racsa.co.cr> pascal-0.1.3 2008-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr>

View File

@ -52,14 +52,14 @@
ssize_t read(int fd, FAR void *buf, size_t nbytes) ssize_t read(int fd, FAR void *buf, size_t nbytes)
{ {
FAR struct filelist *list; FAR struct filelist *list;
int ret = EBADF; int ret = -EBADF;
/* Get the thread-specific file list */ /* Get the thread-specific file list */
list = sched_getfiles(); list = sched_getfiles();
if (!list) if (!list)
{ {
*get_errno_ptr() = EMFILE; errno = EMFILE;
return ERROR; 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; return ret;
} }