Skip to contentSkip to conversation

aio_read:8-1.c: Forget initializing struct aiocb before using it

PATCH In review Garrett Cooper 3 participants 5 messages Mar 16, 2012 – Mar 22, 2012 3 messages not in the archive

lore
Share & tools
lore
#3 lore raw
In reply to a message not in the archive
Quoted 8 lines · Wanlong Gao
Quoted 6 lines · Peng Haitao

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

Quoted 4 lines
Quoted 1 line

Looks good to me , Cyril?

Why not always set fildes == -1 and test that way?

Quoted 70 lines
Quoted 70 lines
.../conformance/interfaces/aio_read/8-1.c              |   14 ++++++++------
.../conformance/interfaces/aio_write/6-1.c             |   16 +++++++++-------
2 files changed, 17 insertions(+), 13 deletions(-)
testcases/open_posix_testsuite/conformance/interfaces/aio_read/8-1.c +8 -6
index 8054eeb..009aeb2 100644
@@ -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
 */
@@ -41,11 +43,11 @@ int main()
   if (sysconf(_SC_ASYNCHRONOUS_IO) < 200112L)
       return PTS_UNSUPPORTED;
 
-    /* submit a request with a NULL buffer */
-    aiocb.aio_fildes = 0;
-    aiocb.aio_buf = NULL;
-    aiocb.aio_nbytes = 0;
-    aiocb.aio_offset = 0;
+    memset(&aiocb, 0, sizeof(struct aiocb));
+    if (sysconf(_SC_PRIORITIZED_IO) < 200112L)
+        aiocb.aio_fildes = -1;
+    else
+        aiocb.aio_reqprio = -1;
 
   if (aio_read(&aiocb) != -1) {
       printf(TNAME " aio_read() should fail!\n");
testcases/open_posix_testsuite/conformance/interfaces/aio_write/6-1.c +8 -6
index 98b8d0d..9234fe6 100644
@@ -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
 *
@@ -42,11 +44,11 @@ int main()
   if (sysconf(_SC_ASYNCHRONOUS_IO) < 200112L)
       return PTS_UNSUPPORTED;
 
-    /* submit a request with a NULL buffer */
-    aiocb.aio_fildes = 0;
-    aiocb.aio_buf = NULL;
-    aiocb.aio_nbytes = 0;
-    aiocb.aio_offset = 0;
+    memset(&aiocb, 0, sizeof(struct aiocb));
+    if (sysconf(_SC_PRIORITIZED_IO) < 200112L)
+        aiocb.aio_fildes = -1;
+    else
+        aiocb.aio_reqprio = -1;
 
   if (aio_write(&aiocb) != -1)
   {
@@ -62,4 +64,4 @@ int main()
 
Quoted 16 lines

testcases/open_posix_testsuite/conformance/interfaces/aio_write/6-1.c int main() · line 67

Quoted 5 lines
testcases/open_posix_testsuite/conformance/interfaces/aio_write/6-1.c +1 -1
   printf ("Test PASSED\n");
   return PTS_PASS;
-}
\ No newline at end of file
+}

------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#4 lore raw

Garrett Cooper said the following on 2012-3-16 17:48:

Quoted 10 lines · Wanlong Gao
Quoted 9 lines · Peng Haitao
Quoted 7 lines

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

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Looks good to me , Cyril?

Why not always set fildes == -1 and test that way?

