mirror of
https://github.com/apache/nuttx.git
synced 2026-05-23 14:58:13 +08:00
libfread: Fixed error flag when reading a write-only file.
This commit is contained in:
committed by
Xiang Xiao
parent
6b31918b42
commit
10d6de46e6
@@ -55,11 +55,17 @@ ssize_t lib_fread(FAR void *ptr, size_t count, FAR FILE *stream)
|
||||
|
||||
/* Make sure that reading from this stream is allowed */
|
||||
|
||||
if (!stream || (stream->fs_oflags & O_RDOK) == 0)
|
||||
if (!stream)
|
||||
{
|
||||
_NX_SETERRNO(EBADF);
|
||||
return ERROR;
|
||||
}
|
||||
else if ((stream->fs_oflags & O_RDOK) == 0)
|
||||
{
|
||||
stream->fs_flags |= __FS_FLAG_ERROR;
|
||||
_NX_SETERRNO(EBADF);
|
||||
return ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* The stream must be stable until we complete the read */
|
||||
|
||||
Reference in New Issue
Block a user