diff options
author | Gregory Nutt <gnutt@nuttx.org> | 2013-09-28 15:37:16 -0600 |
---|---|---|
committer | Gregory Nutt <gnutt@nuttx.org> | 2013-09-28 15:37:16 -0600 |
commit | e735773fe5ea269b43dbecb246cec846b3a0368e (patch) | |
tree | 50aad3b72a6476b67e0b76680e3e4a25a2b89ed3 | |
parent | b2bb7e626fd9d3ca2a0a53a179712a30f6f2ab3a (diff) | |
download | nuttx-e735773fe5ea269b43dbecb246cec846b3a0368e.tar.gz nuttx-e735773fe5ea269b43dbecb246cec846b3a0368e.tar.bz2 nuttx-e735773fe5ea269b43dbecb246cec846b3a0368e.zip |
The last checkin replaced some impossible error handling with DEBUGASSERT. Except that one of the case is actually possible in one cornercase and had to be restored
-rw-r--r-- | nuttx/configs/sim/README.txt | 3 | ||||
-rw-r--r-- | nuttx/fs/fs_lseek.c | 19 | ||||
-rw-r--r-- | nuttx/fs/fs_write.c | 12 | ||||
-rw-r--r-- | nuttx/include/nuttx/fs/fs.h | 4 |
4 files changed, 25 insertions, 13 deletions
diff --git a/nuttx/configs/sim/README.txt b/nuttx/configs/sim/README.txt index 7db2e11a8..c1b105aeb 100644 --- a/nuttx/configs/sim/README.txt +++ b/nuttx/configs/sim/README.txt @@ -165,6 +165,9 @@ I never did get networking to work on the sim target. It tries to use the tap d (/dev/net/tun) to emulate an Ethernet NIC, but I never got it correctly integrated with the NuttX networking (I probably should try using raw sockets instead). +Update: Max Holtzberg reports to me that the tap device actually does work properly, +but not in an NSH configuration because of stdio operations freeze the simulation. + X11 Issues ---------- There is an X11-based framebuffer driver that you can use exercise the NuttX graphics diff --git a/nuttx/fs/fs_lseek.c b/nuttx/fs/fs_lseek.c index bcf66f51b..d2a2a8ca7 100644 --- a/nuttx/fs/fs_lseek.c +++ b/nuttx/fs/fs_lseek.c @@ -80,7 +80,7 @@ off_t file_seek(FAR struct file *filep, off_t offset, int whence) int ret; int err = OK; - DEBUGASSERT(seekfile); + DEBUGASSERT(filep); inode = filep->f_inode; /* Invoke the file seek method if available */ @@ -173,9 +173,6 @@ errout: off_t lseek(int fd, off_t offset, int whence) { FAR struct filelist *list; - FAR struct file *filep; - FAR struct inode *inode; - int err; /* Did we get a valid file descriptor? */ @@ -184,15 +181,17 @@ off_t lseek(int fd, off_t offset, int whence) set_errno(EBADF); return (off_t)ERROR; } + else + { + /* Get the thread-specific file list */ - /* Get the thread-specific file list */ - - list = sched_getfiles(); - DEBUGASSERT(list); + list = sched_getfiles(); + DEBUGASSERT(list); - /* Then let file_seek do the real work */ + /* Then let file_seek do the real work */ - return file_seek(&list->fl_files[fd], offset, whence); + return file_seek(&list->fl_files[fd], offset, whence); + } } #endif diff --git a/nuttx/fs/fs_write.c b/nuttx/fs/fs_write.c index 7b6a8172f..3aad823a8 100644 --- a/nuttx/fs/fs_write.c +++ b/nuttx/fs/fs_write.c @@ -67,7 +67,17 @@ static inline ssize_t file_write(int fd, FAR const void *buf, size_t nbytes) /* Get the thread-specific file list */ list = sched_getfiles(); - DEBUGASSERT(list); + + /* The file list can be NULL under one obscure cornercase: When memory + * management debug output is enabled. Then there may be attempts to + * write to stdout from malloc before the group data has been allocated. + */ + + if (!list) + { + err = EAGAIN; + goto errout; + } /* Was this file opened for write access? */ diff --git a/nuttx/include/nuttx/fs/fs.h b/nuttx/include/nuttx/fs/fs.h index a1678b603..4a883792a 100644 --- a/nuttx/include/nuttx/fs/fs.h +++ b/nuttx/include/nuttx/fs/fs.h @@ -621,7 +621,7 @@ int lib_flushall(FAR struct streamlist *list); ssize_t lib_sendfile(int outfd, int infd, off_t *offset, size_t count); #endif -/* fs/fs_fileread.c *********************************************************/ +/* fs/fs_read.c *************************************************************/ /**************************************************************************** * Name: file_read * @@ -636,7 +636,7 @@ ssize_t lib_sendfile(int outfd, int infd, off_t *offset, size_t count); ssize_t file_read(FAR struct file *filep, FAR void *buf, size_t nbytes); #endif -/* fs/fs_fileread.c *********************************************************/ +/* fs/fs_lseek.c ************************************************************/ /**************************************************************************** * Name: file_seek * |