From: Wanlong G. <gao...@cn...> - 2012-01-20 02:04:15
|
v1->v2: remove the useless cast (Cyril) v2->v3: change the test pass message (Cyril) Cleanup coding style first. Signed-off-by: Wanlong Gao <gao...@cn...> --- .../conformance/interfaces/aio_suspend/8-1.c | 101 ++++++++++---------- 1 files changed, 50 insertions(+), 51 deletions(-) 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 bd58c9f..27af878 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 @@ -94,57 +94,56 @@ main () unlink(tmpfname); - bufs = (char *) malloc (NUM_AIOCBS*BUF_SIZE); + bufs = 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 = 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] = malloc(sizeof(struct aiocb)); memset(aiocbs[i], 0, sizeof(struct aiocb)); aiocbs[i]->aio_fildes = fd; aiocbs[i]->aio_offset = i * BUF_SIZE; - aiocbs[i]->aio_buf = &bufs[i*BUF_SIZE]; + aiocbs[i]->aio_buf = &bufs[i * BUF_SIZE]; aiocbs[i]->aio_nbytes = BUF_SIZE; aiocbs[i]->aio_lio_opcode = LIO_READ; /* Use SIRTMIN+1 for individual completions */ aiocbs[i]->aio_sigevent.sigev_notify = SIGEV_SIGNAL; - aiocbs[i]->aio_sigevent.sigev_signo = SIGRTMIN+1; + aiocbs[i]->aio_sigevent.sigev_signo = SIGRTMIN + 1; aiocbs[i]->aio_sigevent.sigev_value.sival_int = i; } /* Use SIGRTMIN+2 for list completion */ event.sigev_notify = SIGEV_SIGNAL; - event.sigev_signo = SIGRTMIN+2; + event.sigev_signo = SIGRTMIN + 2; event.sigev_value.sival_ptr = NULL; /* Setup handler for individual operation completion */ action.sa_sigaction = sigrt1_handler; sigemptyset(&action.sa_mask); - action.sa_flags = SA_SIGINFO|SA_RESTART; - sigaction(SIGRTMIN+1, &action, NULL); + action.sa_flags = SA_SIGINFO | SA_RESTART; + sigaction(SIGRTMIN + 1, &action, NULL); /* Setup handler for list completion */ action.sa_sigaction = sigrt2_handler; sigemptyset(&action.sa_mask); - action.sa_flags = SA_SIGINFO|SA_RESTART; - sigaction(SIGRTMIN+2, &action, NULL); + action.sa_flags = SA_SIGINFO | SA_RESTART; + sigaction(SIGRTMIN + 2, &action, NULL); /* Setup suspend list */ plist[0] = NULL; @@ -155,57 +154,57 @@ main () 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); + 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", + printf(TNAME " Error : AIOCB %d already completed before 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); - close (fd); - exit (PTS_FAIL); + free(bufs); + free(aiocbs); + close(fd); + exit(PTS_FAIL); } /* 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)); + 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); + free(aiocbs[i]); + free(bufs); + free(aiocbs); + close(fd); + exit(PTS_FAIL); } /* Check selected request has completed */ - err = aio_error (aiocbs[WAIT_FOR_AIOCB]); - ret = aio_return (aiocbs[WAIT_FOR_AIOCB]); + err = aio_error(aiocbs[WAIT_FOR_AIOCB]); + ret = aio_return(aiocbs[WAIT_FOR_AIOCB]); - if ((err != 0) && (ret != BUF_SIZE)) { - printf (TNAME " Error : AIOCB %d should have completed after suspend\n", + if ((err != 0) && (ret != BUF_SIZE)) { + 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); + 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++) { @@ -220,18 +219,18 @@ main () 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("Test PASSED\n"); return PTS_PASS; -} \ No newline at end of file +} -- 1.7.9.rc2 |