postponing close() after aio_write() has finished II and cleanups
PATCH 1/1 postponing close() after aio_write() has finished II and cleanups
Hi,
I've fixed all the sources in the aio_return directory (from the same errors as previous one) and cleaned the coding style a little.
Signature · 2 lines
Cyril Hrubis [email protected]
testcases/open_posix_testsuite/conformance/interfaces/aio_return/1-1.c +14 -16
@@ -34,15 +34,14 @@#include "posixtest.h" #define TNAME "aio_return/1-1.c" +#define BUF_SIZE 111 -int main () +int main (void ) {char tmpfname[256 ]; -#define BUF_SIZE 111char buf[BUF_SIZE ]; -int fd;struct aiocb aiocb; -int retval; +int fd, retval;#if _POSIX_ASYNCHRONOUS_IO !=200112L exit (PTS_UNSUPPORTED );
@@ -53,8 +52,8 @@ 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 );
@@ -65,20 +64,19 @@ int main()memset (buf,0xaa ,BUF_SIZE );memset (&aiocb,0 ,sizeof (struct aiocb )); aiocb.aio_fildes = fd; - aiocb.aio_buf = buf; + aiocb.aio_buf = buf; aiocb.aio_nbytes =BUF_SIZE ; -if (aio_write (&aiocb) ==-1 ) - { +if (aio_write (&aiocb) ==-1 ) { +close (fd);printf (TNAME " Error at aio_write(): %s\n" ,strerror (errno));exit (PTS_FAIL ); } do { - retval = aio_error( &aiocb); - if (retval == -1) - { + retval = aio_error(&aiocb); + if (retval == -1) { close(fd); printf(TNAME " Error at aio_error(): %s\n", strerror(errno));
@@ -87,8 +85,8 @@ int main() }while (retval ==EINPROGRESS ); retval =aio_return (&aiocb); -if (retval !=BUF_SIZE ) - { + +if (retval !=BUF_SIZE ) {close (fd);printf (TNAME " Error at aio_return(): %s\n" ,strerror (errno));
@@ -96,6 +94,6 @@ int main() }close (fd); -printf ("Test PASSED\n" ); -return PTS_PASS ; +printf ("Test PASSED\n" ); +exit (PTS_PASS ); }
testcases/open_posix_testsuite/conformance/interfaces/aio_return/2-1.c +19 -20
@@ -31,15 +31,14 @@#include "posixtest.h" #define TNAME "aio_return/2-1.c" +#define BUF_SIZE 111 -int main () +int main (void ) {char tmpfname[256 ]; -#define BUF_SIZE 111char buf[BUF_SIZE ]; -int fd;struct aiocb aiocb; -int retval; +int fd, retval;#if _POSIX_ASYNCHRONOUS_IO !=200112L exit (PTS_UNSUPPORTED );
@@ -50,8 +49,8 @@ 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 );
@@ -62,22 +61,20 @@ int main()memset (buf,0xaa ,BUF_SIZE );memset (&aiocb,0 ,sizeof (struct aiocb )); aiocb.aio_fildes = fd; - aiocb.aio_buf = buf; + aiocb.aio_buf = buf; aiocb.aio_nbytes =BUF_SIZE ; -if (aio_write (&aiocb) ==-1 ) - { +if (aio_write (&aiocb) ==-1 ) { +close (fd);printf (TNAME " Error at aio_write(): %s\n" ,strerror (errno));exit (PTS_FAIL ); } -close (fd); - do { - retval = aio_error( &aiocb); - if (retval == -1) - { + retval = aio_error(&aiocb); + if (retval == -1) { + close(fd); printf(TNAME " Error at aio_error(): %s\n", strerror(errno)); exit(PTS_FAIL);
@@ -85,8 +82,9 @@ int main() }while (retval ==EINPROGRESS ); retval =aio_return (&aiocb); -if (retval !=BUF_SIZE ) - { + +if (retval !=BUF_SIZE ) { +close (fd);printf (TNAME " Error at aio_return(): %s\n" ,strerror (errno));exit (PTS_FAIL );
@@ -94,13 +92,14 @@ int main() retval =aio_return (&aiocb); -if (retval !=-1 ) - { +if (retval !=-1 ) { +close (fd);printf (TNAME " Second call to aio_return() should return -1 : %d\n" , retval);exit (PTS_FAIL ); } -printf ("Test PASSED\n" ); -return PTS_PASS ; +close (fd); +printf ("Test PASSED\n" ); +exit (PTS_PASS ); }
testcases/open_posix_testsuite/conformance/interfaces/aio_return/3-1.c +29 -26
113 lines not on this page · raw message
testcases/open_posix_testsuite/conformance/interfaces/aio_return/3-2.c +21 -19
@@ -35,15 +35,14 @@#include "posixtest.h" #define TNAME "aio_return/3-2.c" +#define BUF_SIZE 4096 -int main () +int main (void ) {char tmpfname[256 ]; -#define BUF_SIZE 4096char buf[BUF_SIZE ]; -int fd;struct aiocb aiocb; -int retval; +int fd, retval;#if _POSIX_ASYNCHRONOUS_IO !=200112L exit (PTS_UNSUPPORTED );
@@ -54,8 +53,8 @@ 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 );
@@ -66,19 +65,20 @@ int main()memset (buf,0xaa ,BUF_SIZE );memset (&aiocb,0 ,sizeof (struct aiocb )); aiocb.aio_fildes = fd; - aiocb.aio_buf = buf; + aiocb.aio_buf = buf; aiocb.aio_nbytes =BUF_SIZE ; -if (aio_write (&aiocb) ==-1 ) - { + +if (aio_write (&aiocb) ==-1 ) { +close (fd);printf (TNAME " Error at aio_write(): %s\n" ,strerror (errno));exit (PTS_FAIL ); } do { - retval = aio_error( &aiocb); - if (retval == -1) - { + retval = aio_error(&aiocb); + if (retval == -1) { + close(fd); printf(TNAME " Error at aio_error(): %s\n", strerror(errno)); exit(PTS_FAIL);
@@ -86,21 +86,23 @@ int main() }while (retval ==EINPROGRESS ); retval =aio_return (&aiocb); -if (retval !=BUF_SIZE ) - { + +if (retval !=BUF_SIZE ) { +close (fd);printf (TNAME " Error at aio_return(): %d, %s\n" , retval,strerror (errno));exit (PTS_FAIL ); } retval =aio_return (&aiocb); -if ( (retval !=-1 ) && (errno !=EINVAL ) ) - { + +if ((retval !=-1 ) && (errno !=EINVAL )) { +close (fd);printf (TNAME " aio_return() should fail\n" );exit (PTS_FAIL ); } -close (fd); -printf ("Test PASSED\n" ); -return PTS_PASS ; +close (fd); +printf ("Test PASSED\n" ); +exit (PTS_PASS ); }
testcases/open_posix_testsuite/conformance/interfaces/aio_return/4-1.c +20 -22
94 lines not on this page · raw message
------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT is a gathering of tech-side developers & brand creativity professionals. Meet the minds behind Google Creative Lab, Visual Complexity, Processing, & iPhoneDevCamp as they present alongside digital heavyweights like Barbarian Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
Again forgotten to add:
Signature · 13 lines
Cyril Hrubis [email protected] ------------------------------------------------------------------------------ Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT is a gathering of tech-side developers & brand creativity professionals. Meet the minds behind Google Creative Lab, Visual Complexity, Processing, & iPhoneDevCamp as they present alongside digital heavyweights like Barbarian Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com _______________________________________________ Ltp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list