There are 2 changes in this patch.

1. Initialize the aiocb struct before using it
2. If Prioritized Input and Output option is supported, submit the aiocb with
   invalid aio_reqprio, else submit the aiocb with invalid aio_fildes

   The aio_buf points to NULL is undefined, please refer to POSIX spec.

   NAME
    aio_read - asynchronous read from a file
   SYNOPSIS
    #include <aio.h>

    int aio_read(struct aiocb *aiocbp);
   DESCRIPTION
       The aiocbp argument points to an aiocb structure. If the buffer
       pointed to by aiocbp->aio_buf or the control block pointed to by aiocbp
       becomes an illegal address prior to asynchronous I/O completion, then
       the behavior is undefined.

Signed-off-by: Bian Naimeng <[email protected]>
Signed-off-by: Peng Haitao <[email protected]>
---
 .../conformance/interfaces/aio_read/8-1.c          |   12 +++++++++---
 .../conformance/interfaces/aio_write/6-1.c         |   12 +++++++++---
 2 files changed, 18 insertions(+), 6 deletions(-)

diff --git 
a/testcases/open_posix_testsuite/conformance/interfaces/aio_read/8-1.c 
b/testcases/open_posix_testsuite/conformance/interfaces/aio_read/8-1.c
index 8ec568c..2923f3b 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/aio_read/8-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/aio_read/8-1.c
@@ -14,7 +14,9 @@
  *
  * method:
  *
- *     - fill in an aiocb with a NULL aio_buf
+ *     - if Prioritized Input and Output option is supported, fill in an
+ *       aiocb with invalid aio_reqprio, else submit the aiocb with invalid
+ *       aio_fildes
  *     - call aio_read
  *     - check aio_read return value
  */
@@ -42,10 +44,14 @@ int main()
                return PTS_UNSUPPORTED;
 
        /* submit a request with a NULL buffer */
-       aiocb.aio_fildes = 0;
+       memset(&aiocb, 0, sizeof(struct aiocb));
        aiocb.aio_buf = NULL;
        aiocb.aio_nbytes = 0;
        aiocb.aio_offset = 0;
+       if (sysconf(_SC_PRIORITIZED_IO) < 200112L)
+               aiocb.aio_fildes = -1;
+       else
+               aiocb.aio_reqprio = -1;
 
        if (aio_read(&aiocb) != -1)
        {
@@ -55,4 +61,4 @@ int main()
 
        printf ("Test PASSED\n");
        return PTS_PASS;
-}
\ No newline at end of file
+}
diff --git 
a/testcases/open_posix_testsuite/conformance/interfaces/aio_write/6-1.c 
b/testcases/open_posix_testsuite/conformance/interfaces/aio_write/6-1.c
index 98b8d0d..c54908c 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/aio_write/6-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/aio_write/6-1.c
@@ -14,7 +14,9 @@
  *
  * method:
  *
- *     - fill in an aiocb with a NULL aio_buf
+ *     - if Prioritized Input and Output option is supported, fill in an
+ *       aiocb with invalid aio_reqprio, else submit the aiocb with invalid
+ *       aio_fildes
  *     - call aio_write
  *     - check aio_write return value
  *
@@ -43,10 +45,14 @@ int main()
                return PTS_UNSUPPORTED;
 
        /* submit a request with a NULL buffer */
-       aiocb.aio_fildes = 0;
+       memset(&aiocb, 0, sizeof(struct aiocb));
        aiocb.aio_buf = NULL;
        aiocb.aio_nbytes = 0;
        aiocb.aio_offset = 0;
+       if (sysconf(_SC_PRIORITIZED_IO) < 200112L)
+               aiocb.aio_fildes = -1;
+       else
+               aiocb.aio_reqprio = -1;
 
        if (aio_write(&aiocb) != -1)
        {
@@ -62,4 +68,4 @@ int main()
 
        printf ("Test PASSED\n");
        return PTS_PASS;
-}
\ No newline at end of file
+}
-- 
1.7.1


-- 
Best Regards,
Peng Haitao


------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security 
threats, fraudulent activity, and more. Splunk takes this data and makes 
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to