fix the coding style.
Signed-off-by: Wanlong Gao <[email protected]>
---
.../conformance/interfaces/aio_suspend/1-1.c | 25 ++--
.../conformance/interfaces/aio_suspend/3-1.c | 18 +--
.../conformance/interfaces/aio_suspend/4-1.c | 125 ++++++++++----------
.../conformance/interfaces/aio_suspend/6-1.c | 96 ++++++++--------
.../conformance/interfaces/aio_suspend/7-1.c | 40 ++++---
.../conformance/interfaces/aio_suspend/8-1.c | 27 ++--
.../conformance/interfaces/aio_suspend/9-1.c | 127 ++++++++++----------
7 files changed, 226 insertions(+), 232 deletions(-)
diff --git
a/testcases/open_posix_testsuite/conformance/interfaces/aio_suspend/1-1.c
b/testcases/open_posix_testsuite/conformance/interfaces/aio_suspend/1-1.c
index 01b9a00..11e2dbf 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/aio_suspend/1-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/aio_suspend/1-1.c
@@ -41,27 +41,24 @@
#define TNAME "aio_suspend/1-1.c"
#define NUM_AIOCBS 10
-#define BUF_SIZE 1024*1024
+#define BUF_SIZE (1024*1024)
#define WAIT_FOR_AIOCB 6
-int received_selected = 0;
-int received_all = 0;
+static int received_selected;
+static int received_all;
-void
-sigrt1_handler(int signum, siginfo_t *info, void *context)
+static void sigrt1_handler(int signum, siginfo_t *info, void *context)
{
if (info->si_value.sival_int == WAIT_FOR_AIOCB)
received_selected = 1;
}
-void
-sigrt2_handler(int signum, siginfo_t *info, void *context)
+static void sigrt2_handler(int signum, siginfo_t *info, void *context)
{
received_all = 1;
}
-int
-main(void)
+int main(void)
{
char tmpfname[256];
int fd;
@@ -108,12 +105,12 @@ main(void)
exit(PTS_UNRESOLVED);
}
- aiocbs = (struct aiocb**)malloc(sizeof(struct aiocb *) * NUM_AIOCBS);
+ aiocbs = (struct aiocb **)malloc(sizeof(struct aiocb *) * NUM_AIOCBS);
/* Queue up a bunch of aio reads */
for (i = 0; i < NUM_AIOCBS; i++) {
- aiocbs[i] = (struct aiocb*)malloc(sizeof(struct aiocb));
+ aiocbs[i] = (struct aiocb *)malloc(sizeof(struct aiocb));
memset(aiocbs[i], 0, sizeof(struct aiocb));
aiocbs[i]->aio_fildes = fd;
@@ -182,7 +179,7 @@ main(void)
if (!received_selected) {
printf(TNAME " Error : AIOCB %d should have completed after "
"suspend\n", WAIT_FOR_AIOCB);
- for (i=0; i<NUM_AIOCBS; i++)
+ for (i = 0; i < NUM_AIOCBS; i++)
free(aiocbs[i]);
free(bufs);
free(aiocbs);
@@ -208,7 +205,7 @@ main(void)
/* Check return code and free things */
for (i = 0; i < NUM_AIOCBS; i++) {
do {
- err = aio_error(aiocbs[i]);
+ err = aio_error(aiocbs[i]);
} while (err == EINPROGRESS);
ret = aio_return(aiocbs[i]);
@@ -232,4 +229,4 @@ main(void)
printf(TNAME " PASSED\n");
return PTS_PASS;
-}
\ No newline at end of file
+}
diff --git
a/testcases/open_posix_testsuite/conformance/interfaces/aio_suspend/3-1.c
b/testcases/open_posix_testsuite/conformance/interfaces/aio_suspend/3-1.c
index bece700..15120e1 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/aio_suspend/3-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/aio_suspend/3-1.c
@@ -55,8 +55,7 @@ int main()
unlink(tmpfname);
fd = open(tmpfname, O_CREAT | O_RDWR | O_EXCL,
S_IRUSR | S_IWUSR);
- if (fd == -1)
- {
+ if (fd == -1) {
printf(TNAME " Error at open(): %s\n",
strerror(errno));
exit(PTS_UNRESOLVED);
@@ -64,18 +63,16 @@ int main()
unlink(tmpfname);
- for (i = 0; i < NAIOCB; i++)
- {
+ for (i = 0; i < NAIOCB; i++) {
memset(&aiocb[i], 0, sizeof(struct aiocb));
aiocb[i].aio_fildes = fd;
aiocb[i].aio_buf = buf;
aiocb[i].aio_offset = i * BUF_SIZE;
aiocb[i].aio_nbytes = BUF_SIZE;
- if (aio_write(&aiocb[i]) == -1)
- {
+ if (aio_write(&aiocb[i]) == -1) {
printf(TNAME " Error at aio_write(): %s\n",
- strerror(errno));
+ strerror(errno));
exit(PTS_FAIL);
}
}
@@ -85,13 +82,12 @@ int main()
list[5] = &aiocb[1];
list[6] = &aiocb[2];
- if (aio_suspend(list, NENT, NULL) != 0)
- {
+ if (aio_suspend(list, NENT, NULL) != 0) {
printf(TNAME " Error at aio_suspend(): %s\n", strerror(errno));
exit(PTS_FAIL);
}
close(fd);
- printf ("Test PASSED\n");
+ printf("Test PASSED\n");
return PTS_PASS;
-}
\ No newline at end of file
+}
diff --git
a/testcases/open_posix_testsuite/conformance/interfaces/aio_suspend/4-1.c
b/testcases/open_posix_testsuite/conformance/interfaces/aio_suspend/4-1.c
index 21451b6..445e180 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/aio_suspend/4-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/aio_suspend/4-1.c
@@ -38,26 +38,23 @@
#define TNAME "aio_suspend/4-1.c"
#define NUM_AIOCBS 10
-#define BUF_SIZE 1024*1024
+#define BUF_SIZE (1024*1024)
#define WAIT_FOR_AIOCB 6
-int received_selected = 0;
-int received_all = 0;
+static int received_selected;
+static int received_all;
-void
-sigrt1_handler(int signum, siginfo_t *info, void *context)
+static void sigrt1_handler(int signum, siginfo_t *info, void *context)
{
received_selected = 1;
}
-void
-sigrt2_handler(int signum, siginfo_t *info, void *context)
+static void sigrt2_handler(int signum, siginfo_t *info, void *context)
{
received_all = 1;
}
-int
-main ()
+int main()
{
char tmpfname[256];
int fd;
@@ -90,27 +87,27 @@ main ()
unlink(tmpfname);
- bufs = (char *) malloc (NUM_AIOCBS*BUF_SIZE);
+ bufs = (char *) malloc(NUM_AIOCBS*BUF_SIZE);
if (bufs == NULL) {
- printf (TNAME " Error at malloc(): %s\n", strerror (errno));
- close (fd);
+ printf(TNAME " Error at malloc(): %s\n", strerror(errno));
+ close(fd);
exit(PTS_UNRESOLVED);
}
- if (write (fd, bufs, NUM_AIOCBS*BUF_SIZE) != (NUM_AIOCBS*BUF_SIZE)) {
+ if (write(fd, bufs, NUM_AIOCBS*BUF_SIZE) != (NUM_AIOCBS*BUF_SIZE)) {
printf(TNAME " Error at write(): %s\n", strerror(errno));
- free (bufs);
- close (fd);
+ free(bufs);
+ close(fd);
exit(PTS_UNRESOLVED);
}
- aiocbs = (struct aiocb**)malloc(sizeof(struct aiocb *) * NUM_AIOCBS);
+ aiocbs = (struct aiocb **)malloc(sizeof(struct aiocb *) * NUM_AIOCBS);
/* Queue up a bunch of aio reads */
for (i = 0; i < NUM_AIOCBS; i++) {
- aiocbs[i] = (struct aiocb*)malloc(sizeof(struct aiocb));
+ aiocbs[i] = (struct aiocb *)malloc(sizeof(struct aiocb));
memset(aiocbs[i], 0, sizeof(struct aiocb));
aiocbs[i]->aio_fildes = fd;
@@ -152,25 +149,26 @@ main ()
ret = lio_listio(LIO_NOWAIT, aiocbs, NUM_AIOCBS, &event);
if (ret) {
- printf(TNAME " Error at lio_listio() %d: %s\n", errno,
strerror(errno));
- for (i=0; i<NUM_AIOCBS; i++)
- free (aiocbs[i]);
- free (bufs);
- free (aiocbs);
- close (fd);
- exit (PTS_UNRESOLVED);
+ printf(TNAME " Error at lio_listio() %d: %s\n",
+ errno, strerror(errno));
+ for (i = 0; i < NUM_AIOCBS; i++)
+ free(aiocbs[i]);
+ free(bufs);
+ free(aiocbs);
+ close(fd);
+ exit(PTS_UNRESOLVED);
}
/* Check selected request has not completed yet */
if (received_selected) {
- printf (TNAME " Error : AIOCB %d already completed before
suspend\n",
- WAIT_FOR_AIOCB);
- for (i=0; i<NUM_AIOCBS; i++)
- free (aiocbs[i]);
- free (bufs);
- free (aiocbs);
- close (fd);
- exit (PTS_FAIL);
+ printf(TNAME " Error : AIOCB %d already completed"
+ " before suspend\n", WAIT_FOR_AIOCB);
+ for (i = 0; i < NUM_AIOCBS; i++)
+ free(aiocbs[i]);
+ free(bufs);
+ free(aiocbs);
+ close(fd);
+ exit(PTS_FAIL);
}
/* Suspend on selected request */
@@ -178,64 +176,65 @@ main ()
/* Check selected request has not completed */
if (received_selected) {
- printf (TNAME " Error : AIOCB %d should not have completed
after timed out suspend\n",
- WAIT_FOR_AIOCB);
- for (i=0; i<NUM_AIOCBS; i++)
- free (aiocbs[i]);
- free (bufs);
- free (aiocbs);
- close (fd);
- exit (PTS_FAIL);
+ printf(TNAME " Error : AIOCB %d should not have completed"
+ " after timed out suspend\n", WAIT_FOR_AIOCB);
+ for (i = 0; i < NUM_AIOCBS; i++)
+ free(aiocbs[i]);
+ free(bufs);
+ free(aiocbs);
+ close(fd);
+ exit(PTS_FAIL);
}
/* timed out aio_suspend should return -1 and set errno to EAGAIN */
if (ret != -1) {
- printf (TNAME " aio_suspend() should return -1\n");
- for (i=0; i<NUM_AIOCBS; i++)
- free (aiocbs[i]);
- free (bufs);
- free (aiocbs);
- close (fd);
- exit (PTS_FAIL);
+ printf(TNAME " aio_suspend() should return -1\n");
+ for (i = 0; i < NUM_AIOCBS; i++)
+ free(aiocbs[i]);
+ free(bufs);
+ free(aiocbs);
+ close(fd);
+ exit(PTS_FAIL);
}
if (errno != EAGAIN) {
- printf (TNAME " aio_suspend() should set errno to EAGAIN: %d
(%s)\n",
- errno, strerror (errno));
- for (i=0; i<NUM_AIOCBS; i++)
- free (aiocbs[i]);
- free (bufs);
- free (aiocbs);
- close (fd);
- exit (PTS_FAIL);
+ printf(TNAME " aio_suspend() should set errno to EAGAIN:"
+ " %d (%s)\n", errno, strerror(errno));
+ for (i = 0; i < NUM_AIOCBS; i++)
+ free(aiocbs[i]);
+ free(bufs);
+ free(aiocbs);
+ close(fd);
+ exit(PTS_FAIL);
}
/* Wait for list processing completion */
while (!received_all)
- sleep (1);
+ sleep(1);
/* Check return code and free things */
for (i = 0; i < NUM_AIOCBS; i++) {
- err = aio_error(aiocbs[i]);
+ err = aio_error(aiocbs[i]);
ret = aio_return(aiocbs[i]);
if ((err != 0) && (ret != BUF_SIZE)) {
- printf(TNAME " req %d: error = %d - return = %d\n", i,
err, ret);
+ printf(TNAME " req %d: error = %d - return = %d\n",
+ i, err, ret);
errors++;
}
- free (aiocbs[i]);
+ free(aiocbs[i]);
}
- free (bufs);
- free (aiocbs);
+ free(bufs);
+ free(aiocbs);
close(fd);
if (errors != 0)
- exit (PTS_FAIL);
+ exit(PTS_FAIL);
- printf (TNAME " PASSED\n");
+ printf(TNAME " PASSED\n");
return PTS_PASS;
}
diff --git
a/testcases/open_posix_testsuite/conformance/interfaces/aio_suspend/6-1.c
b/testcases/open_posix_testsuite/conformance/interfaces/aio_suspend/6-1.c
index df610b1..c224e37 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/aio_suspend/6-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/aio_suspend/6-1.c
@@ -37,27 +37,24 @@
#define TNAME "aio_suspend/6-1.c"
#define NUM_AIOCBS 10
-#define BUF_SIZE 1024*1024
+#define BUF_SIZE (1024*1024)
#define WAIT_FOR_AIOCB 6
-int received_selected = 0;
-int received_all = 0;
+static int received_selected;
+static int received_all;
-void
-sigrt1_handler(int signum, siginfo_t *info, void *context)
+static void sigrt1_handler(int signum, siginfo_t *info, void *context)
{
if (info->si_value.sival_int == WAIT_FOR_AIOCB)
received_selected = 1;
}
-void
-sigrt2_handler(int signum, siginfo_t *info, void *context)
+static void sigrt2_handler(int signum, siginfo_t *info, void *context)
{
received_all = 1;
}
-int
-main ()
+int main()
{
char tmpfname[256];
int fd;
@@ -89,27 +86,27 @@ main ()
unlink(tmpfname);
- bufs = (char *) malloc (NUM_AIOCBS*BUF_SIZE);
+ bufs = (char *) malloc(NUM_AIOCBS*BUF_SIZE);
if (bufs == NULL) {
- printf (TNAME " Error at malloc(): %s\n", strerror (errno));
- close (fd);
+ printf(TNAME " Error at malloc(): %s\n", strerror(errno));
+ close(fd);
exit(PTS_UNRESOLVED);
}
- if (write (fd, bufs, NUM_AIOCBS*BUF_SIZE) != (NUM_AIOCBS*BUF_SIZE)) {
+ if (write(fd, bufs, NUM_AIOCBS*BUF_SIZE) != (NUM_AIOCBS*BUF_SIZE)) {
printf(TNAME " Error at write(): %s\n", strerror(errno));
- free (bufs);
- close (fd);
+ free(bufs);
+ close(fd);
exit(PTS_UNRESOLVED);
}
- aiocbs = (struct aiocb**)malloc(sizeof(struct aiocb *) * NUM_AIOCBS);
+ aiocbs = (struct aiocb **)malloc(sizeof(struct aiocb *) * NUM_AIOCBS);
/* Queue up a bunch of aio reads */
for (i = 0; i < NUM_AIOCBS; i++) {
- aiocbs[i] = (struct aiocb*)malloc(sizeof(struct aiocb));
+ aiocbs[i] = (struct aiocb *)malloc(sizeof(struct aiocb));
memset(aiocbs[i], 0, sizeof(struct aiocb));
aiocbs[i]->aio_fildes = fd;
@@ -149,13 +146,14 @@ main ()
ret = lio_listio(LIO_NOWAIT, aiocbs, NUM_AIOCBS, &event);
if (ret) {
- printf(TNAME " Error at lio_listio() %d: %s\n", errno,
strerror(errno));
- for (i=0; i<NUM_AIOCBS; i++)
- free (aiocbs[i]);
- free (bufs);
- free (aiocbs);
- close (fd);
- exit (PTS_UNRESOLVED);
+ printf(TNAME " Error at lio_listio() %d: %s\n",
+ errno, strerror(errno));
+ for (i = 0; i < NUM_AIOCBS; i++)
+ free(aiocbs[i]);
+ free(bufs);
+ free(aiocbs);
+ close(fd);
+ exit(PTS_UNRESOLVED);
}
/* Suspend on selected request */
@@ -163,52 +161,54 @@ main ()
/* Check selected request has completed */
if (!received_selected) {
- printf (TNAME " Error : AIOCB %d should have completed after
suspend\n",
- WAIT_FOR_AIOCB);
- for (i=0; i<NUM_AIOCBS; i++)
- free (aiocbs[i]);
- free (bufs);
- free (aiocbs);
- close (fd);
- exit (PTS_FAIL);
+ printf(TNAME " Error : AIOCB %d should have completed"
+ " after suspend\n", WAIT_FOR_AIOCB);
+ for (i = 0; i < NUM_AIOCBS; i++)
+ free(aiocbs[i]);
+ free(bufs);
+ free(aiocbs);
+ close(fd);
+ exit(PTS_FAIL);
}
if (ret) {
- printf (TNAME " Error at aio_suspend() %d: %s\n", errno,
strerror (errno));
- for (i=0; i<NUM_AIOCBS; i++)
- free (aiocbs[i]);
- free (bufs);
- free (aiocbs);
- close (fd);
- exit (PTS_FAIL);
+ printf(TNAME " Error at aio_suspend() %d: %s\n",
+ errno, strerror(errno));
+ for (i = 0; i < NUM_AIOCBS; i++)
+ free(aiocbs[i]);
+ free(bufs);
+ free(aiocbs);
+ close(fd);
+ exit(PTS_FAIL);
}
/* Wait for list processing completion */
while (!received_all)
- sleep (1);
+ sleep(1);
/* Check return code and free things */
for (i = 0; i < NUM_AIOCBS; i++) {
- err = aio_error(aiocbs[i]);
+ err = aio_error(aiocbs[i]);
ret = aio_return(aiocbs[i]);
if ((err != 0) && (ret != BUF_SIZE)) {
- printf(TNAME " req %d: error = %d - return = %d\n", i,
err, ret);
+ printf(TNAME " req %d: error = %d - return = %d\n",
+ i, err, ret);
errors++;
}
- free (aiocbs[i]);
+ free(aiocbs[i]);
}
- free (bufs);
- free (aiocbs);
+ free(bufs);
+ free(aiocbs);
close(fd);
if (errors != 0)
- exit (PTS_FAIL);
+ exit(PTS_FAIL);
- printf (TNAME " PASSED\n");
+ printf(TNAME " PASSED\n");
return PTS_PASS;
-}
\ No newline at end of file
+}
diff --git
a/testcases/open_posix_testsuite/conformance/interfaces/aio_suspend/7-1.c
b/testcases/open_posix_testsuite/conformance/interfaces/aio_suspend/7-1.c
index fc79519..9666f7c 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/aio_suspend/7-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/aio_suspend/7-1.c
@@ -38,12 +38,12 @@
#define TNAME "aio_suspend/7-1.c"
#define NUM_AIOCBS 10
-#define BUF_SIZE 1024*1024
+#define BUF_SIZE (1024*1024)
#define WAIT_FOR_AIOCB 6
-int received_all = 0;
+static int received_all;
-void sigrt1_handler(int signum, siginfo_t *info, void *context)
+static void sigrt1_handler(int signum, siginfo_t *info, void *context)
{
received_all = 1;
}
@@ -89,7 +89,7 @@ int main(void)
exit(PTS_UNRESOLVED);
}
- if (write (fd, bufs, NUM_AIOCBS*BUF_SIZE) != (NUM_AIOCBS*BUF_SIZE)) {
+ if (write(fd, bufs, NUM_AIOCBS*BUF_SIZE) != (NUM_AIOCBS*BUF_SIZE)) {
printf(TNAME " Error at write(): %s\n", strerror(errno));
free(bufs);
close(fd);
@@ -101,7 +101,7 @@ int main(void)
/* Queue up a bunch of aio reads */
for (i = 0; i < NUM_AIOCBS; i++) {
- aiocbs[i] = (struct aiocb*)malloc(sizeof(struct aiocb));
+ aiocbs[i] = (struct aiocb *)malloc(sizeof(struct aiocb));
memset(aiocbs[i], 0, sizeof(struct aiocb));
aiocbs[i]->aio_fildes = fd;
@@ -130,8 +130,9 @@ int main(void)
ret = lio_listio(LIO_NOWAIT, aiocbs, NUM_AIOCBS, &event);
if (ret) {
- printf(TNAME " Error at lio_listio() %d: %s\n", errno,
strerror(errno));
- for (i=0; i<NUM_AIOCBS; i++)
+ printf(TNAME " Error at lio_listio() %d: %s\n",
+ errno, strerror(errno));
+ for (i = 0; i < NUM_AIOCBS; i++)
free(aiocbs[i]);
free(bufs);
free(aiocbs);
@@ -141,9 +142,9 @@ int main(void)
/* Check selected request has not completed yet */
if (aio_error(aiocbs[WAIT_FOR_AIOCB]) != EINPROGRESS) {
- printf(TNAME " Error : AIOCB %d already completed before
suspend\n",
- WAIT_FOR_AIOCB);
- for (i=0; i<NUM_AIOCBS; i++)
+ printf(TNAME " Error : AIOCB %d already completed"
+ " before suspend\n", WAIT_FOR_AIOCB);
+ for (i = 0; i < NUM_AIOCBS; i++)
free(aiocbs[i]);
free(bufs);
free(aiocbs);
@@ -156,9 +157,9 @@ int main(void)
/* Check selected request has not completed */
if (aio_error(aiocbs[WAIT_FOR_AIOCB]) != EINPROGRESS) {
- printf(TNAME " Error : AIOCB %d should not have completed after
timed out suspend\n",
- WAIT_FOR_AIOCB);
- for (i=0; i<NUM_AIOCBS; i++)
+ printf(TNAME " Error : AIOCB %d should not have completed"
+ " after timed out suspend\n", WAIT_FOR_AIOCB);
+ for (i = 0; i < NUM_AIOCBS; i++)
free(aiocbs[i]);
free(bufs);
free(aiocbs);
@@ -169,7 +170,7 @@ int main(void)
/* timed out aio_suspend should return -1 and set errno to EAGAIN */
if (ret != -1) {
printf(TNAME " aio_suspend() should return -1\n");
- for (i=0; i<NUM_AIOCBS; i++)
+ for (i = 0; i < NUM_AIOCBS; i++)
free(aiocbs[i]);
free(bufs);
free(aiocbs);
@@ -178,9 +179,9 @@ int main(void)
}
if (errno != EAGAIN) {
- printf(TNAME " aio_suspend() should set errno to EAGAIN: %d
(%s)\n",
- errno, strerror(errno));
- for (i=0; i<NUM_AIOCBS; i++)
+ printf(TNAME " aio_suspend() should set errno to EAGAIN:"
+ " %d (%s)\n", errno, strerror(errno));
+ for (i = 0; i < NUM_AIOCBS; i++)
free(aiocbs[i]);
free(bufs);
free(aiocbs);
@@ -194,11 +195,12 @@ int main(void)
/* Check return code and free things */
for (i = 0; i < NUM_AIOCBS; i++) {
- err = aio_error(aiocbs[i]);
+ err = aio_error(aiocbs[i]);
ret = aio_return(aiocbs[i]);
if ((err != 0) && (ret != BUF_SIZE)) {
- printf(TNAME " req %d: error = %d - return = %d\n", i,
err, ret);
+ printf(TNAME " req %d: error = %d - return = %d\n",
+ i, err, ret);
errors++;
}
diff --git
a/testcases/open_posix_testsuite/conformance/interfaces/aio_suspend/8-1.c
b/testcases/open_posix_testsuite/conformance/interfaces/aio_suspend/8-1.c
index 743e510..a2a6b0c 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/aio_suspend/8-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/aio_suspend/8-1.c
@@ -42,20 +42,18 @@
#define TNAME "aio_suspend/8-1.c"
#define NUM_AIOCBS 10
-#define BUF_SIZE 1024*1024
+#define BUF_SIZE (1024*1024)
#define WAIT_FOR_AIOCB 6
-int received_selected = 0;
-int received_all = 0;
+static int received_selected;
+static int received_all;
-void
-sigrt1_handler(int signum, siginfo_t *info, void *context)
+static void sigrt1_handler(int signum, siginfo_t *info, void *context)
{
received_all = 1;
}
-int
-main ()
+int main()
{
char tmpfname[256];
int fd;
@@ -135,7 +133,8 @@ main ()
ret = lio_listio(LIO_NOWAIT, aiocbs, NUM_AIOCBS, &event);
if (ret) {
- printf(TNAME " Error at lio_listio() %d: %s\n", errno,
strerror(errno));
+ printf(TNAME " Error at lio_listio() %d: %s\n",
+ errno, strerror(errno));
for (i = 0; i < NUM_AIOCBS; i++)
free(aiocbs[i]);
free(bufs);
@@ -147,8 +146,9 @@ main ()
/* Suspend on selected request */
ret = aio_suspend((const struct aiocb **)plist, 2, NULL);
if (ret) {
- printf(TNAME " Error at aio_suspend() %d: %s\n", errno,
strerror(errno));
- for (i=0; i<NUM_AIOCBS; i++)
+ printf(TNAME " Error at aio_suspend() %d: %s\n",
+ errno, strerror(errno));
+ for (i = 0; i < NUM_AIOCBS; i++)
free(aiocbs[i]);
free(bufs);
free(aiocbs);
@@ -161,8 +161,8 @@ main ()
ret = aio_return(aiocbs[WAIT_FOR_AIOCB]);
if ((err != 0) && (ret != BUF_SIZE)) {
- printf(TNAME " Error : AIOCB %d should have completed after
suspend\n",
- WAIT_FOR_AIOCB);
+ printf(TNAME " Error : AIOCB %d should have completed"
+ " after suspend\n", WAIT_FOR_AIOCB);
for (i = 0; i < NUM_AIOCBS; i++)
free(aiocbs[i]);
free(bufs);
@@ -184,7 +184,8 @@ main ()
ret = aio_return(aiocbs[i]);
if ((err != 0) && (ret != BUF_SIZE)) {
- printf(TNAME " req %d: error = %d - return = %d\n", i,
err, ret);
+ printf(TNAME " req %d: error = %d - return = %d\n",
+ i, err, ret);
errors++;
}
diff --git
a/testcases/open_posix_testsuite/conformance/interfaces/aio_suspend/9-1.c
b/testcases/open_posix_testsuite/conformance/interfaces/aio_suspend/9-1.c
index 4d5583a..87ab4d5 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/aio_suspend/9-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/aio_suspend/9-1.c
@@ -38,27 +38,24 @@
#define TNAME "aio_suspend/9-1.c"
#define NUM_AIOCBS 10
-#define BUF_SIZE 1024*1024
+#define BUF_SIZE (1024*1024)
#define WAIT_FOR_AIOCB 6
-int received_selected = 0;
-int received_all = 0;
+static int received_selected;
+static int received_all;
-void
-sigrt1_handler(int signum, siginfo_t *info, void *context)
+static void sigrt1_handler(int signum, siginfo_t *info, void *context)
{
if (info->si_value.sival_int == WAIT_FOR_AIOCB)
received_selected = 1;
}
-void
-sigrt2_handler(int signum, siginfo_t *info, void *context)
+static void sigrt2_handler(int signum, siginfo_t *info, void *context)
{
received_all = 1;
}
-int
-main ()
+int main()
{
char tmpfname[256];
int fd;
@@ -91,27 +88,27 @@ main ()
unlink(tmpfname);
- bufs = (char *) malloc (NUM_AIOCBS*BUF_SIZE);
+ bufs = (char *)malloc(NUM_AIOCBS*BUF_SIZE);
if (bufs == NULL) {
- printf (TNAME " Error at malloc(): %s\n", strerror (errno));
- close (fd);
+ printf(TNAME " Error at malloc(): %s\n", strerror(errno));
+ close(fd);
exit(PTS_UNRESOLVED);
}
- if (write (fd, bufs, NUM_AIOCBS*BUF_SIZE) != (NUM_AIOCBS*BUF_SIZE)) {
+ if (write(fd, bufs, NUM_AIOCBS*BUF_SIZE) != (NUM_AIOCBS*BUF_SIZE)) {
printf(TNAME " Error at write(): %s\n", strerror(errno));
- free (bufs);
- close (fd);
+ free(bufs);
+ close(fd);
exit(PTS_UNRESOLVED);
}
- aiocbs = (struct aiocb**)malloc(sizeof(struct aiocb *) * NUM_AIOCBS);
+ aiocbs = (struct aiocb **)malloc(sizeof(struct aiocb *) * NUM_AIOCBS);
/* Queue up a bunch of aio reads */
for (i = 0; i < NUM_AIOCBS; i++) {
- aiocbs[i] = (struct aiocb*)malloc(sizeof(struct aiocb));
+ aiocbs[i] = (struct aiocb *)malloc(sizeof(struct aiocb));
memset(aiocbs[i], 0, sizeof(struct aiocb));
aiocbs[i]->aio_fildes = fd;
@@ -151,25 +148,26 @@ main ()
ret = lio_listio(LIO_NOWAIT, aiocbs, NUM_AIOCBS, &event);
if (ret) {
- printf(TNAME " Error at lio_listio() %d: %s\n", errno,
strerror(errno));
- for (i=0; i<NUM_AIOCBS; i++)
- free (aiocbs[i]);
- free (bufs);
- free (aiocbs);
- close (fd);
- exit (PTS_UNRESOLVED);
+ printf(TNAME " Error at lio_listio() %d: %s\n",
+ errno, strerror(errno));
+ for (i = 0; i < NUM_AIOCBS; i++)
+ free(aiocbs[i]);
+ free(bufs);
+ free(aiocbs);
+ close(fd);
+ exit(PTS_UNRESOLVED);
}
/* Check selected request has not completed yet */
if (received_selected) {
- printf (TNAME " Error : AIOCB %d already completed before
suspend\n",
- WAIT_FOR_AIOCB);
- for (i=0; i<NUM_AIOCBS; i++)
- free (aiocbs[i]);
- free (bufs);
- free (aiocbs);
- close (fd);
- exit (PTS_FAIL);
+ printf(TNAME " Error : AIOCB %d already completed"
+ " before suspend\n", WAIT_FOR_AIOCB);
+ for (i = 0; i < NUM_AIOCBS; i++)
+ free(aiocbs[i]);
+ free(bufs);
+ free(aiocbs);
+ close(fd);
+ exit(PTS_FAIL);
}
/* Suspend on selected request */
@@ -177,64 +175,65 @@ main ()
/* Check selected request has not completed */
if (received_selected) {
- printf (TNAME " Error : AIOCB %d should not have completed
after timed out suspend\n",
- WAIT_FOR_AIOCB);
- for (i=0; i<NUM_AIOCBS; i++)
- free (aiocbs[i]);
- free (bufs);
- free (aiocbs);
- close (fd);
- exit (PTS_FAIL);
+ printf(TNAME " Error : AIOCB %d should not have completed"
+ " after timed out suspend\n", WAIT_FOR_AIOCB);
+ for (i = 0; i < NUM_AIOCBS; i++)
+ free(aiocbs[i]);
+ free(bufs);
+ free(aiocbs);
+ close(fd);
+ exit(PTS_FAIL);
}
/* timed out aio_suspend should return -1 and set errno to EAGAIN */
if (ret != -1) {
- printf (TNAME " aio_suspend() should return -1\n");
- for (i=0; i<NUM_AIOCBS; i++)
- free (aiocbs[i]);
- free (bufs);
- free (aiocbs);
- close (fd);
- exit (PTS_FAIL);
+ printf(TNAME " aio_suspend() should return -1\n");
+ for (i = 0; i < NUM_AIOCBS; i++)
+ free(aiocbs[i]);
+ free(bufs);
+ free(aiocbs);
+ close(fd);
+ exit(PTS_FAIL);
}
if (errno != EAGAIN) {
- printf (TNAME " aio_suspend() should set errno to EAGAIN: %d
(%s)\n",
- errno, strerror (errno));
- for (i=0; i<NUM_AIOCBS; i++)
- free (aiocbs[i]);
- free (bufs);
- free (aiocbs);
- close (fd);
- exit (PTS_FAIL);
+ printf(TNAME " aio_suspend() should set errno to EAGAIN:"
+ " %d (%s)\n", errno, strerror(errno));
+ for (i = 0; i < NUM_AIOCBS; i++)
+ free(aiocbs[i]);
+ free(bufs);
+ free(aiocbs);
+ close(fd);
+ exit(PTS_FAIL);
}
/* Wait for list processing completion */
while (!received_all)
- sleep (1);
+ sleep(1);
/* Check return code and free things */
for (i = 0; i < NUM_AIOCBS; i++) {
- err = aio_error(aiocbs[i]);
+ err = aio_error(aiocbs[i]);
ret = aio_return(aiocbs[i]);
if ((err != 0) && (ret != BUF_SIZE)) {
- printf(TNAME " req %d: error = %d - return = %d\n", i,
err, ret);
+ printf(TNAME " req %d: error = %d - return = %d\n",
+ i, err, ret);
errors++;
}
- free (aiocbs[i]);
+ free(aiocbs[i]);
}
- free (bufs);
- free (aiocbs);
+ free(bufs);
+ free(aiocbs);
close(fd);
if (errors != 0)
- exit (PTS_FAIL);
+ exit(PTS_FAIL);
- printf (TNAME " PASSED\n");
+ printf(TNAME " PASSED\n");
return PTS_PASS;
-}
\ No newline at end of file
+}
--
1.7.9
------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list