You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2023/06/28 07:17:41 UTC

[nuttx] branch master updated: libs/libc/aio: fix aio_return compatible bug

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 0d9e7be323 libs/libc/aio: fix aio_return compatible bug
0d9e7be323 is described below

commit 0d9e7be323fda94cb509d53c1c6924d67ace6fdc
Author: guoshichao <gu...@xiaomi.com>
AuthorDate: Thu Jun 8 21:34:23 2023 +0800

    libs/libc/aio: fix aio_return compatible bug
    
    1. make the aio_return implementation can pass the
    ltp/open_posix_testsuite/aio_return testcases
    2. the modification are referred to https://pubs.opengroup.org/onlinepubs/9699919799/functions/aio_return.html
    
    Signed-off-by: guoshichao <gu...@xiaomi.com>
---
 libs/libc/aio/aio_return.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/libs/libc/aio/aio_return.c b/libs/libc/aio/aio_return.c
index 0045170d97..08d4c46b91 100644
--- a/libs/libc/aio/aio_return.c
+++ b/libs/libc/aio/aio_return.c
@@ -91,6 +91,8 @@
 
 ssize_t aio_return(FAR struct aiocb *aiocbp)
 {
+  ssize_t ret;
+
   DEBUGASSERT(aiocbp);
   if (aiocbp->aio_result < 0)
     {
@@ -98,7 +100,15 @@ ssize_t aio_return(FAR struct aiocb *aiocbp)
       return (ssize_t)ERROR;
     }
 
-  return aiocbp->aio_result;
+  ret = aiocbp->aio_result;
+
+  /* the aio_return function may be called exactly only once, thereafter, if
+   * the same aiocbp structure is used in a call to aio_return, then error
+   * may be returned
+   */
+
+  aiocbp->aio_result = -EINVAL;
+  return ret;
 }
 
 #endif /* CONFIG_FS_AIO */