Skip to contentSkip to conversation

posix: aio_cancel: 5-1, 6-1, 7-1: zero out the control block buffer

PATCH New Stanislav Kholmanskikh 2 participants 4 messages Dec 14, 2017 – Dec 21, 2017

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 posix: aio_cancel: 5-1, 6-1, 7-1: zero out the control block buffer

Per aio(7) it's recommended to zero out the control block buffer before use to avoid possible failures due to uninitialized fields.

---

Changes since V1:
- use calloc()

 .../conformance/interfaces/aio_cancel/5-1.c        |    2 +-
 .../conformance/interfaces/aio_cancel/6-1.c        |    2 +-
 .../conformance/interfaces/aio_cancel/7-1.c        |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
testcases/open_posix_testsuite/conformance/interfaces/aio_cancel/5-1.c +1 -1
index ece29ac..9d36c8b 100644
@@ -69,7 +69,7 @@ int main(void)
 	/* create AIO req */
 
 	for (i = 0; i < BUF_NB; i++) {
-		aiocb[i] = malloc(sizeof(struct aiocb));
+		aiocb[i] = calloc(1, sizeof(struct aiocb));
 		if (aiocb[i] == NULL) {
 			printf(TNAME " Error at malloc(): %s\n",
 			       strerror(errno));
testcases/open_posix_testsuite/conformance/interfaces/aio_cancel/6-1.c +1 -1
index 280ac15..e194f49 100644
@@ -71,7 +71,7 @@ int main(void)
 	/* create AIO req */
 
 	for (i = 0; i < BUF_NB; i++) {
-		aiocb[i] = malloc(sizeof(struct aiocb));
+		aiocb[i] = calloc(1, sizeof(struct aiocb));
 		if (aiocb[i] == NULL) {
 			printf(TNAME " Error at malloc(): %s\n",
 			       strerror(errno));
testcases/open_posix_testsuite/conformance/interfaces/aio_cancel/7-1.c +1 -1
index c205d27..5e9bccf 100644
@@ -68,7 +68,7 @@ int main(void)
 
 	/* create AIO req */
 	for (i = 0; i < BUF_NB; i++) {
-		aiocb[i] = malloc(sizeof(struct aiocb));
+		aiocb[i] = calloc(1, sizeof(struct aiocb));
 
 		if (aiocb[i] == NULL) {
 			printf(TNAME " Error@malloc(): %s\n",
Signature · 1 line
1.7.1
#1 lore raw

PATCH v2 2/2 posix: aio_error: 2-1: zero out the control block buffer

Per aio(7) it's recommended to zero out the control block buffer before use to avoid possible failures due to uninitialized fields.

---
Changes since V1:
- use calloc()

 .../conformance/interfaces/aio_error/2-1.c         |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
testcases/open_posix_testsuite/conformance/interfaces/aio_error/2-1.c +1 -1
index 12319dc..9ce2916 100644
@@ -63,7 +63,7 @@ int main(void)
 	/* create AIO req */
 
 	for (i = 0; i < BUF_NB; i++) {
-		aiocb[i] = malloc(sizeof(struct aiocb));
+		aiocb[i] = calloc(1, sizeof(struct aiocb));
 		if (aiocb[i] == NULL) {
 			printf(TNAME " Error@malloc(): %s\n",
 			       strerror(errno));
Signature · 1 line
1.7.1
#3 lore raw

PATCH v2 1/2 posix: aio_cancel: 5-1, 6-1, 7-1: zero out the control block buffer

Thank you.

Pushed.

Quoted 3 lines · Cyril Hrubis

Hi!
These two patches are obviously OK, acked.