diff --git a/fs/aio/aio_write.c b/fs/aio/aio_write.c index 803bbdfa1c..829d1de019 100644 --- a/fs/aio/aio_write.c +++ b/fs/aio/aio_write.c @@ -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;