summaryrefslogtreecommitdiff
path: root/nuttx/fs
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2013-09-28 15:37:16 -0600
committerGregory Nutt <gnutt@nuttx.org>2013-09-28 15:37:16 -0600
commite735773fe5ea269b43dbecb246cec846b3a0368e (patch)
tree50aad3b72a6476b67e0b76680e3e4a25a2b89ed3 /nuttx/fs
parentb2bb7e626fd9d3ca2a0a53a179712a30f6f2ab3a (diff)
downloadpx4-nuttx-e735773fe5ea269b43dbecb246cec846b3a0368e.tar.gz
px4-nuttx-e735773fe5ea269b43dbecb246cec846b3a0368e.tar.bz2
px4-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
Diffstat (limited to 'nuttx/fs')
-rw-r--r--nuttx/fs/fs_lseek.c19
-rw-r--r--nuttx/fs/fs_write.c12
2 files changed, 20 insertions, 11 deletions
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? */