summaryrefslogtreecommitdiff
path: root/nuttx/libc
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2013-01-11 19:08:51 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2013-01-11 19:08:51 +0000
commit049b66a75a6f7795b5e80ce70122479f2ef31586 (patch)
tree2af089980e448cc2cf6ae01d884acb23f26f6d88 /nuttx/libc
parent7272d1e7473fc1ce1d0a29c7287260402ca2420e (diff)
downloadpx4-nuttx-049b66a75a6f7795b5e80ce70122479f2ef31586.tar.gz
px4-nuttx-049b66a75a6f7795b5e80ce70122479f2ef31586.tar.bz2
px4-nuttx-049b66a75a6f7795b5e80ce70122479f2ef31586.zip
Fix an error handling bug in the fread logic
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5511 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/libc')
-rw-r--r--nuttx/libc/misc/lib_filesem.c16
-rw-r--r--nuttx/libc/misc/lib_streamsem.c2
-rw-r--r--nuttx/libc/stdio/lib_libfread.c3
3 files changed, 10 insertions, 11 deletions
diff --git a/nuttx/libc/misc/lib_filesem.c b/nuttx/libc/misc/lib_filesem.c
index 5cc4624ec..f38ff5f23 100644
--- a/nuttx/libc/misc/lib_filesem.c
+++ b/nuttx/libc/misc/lib_filesem.c
@@ -67,8 +67,8 @@
void lib_sem_initialize(FAR struct file_struct *stream)
{
- /* Initialize the LIB semaphore to one (to support one-at-
- * a-time access to private data sets.
+ /* Initialize the LIB semaphore to one (to support one-at-a-time access
+ * to private data sets.
*/
(void)sem_init(&stream->fs_sem, 0, 1);
@@ -98,13 +98,13 @@ void lib_take_semaphore(FAR struct file_struct *stream)
/* Take the semaphore (perhaps waiting) */
while (sem_wait(&stream->fs_sem) != 0)
- {
- /* The only case that an error should occr here is if
- * the wait was awakened by a signal.
- */
+ {
+ /* The only case that an error should occr here is if the wait
+ * was awakened by a signal.
+ */
- ASSERT(get_errno() == EINTR);
- }
+ ASSERT(get_errno() == EINTR);
+ }
/* We have it. Claim the stak and return */
diff --git a/nuttx/libc/misc/lib_streamsem.c b/nuttx/libc/misc/lib_streamsem.c
index e38298bdb..3397f9907 100644
--- a/nuttx/libc/misc/lib_streamsem.c
+++ b/nuttx/libc/misc/lib_streamsem.c
@@ -86,5 +86,3 @@ void stream_semgive(FAR struct streamlist *list)
{
sem_post(&list->sl_sem);
}
-
-
diff --git a/nuttx/libc/stdio/lib_libfread.c b/nuttx/libc/stdio/lib_libfread.c
index bc6479037..3e851bf17 100644
--- a/nuttx/libc/stdio/lib_libfread.c
+++ b/nuttx/libc/stdio/lib_libfread.c
@@ -301,9 +301,10 @@ ssize_t lib_fread(FAR void *ptr, size_t count, FAR FILE *stream)
{
stream->fs_flags |= __FS_FLAG_EOF;
}
+
+ lib_give_semaphore(stream);
}
- lib_give_semaphore(stream);
return bytes_read;
/* Error exits */