When Prioritized Input and Output option is supported,and aio_fildes is set -1, the aio_read() will success:( Only aiocb.aio_reqprio is set -1, the aio_read() will fail.

When Prioritized Input and Output option is not supported,and aio_fildes is set -1, the result of aio_read() is not tested.
But I think it is wrong when aio_fildes is set -1.

Signature · 2 lines
Best Regards,
Peng
Quoted 70 lines
Quoted 70 lines
Quoted 70 lines
.../conformance/interfaces/aio_read/8-1.c              |   14 ++++++++------
.../conformance/interfaces/aio_write/6-1.c             |   16 +++++++++-------
2 files changed, 17 insertions(+), 13 deletions(-)
testcases/open_posix_testsuite/conformance/interfaces/aio_read/8-1.c +8 -6
index 8054eeb..009aeb2 100644
@@ -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
 */
@@ -41,11 +43,11 @@ int main()
   if (sysconf(_SC_ASYNCHRONOUS_IO) < 200112L)
       return PTS_UNSUPPORTED;
 
-    /* submit a request with a NULL buffer */
-    aiocb.aio_fildes = 0;
-    aiocb.aio_buf = NULL;
-    aiocb.aio_nbytes = 0;
-    aiocb.aio_offset = 0;
+    memset(&aiocb, 0, sizeof(struct aiocb));
+    if (sysconf(_SC_PRIORITIZED_IO) < 200112L)
+        aiocb.aio_fildes = -1;
+    else
+        aiocb.aio_reqprio = -1;
 
   if (aio_read(&aiocb) != -1) {
       printf(TNAME " aio_read() should fail!\n");
testcases/open_posix_testsuite/conformance/interfaces/aio_write/6-1.c +8 -6
index 98b8d0d..9234fe6 100644
@@ -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
 *
@@ -42,11 +44,11 @@ int main()
   if (sysconf(_SC_ASYNCHRONOUS_IO) < 200112L)
       return PTS_UNSUPPORTED;
 
-    /* submit a request with a NULL buffer */
-    aiocb.aio_fildes = 0;
-    aiocb.aio_buf = NULL;
-    aiocb.aio_nbytes = 0;
-    aiocb.aio_offset = 0;
+    memset(&aiocb, 0, sizeof(struct aiocb));
+    if (sysconf(_SC_PRIORITIZED_IO) < 200112L)
+        aiocb.aio_fildes = -1;
+    else
+        aiocb.aio_reqprio = -1;
 
   if (aio_write(&aiocb) != -1)
   {
@@ -62,4 +64,4 @@ int main()
 
Quoted 18 lines
Quoted 8 lines

testcases/open_posix_testsuite/conformance/interfaces/aio_write/6-1.c int main() · line 67

Quoted 5 lines
testcases/open_posix_testsuite/conformance/interfaces/aio_write/6-1.c +1 -1
   printf ("Test PASSED\n");
   return PTS_PASS;
-}
\ No newline at end of file
+}
Quoted 8 lines

------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#5 lore raw

PATCH v5 1/1 aio_read:8-1.c: Forget initializing struct aiocb before using it

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 return untested.

---
 .../conformance/interfaces/aio_read/8-1.c               |   13 +++++++------
 .../conformance/interfaces/aio_write/6-1.c              |   15 ++++++++-------
 2 files changed, 15 insertions(+), 13 deletions(-)
testcases/open_posix_testsuite/conformance/interfaces/aio_read/8-1.c +7 -6
index 8054eeb..ea0538e 100644
@@ -14,7 +14,8 @@
  *
  * 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.
  *	- call aio_read
  *	- check aio_read return value
  */
@@ -41,11 +42,11 @@ int main()
 	if (sysconf(_SC_ASYNCHRONOUS_IO) < 200112L)
 		return PTS_UNSUPPORTED;
 
-	/* submit a request with a NULL buffer */
-	aiocb.aio_fildes = 0;
-	aiocb.aio_buf = NULL;
-	aiocb.aio_nbytes = 0;
-	aiocb.aio_offset = 0;
+	if (sysconf(_SC_PRIORITIZED_IO) < 200112L)
+		return PTS_UNTESTED;
+
+	memset(&aiocb, 0, sizeof(struct aiocb));
+	aiocb.aio_reqprio = -1;
 
 	if (aio_read(&aiocb) != -1) {
 		printf(TNAME " aio_read() should fail!\n");
testcases/open_posix_testsuite/conformance/interfaces/aio_write/6-1.c +8 -7
index 98b8d0d..744c82c 100644
@@ -14,7 +14,8 @@
  *
  * 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
  *	- call aio_write
  *	- check aio_write return value
  *
@@ -42,11 +43,11 @@ int main()
 	if (sysconf(_SC_ASYNCHRONOUS_IO) < 200112L)
 		return PTS_UNSUPPORTED;
 
-	/* submit a request with a NULL buffer */
-	aiocb.aio_fildes = 0;
-	aiocb.aio_buf = NULL;
-	aiocb.aio_nbytes = 0;
-	aiocb.aio_offset = 0;
+	if (sysconf(_SC_PRIORITIZED_IO) < 200112L)
+		return PTS_UNTESTED;
+
+	memset(&aiocb, 0, sizeof(struct aiocb));
+	aiocb.aio_reqprio = -1;
 
 	if (aio_write(&aiocb) != -1)
 	{
@@ -62,4 +63,4 @@ int main()
 
 	printf ("Test PASSED\n");
 	return PTS_PASS;
-}
\ No newline at end of file
+}
Signature · 11 lines
1.7.10.rc1


------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
#6 lore raw
Quoted 6 lines · Peng Haitao

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 return untested.

thanks Peng.

ACK.

Quoted 68 lines
---
 .../conformance/interfaces/aio_read/8-1.c               |   13 +++++++------
 .../conformance/interfaces/aio_write/6-1.c              |   15 ++++++++-------
 2 files changed, 15 insertions(+), 13 deletions(-)
testcases/open_posix_testsuite/conformance/interfaces/aio_read/8-1.c +7 -6
index 8054eeb..ea0538e 100644
@@ -14,7 +14,8 @@
  *
  * 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.
  *	- call aio_read
  *	- check aio_read return value
  */
@@ -41,11 +42,11 @@ int main()
 	if (sysconf(_SC_ASYNCHRONOUS_IO) < 200112L)
 		return PTS_UNSUPPORTED;
 
-	/* submit a request with a NULL buffer */
-	aiocb.aio_fildes = 0;
-	aiocb.aio_buf = NULL;
-	aiocb.aio_nbytes = 0;
-	aiocb.aio_offset = 0;
+	if (sysconf(_SC_PRIORITIZED_IO) < 200112L)
+		return PTS_UNTESTED;
+
+	memset(&aiocb, 0, sizeof(struct aiocb));
+	aiocb.aio_reqprio = -1;
 
 	if (aio_read(&aiocb) != -1) {
 		printf(TNAME " aio_read() should fail!\n");
testcases/open_posix_testsuite/conformance/interfaces/aio_write/6-1.c +7 -6
index 98b8d0d..744c82c 100644
@@ -14,7 +14,8 @@
  *
  * 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
  *	- call aio_write
  *	- check aio_write return value
  *
@@ -42,11 +43,11 @@ int main()
 	if (sysconf(_SC_ASYNCHRONOUS_IO) < 200112L)
 		return PTS_UNSUPPORTED;
 
-	/* submit a request with a NULL buffer */
-	aiocb.aio_fildes = 0;
-	aiocb.aio_buf = NULL;
-	aiocb.aio_nbytes = 0;
-	aiocb.aio_offset = 0;
+	if (sysconf(_SC_PRIORITIZED_IO) < 200112L)
+		return PTS_UNTESTED;
+
+	memset(&aiocb, 0, sizeof(struct aiocb));
+	aiocb.aio_reqprio = -1;
 
 	if (aio_write(&aiocb) != -1)
 	{

testcases/open_posix_testsuite/conformance/interfaces/aio_write/6-1.c int main() · line 66

Quoted 6 lines
testcases/open_posix_testsuite/conformance/interfaces/aio_write/6-1.c +1 -1
@@ -62,4 +63,4 @@ int main()
 
 	printf ("Test PASSED\n");
 	return PTS_PASS;
-}
\ No newline at end of file
+}

------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#7 lore raw
In reply to Peng Haitao
Quoted 4 lines · Peng Haitao

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 return untested.

pushed, thanks,

Wanlong Gao

Quoted 70 lines
---
 .../conformance/interfaces/aio_read/8-1.c               |   13 +++++++------
 .../conformance/interfaces/aio_write/6-1.c              |   15 ++++++++-------
 2 files changed, 15 insertions(+), 13 deletions(-)
testcases/open_posix_testsuite/conformance/interfaces/aio_read/8-1.c +7 -6
index 8054eeb..ea0538e 100644
@@ -14,7 +14,8 @@
  *
  * 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.
  *	- call aio_read
  *	- check aio_read return value
  */
@@ -41,11 +42,11 @@ int main()
 	if (sysconf(_SC_ASYNCHRONOUS_IO) < 200112L)
 		return PTS_UNSUPPORTED;
 
-	/* submit a request with a NULL buffer */
-	aiocb.aio_fildes = 0;
-	aiocb.aio_buf = NULL;
-	aiocb.aio_nbytes = 0;
-	aiocb.aio_offset = 0;
+	if (sysconf(_SC_PRIORITIZED_IO) < 200112L)
+		return PTS_UNTESTED;
+
+	memset(&aiocb, 0, sizeof(struct aiocb));
+	aiocb.aio_reqprio = -1;
 
 	if (aio_read(&aiocb) != -1) {
 		printf(TNAME " aio_read() should fail!\n");
testcases/open_posix_testsuite/conformance/interfaces/aio_write/6-1.c +7 -6
index 98b8d0d..744c82c 100644
@@ -14,7 +14,8 @@
  *
  * 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
  *	- call aio_write
  *	- check aio_write return value
  *
@@ -42,11 +43,11 @@ int main()
 	if (sysconf(_SC_ASYNCHRONOUS_IO) < 200112L)
 		return PTS_UNSUPPORTED;
 
-	/* submit a request with a NULL buffer */
-	aiocb.aio_fildes = 0;
-	aiocb.aio_buf = NULL;
-	aiocb.aio_nbytes = 0;
-	aiocb.aio_offset = 0;
+	if (sysconf(_SC_PRIORITIZED_IO) < 200112L)
+		return PTS_UNTESTED;
+
+	memset(&aiocb, 0, sizeof(struct aiocb));
+	aiocb.aio_reqprio = -1;
 
 	if (aio_write(&aiocb) != -1)
 	{

testcases/open_posix_testsuite/conformance/interfaces/aio_write/6-1.c int main() · line 66

Quoted 6 lines
testcases/open_posix_testsuite/conformance/interfaces/aio_write/6-1.c +1 -1
@@ -62,4 +63,4 @@ int main()
 
 	printf ("Test PASSED\n");
 	return PTS_PASS;
-}
\ No newline at end of file
+}

------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list