Cyril Hrubis said the following on 2011-9-2 21:04: > Hi! >> So we may rather: >> >> * change the code to close the fd correctly > > Eg. in all codepaths >
I change the code to close the fd, please comment. Signed-off-by: Peng Haitao <[email protected]> --- .../conformance/interfaces/aio_cancel/7-1.c | 13 ++++++++++--- 1 files changed, 10 insertions(+), 3 deletions(-) diff --git a/testcases/open_posix_testsuite/conformance/interfaces/aio_cancel/7-1.c b/testcases/open_posix_testsuite/conformance/interfaces/aio_cancel/7-1.c index c37f184..1b4c68d 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/aio_cancel/7-1.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/aio_cancel/7-1.c @@ -78,6 +78,7 @@ int main() { printf(TNAME " Error at malloc(): %s\n", strerror(errno)); + close(fd); return PTS_UNRESOLVED; } aiocb[i]->aio_fildes = fd; @@ -86,6 +87,7 @@ int main() { printf(TNAME " Error at malloc(): %s\n", strerror(errno)); + close(fd); return PTS_UNRESOLVED; } aiocb[i]->aio_nbytes = BUF_SIZE; @@ -96,6 +98,7 @@ int main() { printf(TNAME " loop %d: Error at aio_write(): %s\n", i, strerror(errno)); + close(fd); return PTS_FAIL; } } @@ -109,11 +112,10 @@ int main() { printf(TNAME " Error at aio_cancel(): %s\n", strerror(errno)); + close(fd); return PTS_FAIL; } - close(fd); - do { in_progress = 0; for (i = 0; i < BUF_NB; i++) @@ -126,6 +128,7 @@ int main() { printf(TNAME " Error at aio_error(): %s\n", strerror(errno)); + close(fd); return PTS_FAIL; } else if (ret == EINPROGRESS) @@ -139,6 +142,7 @@ int main() if (gret != AIO_NOTCANCELED) { printf(TNAME " Error at aio_error(): %s\n", strerror(errno)); + close(fd); return PTS_FAIL; } @@ -155,11 +159,14 @@ int main() if (gret == AIO_NOTCANCELED) { printf ("Test PASSED\n"); + close(fd); return PTS_PASS; } } } } while (in_progress); + close(fd); + return PTS_UNRESOLVED; -} \ No newline at end of file +} -- 1.7.1 -- Best Regards, Peng Haitao ------------------------------------------------------------------------------ Special Offer -- Download ArcSight Logger for FREE! Finally, a world-class log management solution at an even better price-free! And you'll get a free "Love Thy Logs" t-shirt when you download Logger. Secure your free ArcSight Logger TODAY! http://p.sf.net/sfu/arcsisghtdev2dev _______________________________________________ Ltp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list
