Return-Path: Mailing-List: contact cvs-help@apr.apache.org; run by ezmlm Delivered-To: mailing list cvs@apr.apache.org Received: (qmail 54424 invoked by uid 1121); 8 Jan 2001 23:48:47 -0000 Date: 8 Jan 2001 23:48:47 -0000 Message-ID: <20010108234847.54415.qmail@apache.org> From: trawick@apache.org To: apr-cvs@apache.org Subject: cvs commit: apr/test testfile.c trawick 01/01/08 15:48:47 Modified: test testfile.c Log: get rid of bogus calls to perror() (I'll work through the remaining instances in the short term; thanks to Brian Havard for fixing another instance in log.c and cluing me in to the problem) Revision Changes Path 1.23 +23 -12 apr/test/testfile.c Index: testfile.c =================================================================== RCS file: /home/cvs/apr/test/testfile.c,v retrieving revision 1.22 retrieving revision 1.23 diff -u -r1.22 -r1.23 --- testfile.c 2001/01/05 19:40:06 1.22 +++ testfile.c 2001/01/08 23:48:45 1.23 @@ -76,13 +76,14 @@ apr_file_t *thefile = NULL; apr_socket_t *testsock = NULL; apr_pollfd_t *sdset = NULL; - apr_status_t status = 0; + apr_status_t status; apr_int32_t flag = APR_READ | APR_WRITE | APR_CREATE; apr_size_t nbytes = 0; apr_int32_t rv; apr_off_t zer = 0; + char errmsg[120]; char *buf; - char *str; + const char *str; char *filename = "test.fil"; char *teststr; @@ -103,8 +104,10 @@ fprintf(stdout, "Testing file functions.\n"); fprintf(stdout, "\tOpening file......."); - if (apr_open(&thefile, filename, flag, APR_UREAD | APR_UWRITE | APR_GREAD, context) != APR_SUCCESS) { - perror("Didn't open file"); + status = apr_open(&thefile, filename, flag, APR_UREAD | APR_UWRITE | APR_GREAD, context); + if (status != APR_SUCCESS) { + fprintf(stderr, "Didn't open file: %d/%s\n", status, + apr_strerror(status, errmsg, sizeof errmsg)); exit(-1); } else { @@ -128,8 +131,10 @@ fprintf(stdout, "\tWriting to file......."); nbytes = strlen("this is a test"); - if (apr_write(thefile, "this is a test", &nbytes) != APR_SUCCESS) { - perror("something's wrong"); + status = apr_write(thefile, "this is a test", &nbytes); + if (status != APR_SUCCESS) { + fprintf(stderr, "something's wrong; apr_write->%d/%s\n", + status, apr_strerror(status, errmsg, sizeof errmsg)); exit(-1); } if (nbytes != strlen("this is a test")) { @@ -142,8 +147,10 @@ fprintf(stdout, "\tMoving to start of file......."); zer = 0; - if (apr_seek(thefile, SEEK_SET, &zer) != 0) { - perror("couldn't seek to beginning of file."); + status = apr_seek(thefile, SEEK_SET, &zer); + if (status != APR_SUCCESS) { + fprintf(stderr, "couldn't seek to beginning of file: %d/%s", + status, apr_strerror(status, errmsg, sizeof errmsg)); exit(-1); } else { @@ -153,8 +160,10 @@ #if APR_FILES_AS_SOCKETS fprintf(stdout, "\tThis platform supports files_like_sockets\n"); fprintf(stdout, "\t\tMaking file look like a socket......."); - if (apr_socket_from_file(&testsock, thefile) != APR_SUCCESS) { - perror("Something went wrong"); + status = apr_socket_from_file(&testsock, thefile); + if (status != APR_SUCCESS) { + fprintf(stderr, "apr_socket_from_file()->%d/%s\n", + status, apr_strerror(status, errmsg, sizeof errmsg)); exit(-1); } fprintf(stdout, "OK\n"); @@ -178,8 +187,10 @@ fprintf(stdout, "\tReading from the file......."); nbytes = strlen("this is a test"); buf = (char *)apr_palloc(context, nbytes + 1); - if (apr_read(thefile, buf, &nbytes) != APR_SUCCESS) { - perror("something's wrong"); + status = apr_read(thefile, buf, &nbytes); + if (status != APR_SUCCESS) { + fprintf(stderr, "apr_read()->%d/%s\n", + status, apr_strerror(status, errmsg, sizeof errmsg)); exit(-1); } if (nbytes != strlen("this is a test")) {