libs/libc/aio: refactor the fd flags check procedure

1. make the implementation compatible with c89

Signed-off-by: guoshichao <guoshichao@xiaomi.com>
This commit is contained in:
guoshichao 2023-06-30 14:20:44 +08:00 committed by Alan Carvalho de Assis
parent 5af99c65de
commit 1466a9e2b6

View File

@ -246,6 +246,7 @@ int aio_write(FAR struct aiocb *aiocbp)
{
FAR struct aio_container_s *aioc;
int ret;
int flags;
DEBUGASSERT(aiocbp);
@ -276,8 +277,8 @@ int aio_write(FAR struct aiocb *aiocbp)
* the EBADF error code
*/
int flags = fcntl(aiocbp->aio_fildes, F_GETFL);
if (!(flags & O_WRONLY))
flags = fcntl(aiocbp->aio_fildes, F_GETFL);
if ((flags & O_WRONLY) == 0)
{
aiocbp->aio_result = -EBADF;
return OK;