libfread: Fixed error flag when reading a write-only file.
This commit is contained in:
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 */
|
||||
|
Loading…
Reference in New Issue
Block a user